[hibernate-issues] How can I solve the problem?

Tim Wu timwu1616 at yahoo.ca
Mon Sep 25 09:39:10 EDT 2006


Hi there,
 
The case is there is a immutable class A (table T_A) and it has a list of mutable class B (table T_B). When class A gets persisted, only the new or modified instances in the list of class B will be inserted or updated in T_B. T_A will not get affected. 
Somehow, I need to use <union-subclass ....> to map a class A to a table T_A and use <bag ...> to map a list of class B in class A's mapping file. Because T_A is immutable. a custom peresister class is created that extends from UnionSubclassEntityPersister and its isMutable() method returns false. When Hibernate loads the class A, its status is set to READ_ONLY. 
In the business processing, some new instances of class B are added to the list in the class A. However, when the session gets flushed, Hibernate will check the status of the class A in AbstractFlushingEventListener.prepareEntityFlushes (...). In this method, only the status of MANAGED or SAVING will get flushed. Class A will not get flush because its status is READ_ONLY. The new instances of class B in the list will not get inserted into table T_B.
What is the right solution to this case? How can I update or insert B into T_B only without affect A?
I will appreciate if you could help me.
 
Thanks,
 
Tim 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20060925/1425adf9/attachment.html 


More information about the hibernate-issues mailing list