0

I have three classes

1- Narrative

2- NarrativeData

3- NarrativeSponsershipe

The Narrative class has oneToOne relation with both NarrativeData and narrativeSponership.

I need the three classes to have the same id. In other words, I need the three classes to be mapped using the id.

The id of the Narrative class is annotated using GenericGenerator and the property parameter's value is set to the associated NarrativeData field. This way the Narrative and NarrativeData will has the same id but the NarrativeSponsership will take another id.

How can I achieve the three classes having the same id?

Fanooos
  • 2,718
  • 5
  • 31
  • 55
  • For the id of Narrative, use @Id @GeneratedValue(strategy=GenerationType.AUTO), then persist and get the generated Id from Narrative, and put it for NarrativeData and NarrativeSponsership.. – Riadh Oct 21 '14 at 10:51
  • Why is it so important that they have the same ID? – Alan Hay Oct 21 '14 at 15:18
  • @AlanHay is not important. You are right maybe this is the solution. But for the sake of knowledge, is this possible? – Fanooos Oct 21 '14 at 16:11
  • Does this help? http://stackoverflow.com/a/6839336/1356423 – Alan Hay Oct 21 '14 at 16:14

0 Answers0