[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5159) 'in elements' does not work on ElementCollections of Enums

John Aylward (JIRA) noreply at atlassian.com
Thu Jul 15 12:20:14 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5159?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=37805#action_37805 ] 

John Aylward commented on HHH-5159:
-----------------------------------

I'm able to reproduce this in my system as well (mysql 5.1, hibernate 3.5.0-Final). I worked around it by using
query.setString(param, enumVar.name());
instead of
q.setParameter(param, enumVar);

> 'in elements' does not work on ElementCollections of Enums
> ----------------------------------------------------------
>
>                 Key: HHH-5159
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5159
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core, entity-manager, query-hql
>    Affects Versions: 3.3.2, 3.5.1
>         Environment: Oracle 10, Hibernate 3.5.1-Final
>            Reporter: Peer Hartmann
>         Attachments: bugreport-mvn.zip
>
>
> When performing a query with an 'in elements' clause and an enum typed parameter, hibernate does not correctly set the parameter value for the underlying SQL. Here is an example (HQL) query:
> select e from Employee e where :function in elements( e.jobFunctions );
> Hibernate makes the following SQL of that (correct)
> Hibernate: select employee0_.id as id9_, employee0_.name as name9_ from Employee employee0_ where ? in (select jobfunctio1_.jobfunction from employee2jobfunction jobfunctio1_ where employee0_.id=jobfunctio1_.employeeId)
> ...but sets the parameter wrong as it uses toString instead of the name of the enum:
> [LogPreparedStatement] DEBUG - executing PreparedStatement: 'select ... from employee2jobfunction ...' with bind parameters: {1=[B at 2eb6fb}
> the exmaple uses an employee entity class with an ElementCollection of JobFunction-enum entries. See the attached zip-file for details.
> The same query works when using an entity instead of an enum. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list