We are trying to move from Hibernate {{5.6.10}} to {{6.1.5}} . We use Postgres 14.
The following JPQL query works on {{5.6.10}}:
{code:sql}select c from CalendarEventReminder c where (c.snoozeDate is null and (EXTRACT(EPOCH FROM (c.calendarEvent.startDate)) * 1000 - c.delay) <= ?1) or (c.snoozeDate is not null and (EXTRACT(EPOCH FROM (c.snoozeDate)) * 1000 + c.delay) <= ?1){code}
But fails on {{6.1.5}} with:
{code:java}Caused by: java.lang.IllegalArgumentException: org.hibernate.query.SemanticException: A query exception occurred [select c from CalendarEventReminder c where (c.snoozeDate is null and (EXTRACT(EPOCH FROM (c.calendarEvent.startDate)) * 1000 - c.delay) <= ?1) or (c.snoozeDate is not null and (EXTRACT(EPOCH FROM (c.snoozeDate)) * 1000 + c.delay) <= ?1)] at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:138) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:175) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:182) at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:761) at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:663) at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:127) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:360) at jdk.proxy2/jdk.proxy2.$Proxy272.createQuery(Unknown Source) at org.springframework.data.jpa.repository.query.SimpleJpaQuery.validateQuery(SimpleJpaQuery.java:94) ... 239 more Caused by: org.hibernate.query.SemanticException: A query exception occurred [select c from CalendarEventReminder c where (c.snoozeDate is null and (EXTRACT(EPOCH FROM (c.calendarEvent.startDate)) * 1000 - c.delay) <= ?1) or (c.snoozeDate is not null and (EXTRACT(EPOCH FROM (c.snoozeDate)) * 1000 + c.delay) <= ?1)] at org.hibernate.query.hql.internal.StandardHqlTranslator.parseHql(StandardHqlTranslator.java:130) at org.hibernate.query.hql.internal.StandardHqlTranslator.translate(StandardHqlTranslator.java:77) at org.hibernate.internal.AbstractSharedSessionContract.lambda$createQuery$2(AbstractSharedSessionContract.java:748) at org.hibernate.query.internal.QueryInterpretationCacheStandardImpl.createHqlInterpretation(QueryInterpretationCacheStandardImpl.java:141) at org.hibernate.query.internal.QueryInterpretationCacheStandardImpl.resolveHqlInterpretation(QueryInterpretationCacheStandardImpl.java:128) at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:745) ... 248 more Caused by: org.hibernate.query.sqm.ParsingException: line 1:85 no viable alternative at input 'selectcfromCalendarEventRemindercwhere(c.snoozeDateisnulland(EXTRACT(EPOCHFROM' at org.hibernate.query.hql.internal.StandardHqlTranslator$1.syntaxError(StandardHqlTranslator.java:46) at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41) at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:543) at org.antlr.v4.runtime.DefaultErrorStrategy.reportNoViableAlternative(DefaultErrorStrategy.java:310) at org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:136) at org.hibernate.grammars.hql.HqlParser.queryExpression(HqlParser.java:1180) at org.hibernate.grammars.hql.HqlParser.selectStatement(HqlParser.java:382) at org.hibernate.grammars.hql.HqlParser.statement(HqlParser.java:313) at org.hibernate.query.hql.internal.StandardHqlTranslator.parseHql(StandardHqlTranslator.java:116) ... 253 more{code}
The entities:
{code:java}@Entity public class CalendarEventReminder implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Access(AccessType.PROPERTY) private int id; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(nullable = false) private CalendarEvent calendarEvent;
private Date snoozeDate;
private long delay; }
@Entity public class CalendarEvent extends Serializable {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Access(AccessType.PROPERTY) private int id;
@Temporal(TemporalType.TIMESTAMP) private Date startDate; }{code} |
|