openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pinaki Poddar <ppod...@apache.org>
Subject Re: Able to remove relation with ManyToMany and no cascade.
Date Thu, 10 Jul 2008 04:00:43 GMT

Hi,
> Access the student list and remove the entry in the list with SID "1"

What exactly does 'remove' imply?  Is it something like:
a) team.getStudents().remove(1);
or
b) em.remove(team.getStudents().get(1));

If it is (a) then no database change is expected. Removal of entity X from a
Java collection will not, in general, imply deletion of X from database.
This is in agreement with association relation that collection membership
implies. However, OpenJPA does provide @Dependent/@ElementDependent
annotations to mean ownership of B by A. Annotating uni-cardinality or
multi-cardinality relation with @Dependent or @ElementDependent will cause
deletion from database when the relationship is severed/nullified in memory.
In JPA 2.0, this behavior is being specified under @OrphanRemoval annotation
or an equivalent cascade type.

If it is (b) then the record should be deleted from database. 

 

Jitendra chintamadaka wrote:
> 
> Ok, section 3.2.3 in JSR 220, does explain. 
> 
> Assuming that cascade attribute does not have any effect (as its not
> mentioned in that section). This then is an issue with the JPA
> specification itself. As introducing unwanted DB changes cannot be
> prevented with a annotation. May be I should open a issue or
> recommendation for JPA Specification itself.
> 
> Regards
> 
> 
> ----- Original Message ----
> From: Pinaki Poddar <ppoddar@apache.org>
> To: users@openjpa.apache.org
> Sent: Monday, July 7, 2008 8:04:03 PM
> Subject: Re: Able to remove relation with ManyToMany and no cascade.
> 
> 
> Hi,
> 
>> I have looked up the JSR 220 and did not find any specific mention on
>> this
>> scenario. This seems like a 
>> bug in the implementation. Please let me know if this really is a bug, so
>> I can submit a bug report.
> 
> JSR-220 Section 3.2.3 "Synchronization to the Database" pp 44 says:
> "Bidirectional relationships between managed entities will be persisted
> based on references held by the owning side of the relationship"
> 
> The scenario you have described can be explained and not attributed as a
> limitation of implementation by the above.
> 
> 
> -- 
> View this message in context:
> http://n2.nabble.com/Able-to-remove-relation-with-ManyToMany-and-no-cascade.-tp221593p363223.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
> 
> 
>       
> 

-- 
View this message in context: http://n2.nabble.com/Able-to-remove-relation-with-ManyToMany-and-no-cascade.-tp221593p471622.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Mime
View raw message