Java Mailing List Archive

http://www.gg3721.com/

Home » the NHibernate development list »

Re: [NHibernate-development] Cascading matters: REFRESH

Ayende Rahien

2008-07-03

Replies: Find Java Web Hosting

Author LoginPost Reply
I think that this is a valid behavior to have

On Fri, Jul 4, 2008 at 1:23 AM, Fabio Maulo <fabiomaulo@gmail.com> wrote:
Hi friend.
This post is to use the collective memory (for future questions) to remember a behavior breaking-change difficult to find.

Like you know with NH2.0.0 we have introduced some improvement about cascade.
There is a special situation for "refresh" cascade using collection.
Cascade "all" or "all-delete-orphan" include the "refresh".
"refresh" mean that NH rereads the state of associated objects from the database when an object is passed to refresh.

When the relation with the object is passed to refresh is an aggregation (a list for example) NH2.0.0 refresh all related objects inside the aggregation before refresh the aggregation owner.
This feature mean:
1)same behavior of H3.2
2)at the end an old TODO, for cascade and events, was removed
3)fix NH-1362.

Now what happen if we have something in sessionCache and another session delete an object of the collection and we use refresh ?
(NHibernate.Test.Legacy.MasterDetailTest.CachedCollectionRefresh)
When NH intent the refresh of each element of the aggregation an exception will throw because we are attempt to refresh a deleted entity.

To prevent this situation we can't use "refresh" to define the cascade of the aggregation that mean we can't use "all".
A possible combination is, for example : cascade="save-update,delete" or cascade="save-update,delete-orphan"
Others combination can work but we must remember the exclusion of "refresh".

I hope that the situation is not so usual but I know that the "all" and "all-delete-orphan" is very usual so the situation have a good probability to happen.

--
Fabio Maulo
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Nhibernate-development mailing list
Nhibernate-development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nhibernate-development


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Nhibernate-development mailing list
Nhibernate-development@(protected)
https://lists.sourceforge.net/lists/listinfo/nhibernate-development
©2008 gg3721.com - Jax Systems, LLC, U.S.A.