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: Reading related records in "many-to-many" implementation
PostPosted: Thu Jul 29, 2010 4:38 am 
Newbie

Joined: Thu Jul 29, 2010 3:47 am
Posts: 2
Hi.
I tried to implement a relation between two tables (Tag, Category), many-to-many through a third table. The third table also contains boolean field "isActive", besides keys from other tables.
There is a problem when performing an integration (union) test. This test should to create a relation, and then read these changes from DB - as a result both instance of the tables' classes should contain the new relation. Actually only the class, which has produced a storing, knows about new relation. Reading and filling of containers by the prepared records from the database are correct, the problem bound only with the simultaneous read-write.

P.S. I can send the project's source code to anybody who will take an interest to this problem.

Mapping:
Code:
<class name="Category">
    <id name="Id">
      <generator class="native"/>
    </id>
    <property name="Name" />
    <many-to-one name="Parent" column="ParentId" not-null="false" cascade="save-update" />
    <set name="Children">
      <key column="ParentId"/>
      <one-to-many class="Category" />
    </set>
    <set name="CategoryTags">
      <key column="CategoryId" />
      <one-to-many class="CategoryTag" />
    </set>
  </class>

  <class name="Tag">
    <id name="Id">
      <generator class="identity"/>
    </id>
    <property name="Name" />
    <set name="CategoryTags">
      <key column="TagId" />
      <one-to-many class="CategoryTag" />
    </set>
  </class>

<class name="CategoryTag" table="Category_Tag">
    <composite-id name="Key" class="CategoryTagKey">
      <key-many-to-one name="Tag" column="TagId" class="Tag" />
      <key-many-to-one name="Category" column="CategoryId" class="Category"/>
    </composite-id>
    <property name="isActive" type="bool"/>
  </class>



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.