Tips & Tricks

HQL Console with Pure JPA Facets

In IntelliJ IDEA HQL console can be used with pure JPA facets (as well as with Hibernate facets) to run JPAQL and HQL queries. All you need is Hibernate libraries and JDBC driver in a module classpath. If persistence.xml contains no Hibernate-specific database connection options, it should be mapped to an existing data source via JPA facet settings.

Tip: HQL console can also be used to generate DDL statements for JPA and Hibernate mappings via its Generate DDL command.

Update: If a Persistence Unit or Session Factory is mapped to a valid local Data Source there is no need to specify JDBC driver jars in a module classpath (Since 8.1.1).

Comments below can no longer be edited.

5 Responses to HQL Console with Pure JPA Facets

  1. Avatar

    Sigmund Lundgren says:

    October 16, 2009

    What if the entitymanagerfactory (JPA) is Spring configured? How to make the HQL console work?

    persistence.xml only contains an empty PU def with RESOURCE_LOCAL.

  2. Avatar

    Gregory Shrago says:

    October 19, 2009

    Currently only Hibernate LocalSessionFactoryBean/AnnotationSessionFactoryBean are supported by SpringHibernateIntegration plugin.
    Actually you are the first person to ask this question.

    Vote for:

    As a workaround configure the empty PU to contain all the required mappings, map it to a DataSource with valid JDBC parameters (driver/url/password) and use it to run console as if spring configuration doesn’t exist.

  3. Avatar

    WebComer says:

    September 11, 2012

    hi, Gregory. all the features look really promising, but there are questions.
    i’ve tried a coupla of tutorials, and something comes not very well with highlighting in hibernate and jdo tutorials, which i’ve tried. Look here:

    and here

    you probably know, how to fix it.

    if so, please let me know.

  4. Avatar

    WebComer says:

    September 11, 2012

    image’s tags with urls somehow get cut while posting. so i try to post it again, here they are :

  5. Avatar

    Gregory Shrago says:

    September 11, 2012

    @WebComer Hibernate facet should be correctly configured in Project Settings/Module in order to link hibernate.cfg.xml and HQL queries. If problem persist please create ticket in our issue tracker