openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jitendra chintamadaka <cj...@yahoo.com>
Subject Re: Able to remove relation with ManyToMany and no cascade.
Date Thu, 10 Jul 2008 07:16:04 GMT
Hello,

> What exactly does 'remove' imply?  Is it something like:

> a) team.getStudents().remove(1);
> or
> b) em.remove(team.getStudents().get(1));

I meant (a). And with just JPA annotation specifications, the remove of entity from a java
collection (on owning side) does imply removal of the associated record from the JoinTable
(for ManyToMany).

>From my Scenario 1 (Using owner of relationship "student") :
student.getTeamCollection().remove(0);
entityTransaction.commit();
// The record from COLLEGE table related to this student entity PK and the team entity PK
removed above, will be deleted.

NOTE: This scenario 1, I think is not an expected behavior and can introduce un-expected programming
bugs.

>From my Scenario 2 (Using inverse of relationship "team") :
team.getStudentList().remove(0);
entityTransaction.commit();
// The record from COLLEGE table related to this team entity PK and the student entity PK
remove above, will not be deleted.

NOTE: This scenario 2, behavior is explained by 3.2.3 of JPA specification. So, no questions
here.

Regarding JPA 2.0, I have not yet reviewed the @OrphanRemoval annotation to comment yet. Will
verify that and confirm if its really addressing this issue.

Thanks.

Regards,
Jitendra.



      
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message