From ffb59c35fcd7b8d6adf658bc794bcaff465ced32 Mon Sep 17 00:00:00 2001 From: Pinaki Poddar Date: Mon, 11 Aug 2008 17:18:31 +0000 Subject: [PATCH] OPENJPA-692: Detect orphaning relation and change row update to delete for join table entry. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@684822 13f79535-47bb-0310-9956-ffa450edef68 --- .../openjpa/jdbc/meta/FieldMapping.java | 53 +++++++++++++++++-- .../meta/strats/RelationFieldStrategy.java | 5 +- .../bidi/TestBiDirectionalJoinTable.java | 15 ++++++ 3 files changed, 69 insertions(+), 4 deletions(-) diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMapping.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMapping.java index 72095a826..3a532f77f 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMapping.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMapping.java @@ -73,6 +73,7 @@ public class FieldMapping private int _fetchMode = Integer.MAX_VALUE; private Unique[] _joinTableUniques; // Unique constraints on JoinTable private Boolean _bidirectionalJoinTableOwner = null; + private Boolean _bidirectionalJoinTableNonOwner = null; /** * Constructor. @@ -1075,10 +1076,10 @@ public class FieldMapping ClassMapping relType = elem.getDeclaredTypeMapping(); if (relType == null) return false; - FieldMetaData[] relFmds = relType.getFields(); + FieldMapping[] relFmds = relType.getFieldMappings(); for (int i=0; i addresses = person.getAddresses(); + assertFalse(addresses.isEmpty()); + Address address = addresses.iterator().next(); + addresses.remove(address); + address.setPerson(null); + em.getTransaction().commit(); + + assertSQL("DELETE FROM .*J_PERSON_ADDRESSES .*"); + } /** * Create a Person with given SSN and fixed number of addresses.