This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Uni-direction ManyTomany mapping with annotations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Uni-direction ManyTomany mapping with annotations" Watch "Uni-direction ManyTomany mapping with annotations" New topic

Uni-direction ManyTomany mapping with annotations

Sonx Nkuks
Ranch Hand

Joined: Aug 20, 2010
Posts: 47
Hi, i have a Basket class mapping ProductItem class with ManyToMany relationship. I only did the mapping on Basket

I would like to know if ProductItem will be updated if i execute hibernate update on Basket ... Say i have on ProductItem productA, productB, productC which are contained on the Basket (hence the relationship). If i remove productA (i do this by creating a new basket with only productB and productC then persist the new basket using update), would ProductItem table be updated? if not, how should i achieve this...
Karsten Wutzke
Ranch Hand

Joined: Jul 20, 2010
Posts: 106

I would rather ask why a unidirectional many-to-many relationship would make sense. This is contradictory by nature IMHO. In a many-to-many relationship there's no real owner, so the target side should be able to access the other as well.


OCJP JavaSE 6 (86%)
I agree. Here's the link:
subject: Uni-direction ManyTomany mapping with annotations
Similar Threads
ManyToMany - Repeated column in mapping problem
ManyToMany Deletes Entries
ManyToMany: ternary Relationship
Many to Many Table Relational Mapping with 3 Tables
Set not initialised on lazy loading