Hi!
I have a little issue with a Spring MVC and Hibernate web-application. I have two entities, Event and User, which has a many-to-many relationship (User.events = Set<Event>, Event.attending = Set<User>)
I've built a web-application that works with data over a RESTful api. Sometimes when I want to work with class User I dont want to send all events to the client, User.events is therefore set to null (FetchType.LAZY). When the client updates User and sends a PUT with the JSON object back to the server, Hibernate thinks that we want to remove all relations between the User and Event (since User.events = null).
I've been trying to find a way to map so that Hibernate checks for null collections and skips those updates, or somehow load the entity, copy all attributes that I want to save and then save. However, this introduces new problems. Is there anyone that has experienced the same issue and found a solution?
|