<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> </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 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 <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. </DIV>
<DIV>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<WBR>.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.</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> </DIV>
<DIV>Thanks,</DIV>
<DIV> </DIV>
<DIV>Tim </DIV>
<DIV></DIV></div></body></html>