-->
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: Problem with CollectionFunction 'element in'
PostPosted: Mon Mar 10, 2008 9:51 am 
Newbie

Joined: Mon Dec 25, 2006 5:05 pm
Posts: 5
Hi, All

If I use the 'in elements' expression, where the elements of the set have composite ids...

hibernate translates this:
when (m.mctl, m.matp, m.mmdl, '0211') in elements (m.features)

to:
when (machine1_.MCTL , machine1_.MATP , machine1_.MMDL , '0211') in (feature7_.MCTL)

which cause the following exception:
Remote exception occured:
com.ibm.db2.jcc.b.SqlException: An ON clause associated with a JOIN operator or in a MERGE statement is not valid.

It seems as if hibernate uses only the first part of the composite key as use-in-equals. All the other cases it uses the key normally.

In debug mode it seems as if it could find the keys properly:
Quote:
| | | | \-[IN_LIST] SqlNode: 'inList'
| | | | \-[SQL_TOKEN] CollectionFunction: 'feature7_.MCTL' {method=elements,selectColumns=[feature7_.MCTL, feature7_.MATP, feature7_.MMDL, feature7_.DCOD],fromElement=feature7_}
| | | | \-[DOT] DotNode: '.' {propertyName=features,dereferenceType=3,propertyPath=features,path=m.features,tableAlias=feature7_,className=com.x.bean.Feature,classAlias=null}
| | | | +-[ALIAS_REF] IdentNode: '(machine1_.MCTL, machine1_.MATP, machine1_.MMDL)' {alias=m, className=com.x.bean.Machine, tableAlias=machine1_}
| | | | \-[IDENT] IdentNode: 'features' {originalText=features}


My mapping files are:

Code:
<class name="Machine" table="MACHINE">
<composite-id>
  <key-property name="Mctl" type="string">
   <meta attribute="use-in-equals">true</meta>
    <column name="MCTL" length="8" not-null="true"/>
  </key-property>
  <key-property name="Matp" type="string">
   <meta attribute="use-in-equals">true</meta>
    <column name="MATP" length="4" not-null="true"/>
  </key-property>
  <key-property name="Mmdl" type="string">
   <meta attribute="use-in-equals">true</meta>
    <column name="MMDL" length="4" not-null="true"/>
  </key-property>
</composite-id>
....
<set name="features" inverse="true"   order-by="DCOD ASC">
  <key>
   <column name="MCTL" length="8" not-null="true"/>
   <column name="MATP" length="4" not-null="true"/>
   <column name="MMDL" length="4" not-null="true"/>
  </key>
  <one-to-many class="Feature" />
</set>
</class>


and:

Code:
<class name="Feature" table="FEATURE">
  <composite-id>
   <key-many-to-one name="machine" class="Machine">
    <meta attribute="use-in-equals">true</meta>
    <column name="MCTL" length="8" />
    <column name="MATP" length="4" />
    <column name="MMDL" length="4" />
   </key-many-to-one>
   <key-many-to-one name="feature" class="Feature" column="DCOD">
    <meta attribute="use-in-equals">true</meta>
   </key-many-to-one>
  </composite-id>
  ....
</class>


I use hibernate 3.2.0.cr3.

Does anybody has some tips, what I do wrong?

Thanks:
Bence


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.