[jpa] 'where 1=1' works but 'where true' and 'where 1' fail

Description

Not really sure if this is by design, but please review the following:

succeeds:

fails:

fails:

exception:
org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected AST node: true near line 1, column 85 [from tv.twelvetone.medusa.components.provider.sis.api.data.events.EventsEvent where true

Environment

None

Activity

Show:
Steve Ebersole
November 29, 2016, 4:02 PM

You wont find it. Neither of those are valid according to JPA spec. This would be a "feature request", but to be honest I do not see the benefit in supporting either of those.

S
December 6, 2016, 8:55 PM

They all seem to be valid predicates to me.

I wrote my own custom dialect, so this is not a problem for me anymore, but it's surprising how little documentation there is concerning this. It's also odd that [where 1=1] is in the specs but [where true] is not.

Steve Ebersole
December 7, 2016, 3:26 PM

Even SQL does not support these. JPQL and HQL are largely derived from SQL

Steve Ebersole
December 8, 2016, 2:39 AM

What we (dev team) decided here is that we will not support TRUE/FALSE as a predicates themselves.

We may even optimize 1=1 to just drop that predicate altogether in the generated SQL.

S
December 8, 2016, 3:36 AM

I added true() and false() to my custom sql dialect as a work around. It's useful when building an appended query that might not have any other predicates.

Assignee

Unassigned

Reporter

S

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure