• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hibernate

 
vijaya Yarlagadda
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I want to know how to use one to many relationship for List type in Hibernate.
I wil b grateful for anyone who tries to reply this.. Thanks in advance
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65342
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"vijayaY vijayaY", please check your private messages again for an important administrative matter.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


All you need to do is create your two classes, and in the encapsulating class, declare a list of instances of the encapsulated class. So, a Team has Players, right? Well, you could create a Team class that has a List of Players:




Of course, you'd need the Player class as well.



Then, it's just a matter of writing normal Java code that uses the Hibernate and JPA annotated classes!





It's all that easy!

Here's the full Hibernate3 tutorial if you're interested:

Doing One to Many and Many To One Associations with Hibernate and JPA Annotations

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic