Florian Hof (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=6411c30...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiOGZmYjVjMDEw...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16312?atlOrigin=eyJpIjoiOGZmYj...
) HHH-16312 (
https://hibernate.atlassian.net/browse/HHH-16312?atlOrigin=eyJpIjoiOGZmYj...
) function with collection makes NullPointerException (
https://hibernate.atlassian.net/browse/HHH-16312?atlOrigin=eyJpIjoiOGZmYj...
)
Change By: Florian Hof (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=6411c30...
)
With criteria builder, I’m calling a function which has a collection as parameter. This
fails with a NullPointerException when hibernate validates the types.
My code (simplified), where I define a generic “contains in array” check.
{code:java} protected <T> Predicate
contains(Expression<Collection<T>> array, T value) {
return criteriaBuilder.equal(criteriaBuilder.literal(value),
criteriaBuilder.function("ANY", Object.class, array));
}{code}
This My goal is to query an array-column, something like:
struture with an array-column: {{ALTER TABLE person ADD COLUMN tel_numbers VARCHAR
ARRAY;}}
with Postgres specific: {{SELECT * FROM person p WHERE '+123456' =
ANY(p.tel_numbers)}}
or eventually SQL-Standard: {{SELECT * FROM person p WHERE '+123456' = ANY(SELECT
* FROM UNNEST(p.tel_numbers));}}
The function definition fails at {{ArgumentTypesValidator.validate:92}} with a
{{NullPointerException}}:
{{final JdbcType jdbcType = getJdbcType( queryEngine, argument, indicators, javaType );}}
// → null
{{jdbcType.getDefaultSqlTypeCode()}} → NullPointerException
The {{ArgumentTypesValidator.getJdbcType:139}} calls {{javaType.getRecommendedJdbcType}}
and {{CollectionJavaType.getRecommendedJdbcType}} always returns {{null}}. I think that
{{ArgumentTypesValidator.validate}} should handle a {{null}} jdbcType properly, in that
case not doing the validation.
Or what is your opinion? Is there a workaround?
(
https://hibernate.atlassian.net/browse/HHH-16312#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16312#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#100217- sha1:fd7c927 )