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 Hibernate: many-to-many cascading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate: many-to-many cascading" Watch "Hibernate: many-to-many cascading" New topic
Author

Hibernate: many-to-many cascading

Sebastiaan Kortleven
Ranch Hand

Joined: Mar 12, 2004
Posts: 81
Hi all,

I've been reading up on many-to-many associations on the web and in Hibernate in Action, but I couldn't find the answer to my problem.

I've got an Object of my own class Query, I would like to add some security to this object, so I've created a User object. Each query can have several users that can access it, and each user can have several queries it can run..

This is the part of the query mapping file:


When I create a Query Object, I fill the users-set with UserQuery objects, but when I save the query (session.saveOrUpdate(query)), I get an exception:



Is it possible to save a many-to-many on cascade, or should you do it manually.. if it's possible.. what am I doing wrong?

Thanks in advance!!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Hibernate: many-to-many cascading
 
Similar Threads
JPA many-to-many with extra attribute
(N+1) selects � Hibernate bug?
Persistor Error:
how to save collection object into database
Hibernate: cascade save problem