These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Custom persister
PostPosted: Wed Sep 27, 2006 8:42 am 
Newbie

Joined: Tue Jul 19, 2005 10:37 am
Posts: 2
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 for any help.

Thanks.


Top
 Profile  
 
 Post subject: Could it be a bug?
PostPosted: Wed Sep 27, 2006 2:16 pm 
Newbie

Joined: Tue Jul 19, 2005 10:37 am
Posts: 2
I did some tests for both custom persister and mutable attribute. Whatever isMutable() returns false or mutable="false", Hibernate will mark the status of entity A as READ_ONLY. When the session starts flush, Hiberate checks the status of the entity A in AbstractFlushingEventListener.prepareEntityFlushes(). Usually, if the status of an entity is MANAGED or SAVING, Hiberdate will go further and detect if there is TRANSIANT objects in the graph. If the status is READ_ONLY, Hibernate will skip this step.
In my case, entity A is READ_ONLY, then, the new entities added in the graph will not be detected and will not be inserted into T_B.

Can Hibernate team help it out?

Thank you very much.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.