-->
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: Problem refreshing detached entity
PostPosted: Fri Jun 26, 2009 2:13 am 
Beginner
Beginner

Joined: Thu Jan 29, 2009 1:24 am
Posts: 20
Hello everyone,

I'm having a problem with refreshing a detached entity in hibernate. I'll try and keep my explanation of the situation as simple as possible.

I have three classes. Class A, B and C. All classes are entities. Class A contains an object of Class B with its CascadeType set to refresh only. Class B contains a list of Class C objects, also with a CascadeType of refresh only and its fetch type is set to lazy (it cannot be eager). These classes reside in a web application that has the job of serving up serialized copies of Class A objects in XML form.

Since serializing a PersistentBag object is a problem I set the list of Class C objects inside Class B to null before serialization. The important thing is the relationship of Class B objects to Class A. So when the client receives the XML output it includes all members of Class A as well as all members of Class B with the exception of the list of Class C objects.

I then deserialize the Class A object on the client side, make some change to it and push it back to the webapp to perform an update. Inside Class A's DAO I first perform a refresh on the Class B member before performing the merge.

The problem I am experiencing is that when the DAO performs the refresh on Class B I get an error from hibernate claiming that the object is not managed by hibernate. Now as said previously the intent here is to maintain the relationship of Class A to B so any missing information inside Class B should be irrelevant (except of course the ID that links the two database tables together).

Does refresh not do what I think it does? How do I make this work? Is my only option to pull the list of Class C objects and serialize them as well? If so its a lot of unnecessary data being sent back and forth from webapp to client. There must be a better way.

Thanks in advance for any help!


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.