We're updating the issue view to help you get more done. 

Criteria on custom user type does not work with applied filter

Description

I get following error when trying to use Criteria with filtering on custom user type with applied filter:

1 2 3 4 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) ...

There is a bug in QueryParameters.processFilters:

1 2 3 4 5 6 7 8 9 10 11 12 13 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 ); } }

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

Environment

None

Status

Assignee

Alexander Onnikov

Reporter

Alexander Onnikov

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

3.6.9

Components

Affects versions

5.4.2

Priority

Major