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?
|
|