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

Query on an enum collection fails

Description

When using the isMember operator on a collection of enums the enum parameter is not converted correct. In my attached test case I use hsql, which is throwing an exception:
Caused by: java.sql.SQLSyntaxErrorException: incompatible data type in conversion

Using an oracle-db I just get an empty result, because of the mismatch of the types of the parameter and the field.

1 2 3 4 5 Expression<Set<SimpleEnum>> simpleEnums = root.get( Person_.enumCollection); // Using the correct collection of enums and an enum parameter cq.where(cb.isMember(SimpleEnum.A, simpleEnums)); // leads to SQLSyntaxErrorException: incompatible data type in conversion in hsqldb
1 2 3 4 5 Expression<Set<SimpleEnum>> simpleEnums = root.get( Person_.enumCollection); // Using the correct collection of enums and an enum parameter cq.where(cb.isMember(SimpleEnum.A, simpleEnums)); // leads to SQLSyntaxErrorException: incompatible data type in conversion in hsqldb
1 2 3 4 5 // Here tricking hibernate, telling that it is a collection of strings and passsing a string argument. Expression<Collection<String>> simpleEnums = root.get("enumCollection"); cq.where(cb.isMember("A", simpleEnums)); // no exception and correct return valus

Environment

None

Status

Assignee

Steve Ebersole

Reporter

Oliver Breidenbach

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

4.3.8

Priority

Major