This is a generic question for both Hibernate 2.x and 3.x versions.
Im a little new to hibernate and am trying to find out the posible ways i can map association classes to POJOs. Following is a detailed example and question.
Sorry for the long message, but im trying to give as much info as possible.
Relational Schema:
----------------------
1) Table called "Risk".
Columns; riskid int, riskname varchar(200).
2) Table called "Mission".
Columns; missionid int, missionname varchar(200).
3) Association between Mission and Risk; many-to-many, called "Mission2Risk"
4) Association class connected to association "Mission2Risk" called "Severity".
Columns: severitynumber int, severitynotes varchar(200)
Short description of diagram; A certain mission (could be anything like eg. learning how to ride a horse), has many risks (eg falling off) associated with it. The same risk can be in more than one mission. A mission risk relationship has severity associated with it. Meaning, for falling off a horse, the the same risk would be of severity "very high", but falling off a 3ft rock, the severity would be "low".
So, here are my questions:
--------------------------------
Q1. How do I map this in hibernate? I know i'll have a pojo called mission and risk. But what about mission2riskSeverity? Im not sure if it makes sense i have that as a pojo - rather it and all its attributes (severitynumber etc) should be instead attributes of ??
Q2. Is there more than one way to map this? If yes, what are the possible ways?
Q3. Now in UML, ternary associations and association classes are two separate things. Can association classes be mapped as a ternary association? What happens when you have a model with a ternary association along with an association class?
Q4. I saw a feature in Hibernate 3.x called: "ability to map association tables as having one-to-many multiplicity at the object level". What does this mean? Does it have anything to do with association classes? If yes, where can I find a concrete example of this feature?
Appreciate anyones help.
Thanks a mill,
Girish
|