I get following error when trying to use Criteria with filtering on custom user type with applied filter:
{noformat} java.lang.ClassCastException: org.hibernate.type.CompositeCustomType cannot be cast to org.hibernate.type.ComponentType at org.hibernate.engine.spi.QueryParameters.processFilters(QueryParameters.java:575) at org.hibernate.engine.spi.QueryParameters.processFilters(QueryParameters.java:524) ... {noformat}
There is a bug in _QueryParameters.processFilters_:
{code:java} if ( type.isComponentType() ) { // should process tokens till reaching the number of "?" corresponding to the // numberOfParametersCoveredBy of the compositeType int paramIndex = 1; final int numberOfParametersCoveredBy = getNumberOfParametersCoveredBy( ((ComponentType) type).getSubtypes() ); while ( paramIndex < numberOfParametersCoveredBy ) { final String nextToken = tokens.nextToken(); if ( "?".equals( nextToken ) ) { paramIndex++; } result.append( nextToken ); } } {code}
It use _Type.isComponentType_ to check whether the type is a composite type, but then the type is casted to ComponentType. According to javadocs _Type.isComponentType_ returns true for CompositeType as well.
This is likely regression from HHH-10991 . I did not have a chance to test on another versions, but it does not work at least starting from 5.4.2 |
|