Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

@ManyToOne and @OneToMany : 2 primary keys

 
Dupon David
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.
as I still did not solve my problem, I will try to reformulate my question I want to make request EJB3 QL with joint.
here my tables:



Knowing that I have the following table which has like cl�s primary both cl�s primary of the tables the preceding one.



knowing that cardinality between these tables and ManyToMany, my question and to know if so that I can make a join

between my tables I must create tables interm�diates which contain that the primary keys like umlssnmi_wasnmi kind

and whoart_wasnmi for example, and to make @JoinTable; or the table "wasnmi" will join the tables.

I tried to implement :

For table WHOART:

For UMLSSNMI table:



The TermProjPK class which contains the primary keys of table WASNMI:



For WASNMI table:



That does not function, because I do not know how I can reach the fields ` MODIF' and ` SRC' of the table ` WASNMI' starting from TermSource object.



Somebody already made there?. I thank you in advance

[ November 15, 2006: Message edited by: Dupon David ]

[ November 17, 2006: Message edited by: Bear Bibeault ]
[ November 17, 2006: Message edited by: Bear Bibeault ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well you could always not map your join table, and map the two ends of your many-to-many relationship pointing to your join table.

Mark
 
Dupon David
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I thank you for this solution which appears tempting,
but my superior want imperatively that I use EJB3 with JBoss 4.0.4 and hibernate.
would have an other solution? I thank you in advance
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Um, my solution is using EJB3 and Hibernate. Check out the documentation on mapping Many to Many.

Mark
 
Dupon David
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In fact, the annotation @ManyToMany does not function for my case, because my table WASNMI is not simply a table of joint, but it contains of another fields that the foreign keys.

I implemented as follows:

TermSource and SnomedInter must have a collection of TermProj, and not of TermProPK. In the same way, TermProj must only have a direct bond towards 1 TermSource and 1 SnomedInter in addition. It is HIBERNATE which is given the responsability to manage the keys themselves! Us, only the objects are managed.

TermSource :


SnomedInter :


TermProjPk :


TermProj :



it remains me to be known how I can reach a SnomedInter object to leave a TermSource object!! I tested implementer as follows:



an idea?

[ November 17, 2006: Message edited by: Dupon David ]

[ November 17, 2006: Message edited by: Dupon David ]
[ November 17, 2006: Message edited by: Dupon David ]
 
Mike Keith
author
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David,

You keep looking for an answer, but you don't seem to be paying attention to the answers you are getting. You certainly didn't seem to even look past the basic chapter on OR mapping in our JPA book. Take a look in Chapter 8. There is a "Mapping Relationship State" section there that discusses your exact association table situation.

-Mike
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic