How to get valued query from Hibernate Criteria(Not Logger)?

UPDATED: 04 May 2015

As per my knowledge there is no library available that allows you get Criteria query with its real values. So I came up with solution that allows you to do that.

Hibernate Assist, Its an open source Hibernate Criteria analysis tool. It has many features one of them is to get Criteria query with its value.


Source Code
Criteria criteria = objSession.createCriteria(User.class);
criteria.createAlias("Messages", "Messages");
criteria.createAlias("CreditCard", "CreditCard");
criteria.add(Restrictions.eq("Email", ""));
List<User> listUser = criteria.list();

HibernateAssist objHibernateAssist = new HibernateAssist(objSession);
String strQuery = objHibernateAssist.getValuedCriteriaQuery();

SELECT                        AS id0_2_, 
       this_.username                  AS username0_2_, 
       this_.password                  AS password0_2_,                     AS email0_2_,                   AS id1_0_, 
       messages1_.user_id              AS user2_1_0_, 
       messages1_.message_text         AS message3_1_0_,                 AS id2_1_, 
       creditcard2_.user_id            AS user2_2_1_, 
       creditcard2_.credit_card_number AS credit3_2_1_ 
FROM   user_master this_ 
       INNER JOIN message messages1_ 
               ON = messages1_.user_id 
       INNER JOIN creditcard creditcard2_ 
               ON = creditcard2_.user_id 
WHERE = '' 
Note: I tried to manage almost all cases however if you find for your Criteria its not working please comment your issues.