[hibernate-issues] [Hibernate-JIRA] Commented: (HSEARCH-306) Problem with composite key

Nick Vintila (JIRA) noreply at atlassian.com
Tue May 26 15:53:13 EDT 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=33250#action_33250 ] 

Nick Vintila commented on HSEARCH-306:
--------------------------------------

Yes, this is a defect as described by the original description.

The IN clause is generated incorrectly when the PK is composite.

To reproduce create an entity with a PK (String, int) and look it up using Hibernate Search (for example) - likely this happens if you create a simple IN clause search using the criteria framework.

To fix flip two lines:

			for ( int i=0; i<types.length; i++ ) {
				for ( int j=0; j<values.length; j++ ) {
					Object subval = values[j]==null ?
becomes

  		        for ( int j=0; j<values.length; j++ ) {
                                for ( int i=0; i<types.length; i++ ) {
					Object subval = values[j]==null ?

Nick

> Problem with composite key
> --------------------------
>
>                 Key: HSEARCH-306
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-306
>             Project: Hibernate Search
>          Issue Type: Bug
>          Components: query
>    Affects Versions: 3.1.0.CR1
>            Reporter: Mohit Khopkar
>         Attachments: hibernate jira.zip
>
>
> When a composite key is used and more than one results are expected , the values passed to the query are not in a proper expected order.
> In the below query the parameters passed are (A00, A00),(A00, 1),(2,5) ....instead of the correct order which should be (A00,1) ,(A00,2), (A00,5)
> (I have omitted the select part)..
> ..
> where ((this_.key_client, this_.key_identifier) in ((?, ?), (?, ?), (?, ?)))
> I tried to debug this issue and found that in the class org.hibernate.criterion.InExpression, the method getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)  has 2 for loops , one for types and other for values. I get 2 types CustomType and LongType and so for each type it retrieves the value and adds it in the list in the order A00,A00,A00,1,2,5
> I have attached the source code for your reference.
> For more information, refer to the below topic on the hibernate forums:
> http://forums.hibernate.org/viewtopic.php?t=992121&sid=16e54abb3dbc45d314f528a4646763cc

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