This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate with annotations - One-to-many question  RSS feed

 
Manny Garcia
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm using Hibernate with annotations and attempting for the first time to do a simple inner join on two tables in an entity class. My first table Alert has no key pointing to the second table EmailAddress. There is a one-to-many relationship between Alert and EmailAddress. EmailAddress has a column AlertId which is a foreign key to the id column of Alert.

So how do I code up the Alert class to include a List (or Set or any Collection, I don't care) of EmailAddress objects? Each entity classes work fine on their own (my Alert class currently does not contain any data members for the EmailAddress list) and I don't want to create a wrapper class that uses both of the other entity classes. I was hoping to just create an Address object when I needed one.


Regards,

Manny G
 
Omar Al Kababji
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this:




(peace)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!