views:

46

answers:

2

Is it possible to put comments into Hibernate Query Language? If so, how?

+2  A: 

AFAIK, HQL does not support comments.

Hal
I think I agree. Does anyone have a definitive answer?
Thomas Bratt
+1  A: 

Make sure your session is configured with:


<property name="hibernate.use_sql_comments">true</property>

Then do:


Query query = ...;
query.setComment("Some comment here");

and you will see something like the following in your MySQL log file (if you're using MySQL):


5998 Query /* Some comment here */ select .....

Hisham
+1 For the nice tip! I wanted comments in the source but this is close :)
Thomas Bratt