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: Many to many with additional field in mapping table
PostPosted: Tue Apr 14, 2009 4:21 pm 
Newbie

Joined: Thu Dec 25, 2008 7:13 am
Posts: 10
Hibernate version:

2.0.1.4

Mapping documents:
<!-- Product -->
<class name="FlexiCommerce.Components.Product,FlexiCommerce" table="Flexi_Product">
<cache usage="read-write" />

<id name="ID" column="ID" type="Int32" unsaved-value="0" access="property">
<generator class="native" />
</id>

<bag name="Images" generic="true" lazy="true" table="Flexi_ProductImageMapping" cascade="none">
<cache usage="read-write" />
<key column="ProductID"></key>
<many-to-many class="FlexiCommerce.Components.Image,FlexiCommerce" column="ImageID"></many-to-many>
</bag>

</class>

<!-- Image -->
<class name="FlexiCommerce.Components.Image,FlexiCommerce" table="Flexi_Images">
<cache usage="read-write" />

<id name="ID" column="ID" type="Int32" unsaved-value="0" access="property">
<generator class="native" />
</id>
<property name="Bitmap" type="Serializable" length="2147483647" />
<property name="Hash" access="property"/>

</class>

Problem

I would like to add a sort number to the image field. Products may use the same pictures so I would like to keep the sort field relevant to the product-image mapping table.

Can I add images to the Product.Images property with a sort order property that will get saved to the mapping table rather than the image table?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 15, 2009 4:37 am 
Regular
Regular

Joined: Wed Feb 11, 2009 10:58 am
Posts: 55
If you don't want to build a class in between you could add a map and use the Index to store your sort parameter (though will have to take care about the sort order yourself).


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.