-->
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: key-many-to-one and composite-id --> HQL delete problem
PostPosted: Fri Jul 14, 2006 5:10 am 
Newbie

Joined: Fri Oct 28, 2005 9:08 am
Posts: 12
I have to delete an object that has a many-to-one association in his primary key using the HQL delete request (for performance reason).

The associated object has the key defined in a composite-id (with id there is no error).

The HQL request is :

this.getSession().createQuery("delete Label label where label.numseq = '01' and label.codlan = '01'" and label.mytad.argtbl = 'BE' and label.mytad.numbtl = '054' ").executeUpdate();

I can see in the log file the generated SQL :

delete from JPRG.LABEL, MYTAD mytad1_ where NUMSEQ='01' and CODLAN='01' and ARGTBL='BE' and NUMBTL='054'

I don't understand why hibernate adds MYTAD mytad1_ in the generated SQL. This causes the following error : SQL command not properly ended.

Here are the mapping files :
Code:
<hibernate-mapping package="com.cwsoft.businessobject">
     <class name="Label" table="LABEL" schema="JPRG">
          <composite-id>
               <key-many-to-one name="mytad">
                    <column name="NUMBTL"/>
                    <column name="ARGTBL"/>
                 </key-many-to-one>
                 <key-property name="numseq" type="string">
                      <column name="NUMSEQ"/>
                 </key-property>
                 <key-property name="codlan" type="string">
                      <column name="CODLAN"/>
                 </key-property>
          </composite-id>
          <property name="labele" column="LABELE" type="string" not-null="true" /> 
     </class>
</hibernate-mapping>

The associated class is defined with a composite-id :
Code:
<hibernate-mapping package="com.cwsoft.businessobject">
     <class name="Mytad" table="MYTAD">
          <composite-id>
               <key-property name="numbtl" type="string">
                    <column name="NUMBTL"/>
               </key-property>
               <key-property name="argtbl" type="string">
                    <column name="ARGTBL"/>
               </key-property>
           </composite-id>
           <property name="thdesc" type="string"  column="THDESC"/>
     </class>
</hibernate-mapping>


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.