-->
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: unproxy - how?, why?
PostPosted: Sat Nov 12, 2011 7:01 pm 
Newbie

Joined: Sat Nov 12, 2011 6:50 pm
Posts: 1
I'm trying to copy some of my data from one database to another one using two open hibernate sessions with two different configurations.

1. load an object from the first (server) database /session
2. generate a second object with a onetomany assotiation to the first
3. save the generated object in the second (server) database /session

now i get an error -- org.hibernate.HibernateException: illegally attempted to associate a proxy with two open Sessions

- i want cascade = ALL on the onetomany mapping of the generated object
- setting fetch = EAGER on the (annotations) mapping doesn't solve it

- there are ways to prevent the problem
- one (1) is not to use cascade = ALL and save all onetomany references manually
- another (2) is to unproxy the object loaded innn step 1 before associating it with the one generated in step 2

i like (2), and use "((HibernateProxy)o).getHibernateLazyInitializer().getImplementation()" - but:

What would be the "right way" to solve this?
Assuming "unproxy" is valid: Is there some more official method of unproxying an object?


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.