aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate/jpa: do I have to Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate/jpa: do I have to "re-attach"" Watch "Hibernate/jpa: do I have to "re-attach"" New topic
Author

Hibernate/jpa: do I have to "re-attach"

Sol Mayer-Orn
Ranch Hand

Joined: Nov 13, 2002
Posts: 311
Hi,
I'm using JPA with Hibernate implementation (but a solution on classic Hibernate would also be appreciated).
It's a Many-to-Many unidirectional relation, say between "Course" and "Student" (code below).
My problem is saving a Student when his Courses list is detached. I'm sure each such course is already saved in the database and has proper ID... so I wanted to just update the JoinTable without wasting performance on checking the existence of each course. I could do it easily with raw JDBC. But if I use Hibernate, it forces me to check and "re-attach" the courses (re-attaching is either through CASCADE, or re-selecting the courses).


Is there a way to tell Hibernate to "just trust me &update the JoinTable (linking this studentID to those courseIDs), without reattaching/validating each course?

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate/jpa: do I have to "re-attach"