How to put a comment into HQL (Hibernate Query Language)?

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


AFAIK, HQL does not support comments.

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 .....

If it helps your development, Hibernate Tools (Eclipse) supports double hyphens as single-line comments in their HQL editor. Helps me a lot. I've just tried the JPQL statement

SELECT pro,, te.ordinalNbr, tt.code, se.startYear,,, pte.ordinalNbr, ptt.code, pse.startYear
FROM Roster ro
  JOIN ro.season se
  JOIN te
  JOIN cl
  JOIN te.teamType tt
  JOIN te.rosters pro
  JOIN pro.season pse
  JOIN pte
  JOIN pcl
  JOIN pte.teamType ptt
WHERE = 32
ORDER BY pse.startYear

and it returned the pro instances.

Also not quite to the point, but it might be useful nontheless.

Need Your Help

Objective-C copy and retain

objective-c copy retain

When should I use copy instead of using retain? I didn't quite get it.

Learning Clojure - What should I know about Java and more


I have started learning Clojure recently, my main programming language is Ruby and I have no Java experience whatsoever.