How to test HQL queries?

You can use hibernate tools in eclipse to run queries. This will allow you to run HQL whenever you want to try something.

If you're using IntelliJ, there is Hibero.

There is a standalone editor from sun, but I haven't tried it.


With Intellij IDEA 8.1.3 the mechnism of choice is called 'Facet'. To instantly test HQL queries:

  1. create a data source Tools -> Data Source, Add Data Source, define driver, username and password of yor development db
  2. in case you dont have already a hibernate.cfg or you configure your session factory in a different way than via xml: create a hibernate.cfg file referencing all XML mapping's (define a name for the session factory, just for easier handling)
  3. in 'Project Structure' add Facet to your module of choice and assign the recently defined data source to the new facet
  4. switch to Java EE View
  5. Open Hibernate Facets - Node
  6. Right click Session factory and choose "Open HQL Console"
  7. enter HQL query in console ...and your're done.

sorry for this RTFM question.