Background: Java/Wildfly/Hibernate application with Java 8 and Hibernate 5.3.9.Final.
I have a named query like this
@NamedQuery(
name = DailyStatement.GET_EXPORT_DATES_BY_ORGASTRUCTUREIDS_FOR_MISEXPORT,
query =
" SELECT d.orgaStructureId, MIN(d.workingDay), MAX(d.workingDay) "
+ " FROM DailyStatement d "
+ " WHERE d.orgaStructureId in (:orgaStructureIds) "
+ " AND d.misExportFlag = false "
+ " AND d.state = net.shop.ob.ptm.types.timerecord.EDailyStatmentsState.CLOSED "
+ " AND d.workingDay <= :maxWorkingDay "
+ " GROUP BY d.orgaStructureId "
When starting the application I get an error
DailyStatement.getExportDatesByOrgaStructureIdsForMISExport failed because of: org.hibernate.hql.internal.ast.QuerySyntaxException: Invalid path: 'net.shop.ob.ptm.types.timerecord.EDailyStatmentsState.CLOSED' [ SELECT d.orgaStructureId, MIN(d.workingDay), MAX(d.workingDay) FROM net.shop.ob.ptm.dm.entities.DailyStatement d WHERE d.orgaStructureId in (:orgaStructureIds) AND d.misExportFlag = false AND d.state = net.shop.ob.ptm.types.timerecord.EDailyStatmentsState.CLOSED AND d.workingDay <= :maxWorkingDay GROUP BY d.orgaStructureId ]
The referenced, allegedly erroneous enum looks like this
public enum EDailyStatmentsState {
OPEN(0),
ERROR(1),
CLOSED(2);
private int id;
//(...)
The error does not occur if I set the hibernate parameter
hibernate.query.conventional_java_constants
to false
in persistence.xml. In blog post https://vladmihalcea.com/the-performance-penalty-of-class-forname-when-parsing-jpql-and-criteria-queries/ the meaning of this parameter is explained. I would understand the error, if the constant EDailyStatmentsState.CLOSED would not follow standard Java naming conventions, but as far as I can see, it does.
Because of performance reasons I would like to set the Hibernate option
hibernate.query.conventional_java_constants
to false and fix the root cause of the error. What could be causing this?
BTW, This question is not a duplicate of e.g. this question QuerySyntaxException with enum as the non-standard lower-case enum naming is causing the error there, unlike in my case.