• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate with annotations - One-to-many question

 
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)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic