Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Object Relational Mapping and the fly likes How to persist data in tables with Many-to-Many relationship Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How to persist data in tables with Many-to-Many relationship" Watch "How to persist data in tables with Many-to-Many relationship" New topic
Author

How to persist data in tables with Many-to-Many relationship

Bhagirathi Mallick
Greenhorn

Joined: Jul 21, 2011
Posts: 26


and this is another class for options


and




And this is the main method





When i am executing this code
I am getting an exception like
org.hibernate.PersistentObjectException : detached entity passed to persist: com.crosscoce.entity.Question

Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 594
so you mean to say userId column will come in Email table only in case of one to many Bidirectional and not in case of one to many unidirectional? So in case of one to many unidirectional in Email table we should have only one column that is EmailId?

thanks
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to persist data in tables with Many-to-Many relationship
 
Similar Threads
Saving database records problem
Multiple Column Join
Confused with many to many,
Mysql auto generated PK used for another table and JPA
JPA - need help with query