-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: component mapping and 'IN' expressions
PostPosted: Tue Dec 06, 2005 5:46 am 
Newbie

Joined: Tue Dec 06, 2005 4:36 am
Posts: 1
There seems to be a problem using <components> within an 'IN' Expression.

Let's assume the following situation:

We have a class that contains a 'state' component with the properties 'code' and 'subCode'

Code:
<component
    name="state"
    class="com.xyz.State">
   
    <property
        name="code"
        type="java.lang.String"
        column="STATE_CODE"
        length="3"
        not-null="true"/>
                   
    <property
        name="subCode"
        type="java.lang.String"
        column="SUB_STATE_CODE"
        length="3"/>
</component>


I now want to search for objects that match a given component criteria (e.g. objects where code='DFT' and subCode='UDF'). Therefore I use an IN Expression.

Code:
// some code omitted
buffer.append("where state in (:state_list)");
Query query = session.createQuery(buffer.toString());
query.setParameterList("state_list", getStates());
query.list();

private State[] getStates() {
    return new State[] { new State("DFT", "UDF") };
}


The generated SQL code has a syntax error, as there are missing parenthesis around the 2-tuple ('DFT', 'UDF').

Code:
where ((this_.STATE_CODE, this_.SUB_STATE_CODE) in ('DFT' , 'UDF'))


When I use more than one components in my IN list

Code:
private State[] getStates() {
    return new State[] { new State("FIN", "UDF"), new State("DFT", "UDF") };
}


the syntax is ok, but the order is wrong:

Code:
where ((this_.STATE_CODE, this_.SUB_STATE_CODE) in (('FIN' , 'DFT'), ('UDF' , 'UDF')))


The correct order would be ('FIN', 'UDF') and ('DFT', 'UDF').

Has anybody experienced similar problems? If not I will report it as a BUG.

thx
patric


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.