• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

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

 
Ranch Hand
Posts: 311
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic