[hibernate-issues] [Hibernate-JIRA] Created: (HHH-4954) Support Criteria API restriction index-refering functions for many-to-many, indexed collections

Marius (JIRA) noreply at atlassian.com
Thu Feb 25 10:03:47 EST 2010


Support Criteria API restriction index-refering functions for many-to-many, indexed collections
-----------------------------------------------------------------------------------------------

                 Key: HHH-4954
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4954
             Project: Hibernate Core
          Issue Type: Improvement
          Components: query-criteria
    Affects Versions: 3.5.0-CR-2
            Reporter: Marius


The problem is that the restrictions from Criteria API can't use hql functions.

I have a many-to-many relation but I want to left join the other side only with the first index (0).


In HQL(starting from 3.5.0-CR-2 for many-to-many relation) to get the first user's address I can write:
left join user.addresses address with index(address) = '0'

The generated SQL will look like this:
select * from USER user
    left outer join
        USER_ADDRESS address1_ 
            on user_.ADDRESS_ID=address1_.USER_ID 
            and (
                address1_.IDX='0'
            )
    left outer join
        ADDRESS address2_ 
            on address1_.ADDRESS_ID=address2_.ADDRESS_ID

where USER_ADDRESS is the table used for many-to-many relation and IDX is the index column

So I want to be able to write in Criteria like this:
.createAlias("user.addresses", "address", Criteria.LEFT_JOIN, Restrictions.eq("index(address)", 0))

Or maybe Restrictions.indexEq("address", 0).


Index-refering functions to implement: INDEX(), MININDEX(), MAXINDEX()

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