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.