-->
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: Problem with mapping
PostPosted: Mon Oct 03, 2005 9:01 am 
Newbie

Joined: Mon Oct 03, 2005 8:39 am
Posts: 4
Hello,

i'm a new user of Hibernate mappings in my Java classes via Doclets.
And i have a few problems to resolve certain mappings...

I often have the following context :
- Class A
- Class B
These two classes are linked (n-n) by an association class C, witch have its own attributes (a kind of valuation of the link).

My Java Class "A" has certain attributes and a "getClassB-ObjectswithC-valuation()" method.
My Java Class "B" has the same inverse method, or a "getClassA-RefObject()" method if relation is 1-n.
I created a Java class "C" which contains its own attributes and one object of type A and one of type B.
In order to have this class work like the following "join table":

ClassAobj1 ClassBobj1 ClassCVal1
ClassAobj1 ClassBobj2 ClassCVal2
...
ClassAobj2 ClassBobj1 ClassCVal1
ClassAobj2 ClassBobj2 ClassCVal2
...

so the "key" of this table is (ClassA, ClassB) objects.

But i don't see how to declare/map this with hibernate doclets ???
shall i use (for Class A) something like :

@hibernate.set table="C"
@hibernate.collection-key column="A_ID"
@hibernate.collection-many-to-many
class="ext.xxx.data.bean.B"
column="B_ID"
foreign-key="A_ID"

but where do i define my class C attribute ?...
may i write something like :

@hibernate.set table="C"
@hibernate.collection-key column="A_ID"
@hibernate.collection-many-to-many
class="ext.xxx.data.bean.B"
column="B_ID"
@hibernate.collection-many-to-many
class="ext.xxx.data.bean.C"
column="C_ID"
primary-key="(A_ID,B_ID)"


or rather use a hibernate.map solution ? (which one) ?

I sometimes also have the same type of relations but with Class B = Class A. (an object A1 has a list of other A objects "valuated" with a C class attribute), which is even more difficult to write with doclet tags...

thank you in advance for any help!

Stephane


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.