Christian Beikov (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *commented* on HHH-15743 (
https://hibernate.atlassian.net/browse/HHH-15743?atlOrigin=eyJpIjoiNGM3MD...
)
Re: Querying with empty parameter list fails (
https://hibernate.atlassian.net/browse/HHH-15743?atlOrigin=eyJpIjoiNGM3MD...
)
That’s simply not how you should do this. There are many issues with this approach.
* Potentially sending long lists twice
* Confusing the query planner
* Destroying reasonable planner estimates when the prepared query switches to a generic
statement
Just do what everyone else does who want conditional filtering and only append that
condition to the query when you actually have a non-empty list of departments. With e.g.
JPA Criteria you’d simply not add that IN predicate to your predicate list if no value is
given.
And if you are using HQL, then consider switching to JPA Criteria for such dynamic
filtering use cases.
The only possible change I would support is to throw an exception when using
coalesce(:param) where :param refers to a list parameter, because list parameters are
actually only valid in the IN predicate.
(
https://hibernate.atlassian.net/browse/HHH-15743#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-15743#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#100210- sha1:eab5823 )