I have issue with Hibernate query, my IDEA inspection error syntax:
This inspection controls whether the Persistence QL Queries are error-checked
But I create mapping for Task
objects in my hibernate.cfg.xml
:
<session-factory>
<property name="connection.url">jdbc:postgresql://localhost:5432/todo_list</property>
<property name="connection.driver_class">org.postgresql.Driver</property>
<property name="connection.username">postgres</property>
<property name="connection.password">1</property>
<property name="dialect">org.hibernate.dialect.PostgreSQL95Dialect</property>
<mapping resource="ru/pravvich/model/Task.hbm.xml" />
</session-factory>
Facets:
If I cheating IDE and instead createQuery("select t from Task t")
, create variable and push in createQuery
String hql = format("select t from Task t where t.id > %s", 0);
session.createQuery(hql)
It's work, but it's not normal code. How to fix this issue
Here is what for me resolve the same issue:
Open in the IDEA Preferences (Settings)/Editor/Language Injections
and under the list of languages find Session (org.hibernate)
.
Under the column Language, it should be selected Hibernate QL
.
Double click on it and a list of operations will be displayed.
Select the operations that you need.