Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JoinTable on OneToMany unidirectional JPA.

 
Pedro Erencia
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In JPA a OneToMany unidirectional relationship is mapped on the database with a join table. Why can't this be done with a foreign key, just as with a OneToMany bi-directional relationship ?
Is it the same in hibernate ?
Anyone knows which is the problem about a foreign key on that case?

Thanks.
 
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
Here's a tutorial that looks at a One to Many unidirection relationship with Hibernate, and then turns it into a bidirectional One to Many relationship. Hibernate and JPA (Java Persistence API) annotations are used for the example.

Implementing One-To-Many Relationships with Hibernate and JPA Annotations

Perhaps you weren't implementing the flipside of the relationship with a many-to-one annotation, or the Join Column annotation?






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