Thomas Herth (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=712020%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiOGMzYWQ3ODMz...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16804?atlOrigin=eyJpIjoiOGMzYW...
) HHH-16804 (
https://hibernate.atlassian.net/browse/HHH-16804?atlOrigin=eyJpIjoiOGMzYW...
) SqmComparisonPredicate does not store boolean Expressions (
https://hibernate.atlassian.net/browse/HHH-16804?atlOrigin=eyJpIjoiOGMzYW...
)
Issue Type: Bug Affects Versions: 6.2.5 Assignee: Unassigned Created: 15/Jun/2023 03:53 AM
Environment: Spring Boot 3 application on Windows 10, Java 17, PostgeSQL 13 Priority:
Major Reporter: Thomas Herth (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=712020%...
)
To dynamically add restrictions to a query I used the following way:
CriteriaBuilder cb = session.getCriteriaBuilder();
Predicate restriction = cb.and();
List<Expression<Boolean>> restrictions = restriction.getExpressions();
if (…)
{ restrictions.add(cb.equal(root.get(Table_.column), …); }
cq.select(root)
.where(restriction)
After migration my application to Spring Boot 3 with Hibernate 6 this does not work
anymore:
Predicate is of type SqmComparisonPredicate wich extends AbstractNegatableSqmPredicate
which extends AbstractSqmPredicate:
@Override
public List<Expression<Boolean>> getExpressions()
{ /// most predicates do not have sub-predicates return new ArrayList<>(0); }
Every time getExpressions() is called a new array is created which is not stored in the
Predicate, therefore “restriction” is “empty” i.e. does not contain any restriction added
before.
(
https://hibernate.atlassian.net/browse/HHH-16804#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16804#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100226- sha1:d46780b )