-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Updating Entities with null collection from JSON
PostPosted: Thu Aug 15, 2013 10:26 am 
Newbie

Joined: Thu Aug 15, 2013 10:16 am
Posts: 1
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.