java - How does orphanRemoval=true work in JPA 2.0 -
can check how orphanremoval=true works? sql operation, i.e. database checked orphans after changes merged. or in memory operation tracks object has been removed collection, therefore must deleted?
what mechanics?
for example if 2 people editing same data , both have entity x.collectiony , collectiony has items id of 1,2,3,4 in it...then when both users working in application have same start point. if user 1 adds item 5,6,7 , user 2 commits...because 5,6,7 not part of collection happens?
also, if swap 1 collection out in backing bean, how affect tracking.
sorry basic questions, if sql operation ok , understand it, need head round using quite heavily @ moment.
if remove reference entity nulling out or having reference different, jpa orphan removal requires providers delete dereferenced entity. provider specific, i'm not sure need know - left orphaned required spec deleted. questions on multiple users editing same data not apply orphan removal - general problems synchronous data access. these changes should conflict each other regardless of orphan removal being involved, should using form of locking, optimistic locking being common.
if there no locking, there chance overwrite data stale data , cause entities removed, instance if user 2 detached instance , tries merge stale object entity manager. @ end, 1 transaction overwrite other without form of locking.
there number of blogs , docs can find describing locking, simplest use http://wiki.eclipse.org/eclipselink/userguide/jpa/basic_jpa_development/mapping/locking/optimistic_locking
Comments
Post a Comment