-->
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: Order when saving mappings/relations between entities.
PostPosted: Tue Sep 19, 2006 5:33 pm 
Newbie

Joined: Tue Sep 19, 2006 4:55 pm
Posts: 2
Does hibernate have and order on how mappings/relations between entities are made persistant in the data base. Take the example xml mapping I've written below:

Code:
<class name="Foo" table="FooTable">
     <id name="id" column="Foo_Id">
        <generator class="native" />
     </id>
     <property name="repr" type="text" />
   <many-to-one name="bar_object" column="BarObjectClass_ID" />
     <list name="values" table="ValuesOfOtherObjectTypeInFoo">
        <key column="Foo_Id" not-null="true"/>
        <list-index column="sortedOrder" />
        <many-to-many column="OtherObjectType_ID" unique="true" class="OtherObjectType"/>   
     </list>
</class>


An instance of the Foo class is mapped many-to-one with some BarObject instance and is also mapped many-to-many (actully a join many-to-one) with another class. The problem I've is that BarObject set restrictions on the instance of Foo, in particular a Foo instance it's going to be related with "OtherObjectType" if the restrictions on BarObject are met. So when saving a Foo instance I first need to set the relation with "BarObjectClass" and then relate it with "OtherObjectType".

When I first tried this The mapping was like this:


Code:
<class name="Foo" table="FooTable">
     <id name="id" column="Foo_Id">
        <generator class="native" />
     </id>
     <property name="repr" type="text" />

     <list name="values" table="ValuesOfOtherObjectTypeInFoo">
        <key column="Foo_Id" not-null="true"/>
        <list-index column="sortedOrder" />
        <many-to-many column="OtherObjectType_ID" unique="true" class="OtherObjectType"/>   

   <many-to-one name="bar_object" column="BarObjectClass_ID" />


     </list>
</class>


An instance the property "repr" has different values depending on the values list.
Repr is generated when the .getRepr() is called depending on the values list and the values list depends on the association <many-to-one name="bar_object" column="BarObjectClass_ID" />. I get wrong results with the above mapping. Although the first mapping I showed you gives the correct results, and I would like to know if this is not just a "coincidence".

I've scanned through most documantation I could get a hang on, If I missed something, please inform me!

Thanks in advance.
Ale.


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.