[hibernate-issues] [Hibernate-JIRA] Created: (HHH-4922) Incorrect Parsing of IN-Clause in JPQL

Pierce Wetter (JIRA) noreply at atlassian.com
Tue Feb 16 12:17:47 EST 2010


Incorrect Parsing of IN-Clause in JPQL
--------------------------------------

                 Key: HHH-4922
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4922
             Project: Hibernate Core
          Issue Type: Bug
          Components: entity-manager
    Affects Versions: 3.5.0-Beta-4
         Environment: 3.5.0-Beta-4, ALL
            Reporter: Pierce Wetter


In the reference implementation, a query such as the following:

select u from User u where u.loginName IN :logins

will accept :logins as a parameter of Collection<String>. While:

select u from User u where u.loginName IN (:login1)

will accept :login1 as a String. 

For a collection, Hibernate insists on:

select u from User u where u.loginName IN (:logins)

and it throws an error on:

select u from User u where u.loginName IN :logins

But not only does this not match the reference implementation, but it precludes the use of:

select u from User u where u.loginName IN (:login1. :login2, :login3)

That is, is prevents the use of the IN clause with a hard coded set of String values. 

Test Case:

It's pretty trivial. Both of these should be allowed:

Query           qTwoLogins    = em.createQuery(
                "select u from User u where ou.loginId in (:login1, :login2)"
            );
        Query           qCollectionLogins       = em.createQuery(
                "select u from User u where u.login in :logins"
            );

qTwoLogins.setParameter("login1","testuser1");
qTwoLogins.setParameter("login2","testuser2");

HashSet<String> list= new HashSet<String>(2);

list.add("testuser1");
list.add("testuser2");

qCollectionLogins.setParameter("logins",list);



-- 
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