-->
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: bag using wrong key for many to many look up
PostPosted: Wed Mar 02, 2011 2:14 pm 
Newbie

Joined: Wed Mar 02, 2011 2:08 pm
Posts: 1
I'm going to simplify the problem I'm having. So let's suppose we have an NHibernate domain of pets, with Spot the dog, Fluffy the cat, Hunter the cat, and SSSS the snake so in the db these guys would look like:

ID Name Species
1 Spot 1
2 Fluffy 2
3 Hunter 2
4 SSSS 3

And we have a species table

ID Species
1 Dog
2 Cat
3 Snake

And let's say we have a skin-type table with these two entries

ID Type
1 Furry
2 Scaley

And a look up table that looks like

Species Type
1 1
2 1
3 2

How do I map this so that will pull the type of skin in with the object.

I've looked at a mapping file like this

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="menagerie" assembly="menagerie"> <class name="Pet" table="Pets">
<id name="Id">
<column name="id" />
<generator class="native" />
</id>
<property name="Name" />
<many to one name="Species"
class="PetSpecies"
column="Species"
cascade="all" />
<bag name="SkinType" table="Species_SkinType" cascade="none" lazy="false">
<key column="Species" />
<many-to-many class="SkinType" column="[type]" />
</bag> </class>
</hibernate-mapping>

However, the bag that's supposed to be filled with the pet's skin type wants to use the pet's id as the look up key value, not the pet's species. How do I get it to use the pet's species to populate the skintype for the pet?


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.