<html><head><style type="text/css"><!-- DIV {margin:0px} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><DIV>Hi there,</DIV>
<DIV>&nbsp;</DIV>
<DIV>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&nbsp;instances in the list of class B will be inserted or updated in T_B. T_A will not get affected. </DIV>
<DIV>Somehow, I need to use &lt;union-subclass ....&gt; to map a class A to a table T_A and use &lt;bag ...&gt; to map&nbsp;a list of&nbsp;class B in class A's mapping file.&nbsp;Because T_A is immutable.&nbsp;a custom peresister class is created that extends from UnionSubclassEntityPersister and its&nbsp;isMutable() method&nbsp;returns false. When Hibernate loads the class A, its status is set to READ_ONLY. </DIV>
<DIV>In the business processing, some new instances of class B are added to the list&nbsp;in the class A. However, when the session gets flushed,&nbsp;Hibernate will check the status of the class A in AbstractFlushingEventListener<WBR>.prepareEntityFlushes (...).&nbsp;In this method, only the status of MANAGED or SAVING will get flushed.&nbsp;Class A&nbsp;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.</DIV>
<DIV>What is the right solution to this case? How can I update or insert B into T_B only without affect A?</DIV>
<DIV>I will appreciate if you could help me.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thanks,</DIV>
<DIV>&nbsp;</DIV>
<DIV>Tim&nbsp;</DIV>
<DIV></DIV></div></body></html>