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.  [ 3 posts ] 
Author Message
 Post subject: Collection mapping without table association
PostPosted: Thu Apr 16, 2009 4:20 am 
Newbie

Joined: Thu Apr 16, 2009 3:55 am
Posts: 3
Hello I have this table strcture (can't change it)

TableA
IDA Ref
1 1
2 2

TableB
Ref Value1 Value 2
1 0 2
1 1 2
2 0 3

In want the collection of entity from Table B where TableA.Ref = TableB.Ref

EntityA.ListeEntityB

EntityA(IdA= 1) muste return 2 EntityB ((Value1=0, Value2=2);(Value1=1, Value2=2)


This mapping configuration does not work

<class name="EntityA" table="TableA">
<id name="Id" column="IDA" unsaved-value="0">
<generator class="native" />
</id>

<bag name="ListeEntityB" table="TableB">
<key column="Ref"></key>
<one-to-many class="EntityB" />
</bag>
</class>


So how can i make the association whith this ugly structure (can't change it), does hibernate requires an association table for collection ? How can i make the association without a unique index (Ref in Table B is not unique ??)

Thanks for your reply


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 16, 2009 5:30 am 
Regular
Regular

Joined: Wed Feb 11, 2009 10:58 am
Posts: 55
I think NHibernate can't handle this. How should NHibernate know which Object to change without an unique identifier, if you update one?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 16, 2009 7:19 am 
Newbie

Joined: Thu Apr 16, 2009 3:55 am
Posts: 3
reflection wrote:
I think NHibernate can't handle this. How should NHibernate know which Object to change without an unique identifier, if you update one?


Thanks for your response, I need to read only not update delete or insert


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.