-->
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: composite primary keys and mapping three tables
PostPosted: Tue Mar 13, 2007 5:01 am 
Newbie

Joined: Mon Mar 12, 2007 1:29 pm
Posts: 3
Location: Barcelona, Spain
Hi all,

Actually, i've got 3 tables (in an Oracle database) and i can't find the way to write their mappings.
I want to represent the primaries keys of thes tables.
The structure looks like this :

TASQUES_DOCUMENTS ------ DOCUMENTS
TTD_SYS ------------------------ TDO_SYS
TDO_CODI-------------------- TDO_CODI
TTQ_CODI


TASQUES_DOCUMENTS --- TASQUES
TTD_SYS ------------------ TTQ_SYS
TDO_CODI
TTQ_CODI ---------------- TTQ_CODI

So i defined DOCUMENTS:

Code:
<hibernate-mapping package="net.gencat.uid.model.param.document">
   <class
      name="Document"
      table="UIDT_DOCUMENTS">
      <composite-id>
         <key-property name="dosys" column="TDO_SYS" />
         <key-property name="docodi" column="TDO_CODI" />
      </composite-id>
   </class>   
</hibernate-mapping>



and then TASQUES :

Code:
<hibernate-mapping package="net.gencat.uid.model.param.tasca">
   <class
      name="Tasca"
      table="UIDT_TASQUES">
      <composite-id>
         <key-property name="tqsys" column="TTQ_SYS" />
         <key-property name="tqcodi" column="TTQ_CODI" />
      </composite-id>
      <set name="tascaDocuments" inverse="true" lazy="true" order-by="TDO_CODI">
         <key>
            <column name="TTQ_CODI"/>
            <column name="TTQ_SYS"/>
         </key>
         <one-to-many class="net.gencat.uid.model.param.tasca.TascaDocument"/>
      </set>
   </class>   
</hibernate-mapping>



and the last mapping TASQUES_DOCUMENTS :

Code:
<hibernate-mapping package="net.gencat.uid.model.param.tasca" >
   <class
      name="TascaDocument"
      table="UIDT_TASQUES_DOCUMENTS">
      <composite-id name="id" class="TascaDocumentPK">
         <key-property name="tdsys" column="TTD_SYS"/>
         <key-many-to-one name="tasca"
            class="net.gencat.uid.model.param.tasca.Tasca">
            <column name="TTQ_SYS"/>
            <column name="TTQ_CODI"/>
         </key-many-to-one>
         <key-many-to-one name="document"
            class="net.gencat.uid.model.param.document.Document">
            <column name="TDO_SYS"/>
            <column name="TDO_CODI"/>
         </key-many-to-one>   
      </composite-id>
   </class>   
</hibernate-mapping>



Certainly, you understood my problem is related to the last mapping. When i'm trying to acces to TascaDocument with the set tascaDocuments of Tasques,
the system throw an SQLGrammarxception. Probably because my mapping isn't correct.
I did have created all asociated classes, included the class which contains the primary key of Tasques_Documents
Any idea ?


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.