-->
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.  [ 2 posts ] 
Author Message
 Post subject: Collection mapping to sliced table
PostPosted: Mon Jun 20, 2005 12:17 pm 
Newbie

Joined: Fri Jun 17, 2005 11:24 am
Posts: 5
[b]Hibernate version:3.0.5

I have a class that contains two collections of sub-components of the same type, but with different meanings. In the database, I map these collections using the same link table, but with a different type column. I can pull data that already exists in the database wonderfully. When I insert a new SolutionComponent into the database, the sub_component_list rows have null sub_list_type columns. What I need is someway to specify the sub_list_type column on each set element, so that when an insert/update happens the sub_list_type value would get set correctly. Any ideas?

<hibernate-mapping>
<class name="SolutionComponent" table="solution_component">
<id name="sku" column="sku" />

….

<!-- A solution component can be have lists of other solution components
(alternative,linked) managed by the sub_component_list table
distinguished by the sub_list_type column -->
<set name="alternateComponentList" table="sub_component_list"
where="sub_list_type = 1" lazy="false">
<key column="solution_component_sku" />
<many-to-many column="sub_component_sku" class="SolutionComponent"/>
</set>
<set name="linkedComponentList" table="sub_component_list"
where="sub_list_type = 2" lazy="false">
<key column="solution_component_sku" />
<many-to-many column="sub_component_sku" class="SolutionComponent"/>
</set>
</class>

Thanks,
--david


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 20, 2005 12:40 pm 
Newbie

Joined: Fri Jun 17, 2005 11:24 am
Posts: 5
Wow, that is ugly. Repost of code:

Code:
<hibernate-mapping>
<class name="SolutionComponent" table="solution_component">
<id name="sku" column="sku" />

….

<!-- A solution component can be have lists of other solution components
  (alternative,linked) managed by the sub_component_list table
  distinguished by the sub_list_type column -->
  <set name="alternateComponentList" table="sub_component_list"
     where="sub_list_type = 1" lazy="false">
    <key column="solution_component_sku" />
    <many-to-many column="sub_component_sku"     
         class="SolutionComponent"/>
  </set>

  <set name="linkedComponentList" table="sub_component_list"
      where="sub_list_type = 2" lazy="false">
  <key column="solution_component_sku" />
  <many-to-many column="sub_component_sku" 
      class="SolutionComponent"/>
  </set>
</class>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.