0

while running a named query in hibernate-5 how would I make sure that it is using JPA2.1 standards(JPQL Grammer)

When running in hibernate5 it executes fine, this should fail when in JPA2.1, what/where do I need set something to use the JPA standard(JPQL Grammar).

String queryString = "from DeptEmployee where employeeNumber = :employeeNo";
Query jpaQuery = entityManager.createQuery(queryString);

this should throw an exception (for not having a "select" keyword according) when running against JPQL grammar in Hibernate-5 but should run fine without setting JPQL grammar.

I want to run using Hibernate5 engine but still want to keep the JPA implementation. btw I tried this property 'hibernate.query.jpaql_strict_compliance= true', this didn't work. ref: http://docs.jboss.org/hibernate/orm/5.2/javadocs/org/hibernate/cfg/AvailableSettings.html#JPAQL_STRICT_COMPLIANCE

1 Answers1

1

You can't. Because Hibernate is the underlying JPA implementation and accepts queries in HQL style (without select).

Btw. why do you want to do that?

Simon Martinelli
  • 34,053
  • 5
  • 48
  • 82
  • I want to do that because -- I want to run using Hibernate5 engine but still want to keep the JPA implementation. btw I tried this property 'hibernate.query.jpaql_strict_compliance= true', this didn't work. ref: [http://docs.jboss.org/hibernate/orm/5.2/javadocs/org/hibernate/cfg/AvailableSettings.html#JPAQL_STRICT_COMPLIANCE] @simon – PrimeAvenger May 17 '19 at 14:32