Can someone tell me if my understanding below is correct re: cascading. 

It seems that it would make the most sense that if you are using cascading, you 
should also use eager loading.  If not, its concievable that you've just 
introduced an easy way for some client to unknowingly destroy data.  

Here's an example (note that the important part is the entity is detached when 
going to the client and the client is not getting or modifying the 
relationship's objects):

Person has PhoneNumbers relationship that is lazy loaded but I cascade all 
operations.

Client wants to change the person's nickname so it calls into a SLSB to get the 
Person object; the Person is loaded, detached and returned to the client.  
Person is loaded, but the PhoneNumbers objects are not due to the lazy 
fetching.  Client calls Person.setNickname and then passes the Person object 
back to the SLSB so it can merge it.  Well, at this point, the POJO has an 
empty set of PhoneNumbers.

Won't the merge (when cascading) delete all of those existing PhoneNumbers 
related to the Person because the Person object has an empty set of PhoneNumber 
objects in the relationship (not because the client deleted them but because 
the client never asked to load them and the container never eagerly loaded them 
automatically).

The client must be smart enough to know the cascading and fetching rules here - 
it needs to know that merging will cascade so it needs to explicitly ask to get 
the current set of phone numbers since it knows that with the lazy fetching it 
won't happen automatically.

If that's the way cascading works, it seems that eager loading should always be 
enabled when cascading is enabled (unless you want to force your client 
developers to know about the fetching/cascading settings ahead of time).

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3929839#3929839

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3929839


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to