Hello,
I have an object of type A which is composed of an object of type B. Type B contains two collections, both of which are mapped with lazy load.
I have a mapper for A and a mapper for B, but there is a slight difference. When dealing with objects of type A, the information in B (including the collections) gets mapped to a different table than if B were mapped alone. So, when mapping A, the B component of A and its associated collections are mapped to table X.
Now, the mapper for B (i.e. if B is mapped by itself), puts the information in table Y.
Here's the problem:
I create an object of A:
openSession
session.save(a)
closeSession
then, I later pass the object of A over a queue which then extracts and saves B:
b = a.getB();
openSession
session.save(b)
closeSession
What happens here is that Hibernate deletes the collections from table X (which is mapped from A), and then inserts the collections into table Y (which is mapped from B). However, I want the data to be in both X and Y (i.e. do not delete from X).
This can be solved if I can completely detach A, filling in all lazy loaded data, etc. However, I don't see how this is possible with Hibernate.
Any help is appreciated!
|