aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Curtis2014-06-26 13:59:32 (EDT)
committertware2014-07-04 09:47:46 (EDT)
commitf7cdcba0bbdc84297596eac55731d03997b4c631 (patch)
treed353c3daf0e057c3723be103c4db6fd1ebd773f7
parentf346f5b0a24284b102e659a90088df176e029bb0 (diff)
downloadeclipselink.runtime-f7cdcba0bbdc84297596eac55731d03997b4c631.zip
eclipselink.runtime-f7cdcba0bbdc84297596eac55731d03997b4c631.tar.gz
eclipselink.runtime-f7cdcba0bbdc84297596eac55731d03997b4c631.tar.bz2
Fix for bug 438177. Support using @JoinTable annotation on a M2M map.
Signed-off-by: Rick Curtis <curtisr7@gmail.com>
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/descriptors/ClassDescriptor.java6
-rw-r--r--jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/relationships/MtoMEntityA.java84
-rw-r--r--jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/relationships/MtoMEntityB.java51
-rw-r--r--jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/relationships/RelationshipsTableManager.java148
-rw-r--r--jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/FullRegressionTestSuite.java6
-rw-r--r--jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/relationships/TestKeyTypeToManyRelationship.java133
6 files changed, 425 insertions, 3 deletions
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/descriptors/ClassDescriptor.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/descriptors/ClassDescriptor.java
index d0f89dc..50a18a2 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/descriptors/ClassDescriptor.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/descriptors/ClassDescriptor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 1998, 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014 Oracle and/or its affiliates, IBM Corporation. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -30,6 +30,8 @@
* - 354678: Temp classloader is still being used during metadata processing
* 09 Jan 2013-2.5 Gordon Yorke
* - 397772: JPA 2.1 Entity Graph Support
+ * 06/25/2014-2.5.2 Rick Curtis
+ * - 438177: Support M2M map with jointable
******************************************************************************/
package org.eclipse.persistence.descriptors;
@@ -867,6 +869,8 @@ public class ClassDescriptor extends CoreDescriptor<AttributeGroup, DescriptorEv
DatabaseTable table;
if (relationTable != null && field.hasTableName() && field.getTableName().equals(relationTable.getName())){
table = relationTable;
+ } else if (relationTable != null && !field.hasTableName()) {
+ table = relationTable;
} else if (field.hasTableName()) {
table = getTable(field.getTableName());
} else {
diff --git a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/relationships/MtoMEntityA.java b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/relationships/MtoMEntityA.java
new file mode 100644
index 0000000..b8b938b
--- /dev/null
+++ b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/relationships/MtoMEntityA.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2014 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 06/25/2014-2.5.2 Rick Curtis
+ * - 438177: Test M2M map
+ *******************************************************************************/
+package org.eclipse.persistence.testing.models.jpa.relationships;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.persistence.Cacheable;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.persistence.MapKeyClass;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="MTOMENTITYA")
+@Cacheable(false)
+public class MtoMEntityA {
+ @Id
+ private int id;
+
+ private String name;
+
+ @ManyToMany
+ @JoinTable(name = "MM_MNMK_JT")
+ private Map<Integer, MtoMEntityB> entityB;
+
+ @ManyToMany
+ private Map<Integer, MtoMEntityB> entityBDefault;
+
+ public MtoMEntityA() {
+ entityB = new HashMap<Integer, MtoMEntityB>();
+ entityBDefault = new HashMap<Integer, MtoMEntityB>();
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Map<Integer, MtoMEntityB> getEntityB() {
+ return entityB;
+ }
+
+ public void setEntityB(Map<Integer, MtoMEntityB> entityB) {
+ this.entityB = entityB;
+ }
+
+
+
+ public Map<Integer, MtoMEntityB> getEntityBDefault() {
+ return entityBDefault;
+ }
+
+ public void setEntityBDefault(Map<Integer, MtoMEntityB> entityBDefault) {
+ this.entityBDefault = entityBDefault;
+ }
+
+ @Override
+ public String toString() {
+ return "MtoMEntityA [id=" + id + ", name=" + name + ", entityB="
+ + entityB + "]";
+ }
+}
diff --git a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/relationships/MtoMEntityB.java b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/relationships/MtoMEntityB.java
new file mode 100644
index 0000000..3129dd3
--- /dev/null
+++ b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/relationships/MtoMEntityB.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2014 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 06/25/2014-2.5.2 Rick Curtis
+ * - 438177: Test M2M map
+ *******************************************************************************/
+package org.eclipse.persistence.testing.models.jpa.relationships;
+
+import javax.persistence.Cacheable;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="MTOMENTITYB")
+@Cacheable(false)
+public class MtoMEntityB {
+ @Id
+ private int id;
+
+ private String name;
+
+ public MtoMEntityB() {
+
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return "MtoMEntityB [id=" + id + ", name=" + name + "]";
+ }
+}
diff --git a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/relationships/RelationshipsTableManager.java b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/relationships/RelationshipsTableManager.java
index bf3eecc..df145e4 100644
--- a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/relationships/RelationshipsTableManager.java
+++ b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/relationships/RelationshipsTableManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 1998, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014 Oracle and/or its affiliates, IBM Corporation. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -13,6 +13,8 @@
* - 324471: Do not default to VariableOneToOneMapping for interfaces unless a managed class implementing it is found
* 01/25/2011-2.3 Guy Pelletier
* - 333488: Serializable attribute being defaulted to a variable one to one mapping and causing exception
+ * 06/25/2014-2.5.2 Rick Curtis
+ * - 438177: Test M2M map
******************************************************************************/
package org.eclipse.persistence.testing.models.jpa.relationships;
@@ -56,6 +58,12 @@ public class RelationshipsTableManager extends TogglingFastTableCreator {
addTableDefinition(buildServiceCallTable());
addTableDefinition(buildCustomerServiceRepTable());
addTableDefinition(buildCustRepTable());
+
+ addTableDefinition(buildMtoMEntityATable());
+ addTableDefinition(buildMtoMEntityBTable());
+ addTableDefinition(buildMtoMEntityJoinTable());
+ addTableDefinition(buildMtoMEntityDefaultJoinTable());
+
}
public static TableCreator getCreator(){
@@ -1011,5 +1019,143 @@ public class RelationshipsTableManager extends TogglingFastTableCreator {
return table;
}
+
+ public static TableDefinition buildMtoMEntityATable(){
+ TableDefinition table = new TableDefinition();
+ table.setName("MTOMENTITYA");
+
+ FieldDefinition field_ID = new FieldDefinition();
+ field_ID.setName("ID");
+ field_ID.setTypeName("NUMBER");
+ field_ID.setSize(15);
+ field_ID.setSubSize(0);
+ field_ID.setIsPrimaryKey(true);
+ field_ID.setIsIdentity(false);
+ field_ID.setUnique(false);
+ field_ID.setShouldAllowNull(false);
+ table.addField(field_ID);
+
+ FieldDefinition fieldNAME = new FieldDefinition();
+ fieldNAME.setName("NAME");
+ fieldNAME.setTypeName("VARCHAR2");
+ fieldNAME.setSize(80);
+ fieldNAME.setSubSize(0);
+ fieldNAME.setIsPrimaryKey(false);
+ fieldNAME.setIsIdentity(false);
+ fieldNAME.setUnique(false);
+ fieldNAME.setShouldAllowNull(true);
+ table.addField(fieldNAME);
+
+ return table;
+ }
+
+ public static TableDefinition buildMtoMEntityBTable(){
+ TableDefinition table = new TableDefinition();
+ table.setName("MTOMENTITYB");
+
+ FieldDefinition field_ID = new FieldDefinition();
+ field_ID.setName("ID");
+ field_ID.setTypeName("NUMBER");
+ field_ID.setSize(15);
+ field_ID.setSubSize(0);
+ field_ID.setIsPrimaryKey(true);
+ field_ID.setIsIdentity(false);
+ field_ID.setUnique(false);
+ field_ID.setShouldAllowNull(false);
+ table.addField(field_ID);
+
+ FieldDefinition fieldNAME = new FieldDefinition();
+ fieldNAME.setName("NAME");
+ fieldNAME.setTypeName("VARCHAR2");
+ fieldNAME.setSize(80);
+ fieldNAME.setSubSize(0);
+ fieldNAME.setIsPrimaryKey(false);
+ fieldNAME.setIsIdentity(false);
+ fieldNAME.setUnique(false);
+ fieldNAME.setShouldAllowNull(true);
+ table.addField(fieldNAME);
+
+ return table;
+ }
+
+ public static TableDefinition buildMtoMEntityJoinTable(){
+ TableDefinition table = new TableDefinition();
+ table.setName("MM_MNMK_JT");
+
+ FieldDefinition fieldMtoMEntityA_ID = new FieldDefinition();
+ fieldMtoMEntityA_ID.setName("MtoMEntityA_ID");
+ fieldMtoMEntityA_ID.setTypeName("NUMBER");
+ fieldMtoMEntityA_ID.setSize(15);
+ fieldMtoMEntityA_ID.setSubSize(0);
+ fieldMtoMEntityA_ID.setIsPrimaryKey(true);
+ fieldMtoMEntityA_ID.setIsIdentity(false);
+ fieldMtoMEntityA_ID.setUnique(false);
+ fieldMtoMEntityA_ID.setShouldAllowNull(false);
+ table.addField(fieldMtoMEntityA_ID);
+
+ FieldDefinition fieldMtoMEntityB_ID = new FieldDefinition();
+ fieldMtoMEntityB_ID.setName("entityB_ID");
+ fieldMtoMEntityB_ID.setTypeName("NUMBER");
+ fieldMtoMEntityB_ID.setSize(15);
+ fieldMtoMEntityB_ID.setSubSize(0);
+ fieldMtoMEntityB_ID.setIsPrimaryKey(true);
+ fieldMtoMEntityB_ID.setIsIdentity(false);
+ fieldMtoMEntityB_ID.setUnique(false);
+ fieldMtoMEntityB_ID.setShouldAllowNull(false);
+ table.addField(fieldMtoMEntityB_ID);
+
+ FieldDefinition fieldMtoMEntityB_Key_ID = new FieldDefinition();
+ fieldMtoMEntityB_Key_ID.setName("EntityB_Key");
+ fieldMtoMEntityB_Key_ID.setTypeName("NUMBER");
+ fieldMtoMEntityB_Key_ID.setSize(15);
+ fieldMtoMEntityB_Key_ID.setSubSize(0);
+ fieldMtoMEntityB_Key_ID.setIsPrimaryKey(false);
+ fieldMtoMEntityB_Key_ID.setIsIdentity(false);
+ fieldMtoMEntityB_Key_ID.setUnique(false);
+ fieldMtoMEntityB_Key_ID.setShouldAllowNull(true);
+ table.addField(fieldMtoMEntityB_Key_ID);
+
+ return table;
+ }
+
+ public static TableDefinition buildMtoMEntityDefaultJoinTable(){
+ TableDefinition table = new TableDefinition();
+ table.setName("MTOMENTITYA_MTOMENTITYB");
+
+ FieldDefinition fieldMtoMEntityA_ID = new FieldDefinition();
+ fieldMtoMEntityA_ID.setName("MtoMEntityA_ID");
+ fieldMtoMEntityA_ID.setTypeName("NUMBER");
+ fieldMtoMEntityA_ID.setSize(15);
+ fieldMtoMEntityA_ID.setSubSize(0);
+ fieldMtoMEntityA_ID.setIsPrimaryKey(true);
+ fieldMtoMEntityA_ID.setIsIdentity(false);
+ fieldMtoMEntityA_ID.setUnique(false);
+ fieldMtoMEntityA_ID.setShouldAllowNull(false);
+ table.addField(fieldMtoMEntityA_ID);
+
+ FieldDefinition fieldMtoMEntityB_ID = new FieldDefinition();
+ fieldMtoMEntityB_ID.setName("entityBDefault_ID");
+ fieldMtoMEntityB_ID.setTypeName("NUMBER");
+ fieldMtoMEntityB_ID.setSize(15);
+ fieldMtoMEntityB_ID.setSubSize(0);
+ fieldMtoMEntityB_ID.setIsPrimaryKey(true);
+ fieldMtoMEntityB_ID.setIsIdentity(false);
+ fieldMtoMEntityB_ID.setUnique(false);
+ fieldMtoMEntityB_ID.setShouldAllowNull(false);
+ table.addField(fieldMtoMEntityB_ID);
+
+ FieldDefinition fieldMtoMEntityB_Key_ID = new FieldDefinition();
+ fieldMtoMEntityB_Key_ID.setName("entityBDefault_Key");
+ fieldMtoMEntityB_Key_ID.setTypeName("NUMBER");
+ fieldMtoMEntityB_Key_ID.setSize(15);
+ fieldMtoMEntityB_Key_ID.setSubSize(0);
+ fieldMtoMEntityB_Key_ID.setIsPrimaryKey(false);
+ fieldMtoMEntityB_Key_ID.setIsIdentity(false);
+ fieldMtoMEntityB_Key_ID.setUnique(false);
+ fieldMtoMEntityB_Key_ID.setShouldAllowNull(true);
+ table.addField(fieldMtoMEntityB_Key_ID);
+
+ return table;
+ }
}
diff --git a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/FullRegressionTestSuite.java b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/FullRegressionTestSuite.java
index b6e8b08..0386dff 100644
--- a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/FullRegressionTestSuite.java
+++ b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/FullRegressionTestSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 1998, 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014 Oracle and/or its affiliates, IBM Corporation. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -15,6 +15,8 @@
* - 211322: Add fetch-group(s) support to the EclipseLink-ORM.XML Schema
* 03/23/2011-2.3 Guy Pelletier
* - 337323: Multi-tenant with shared schema support (part 1)
+ * 06/25/2014-2.5.2 Rick Curtis
+ * - 438177: Test M2M map
******************************************************************************/
package org.eclipse.persistence.testing.tests.jpa;
@@ -102,6 +104,7 @@ import org.eclipse.persistence.testing.tests.jpa.relationships.IsolatedCacheTest
import org.eclipse.persistence.testing.tests.jpa.relationships.RelationshipModelJUnitTestSuite;
import org.eclipse.persistence.testing.tests.jpa.relationships.UniAndBiDirectionalMappingTestSuite;
import org.eclipse.persistence.testing.tests.jpa.relationships.VirtualAttributeTestSuite;
+import org.eclipse.persistence.testing.tests.jpa.relationships.TestKeyTypeToManyRelationship;
import org.eclipse.persistence.testing.tests.jpa.validation.QueryParameterValidationTestSuite;
import org.eclipse.persistence.testing.tests.jpa.validation.ValidationTestSuite;
import org.eclipse.persistence.testing.tests.jpa.xml.EntityMappingsJUnitTestSuite;
@@ -212,6 +215,7 @@ public class FullRegressionTestSuite extends TestSuite {
suite.addTest(QueryParameterValidationTestSuite.suite());
suite.addTest(UniAndBiDirectionalMappingTestSuite.suite());
suite.addTest(RelationshipModelJUnitTestSuite.suite());
+ suite.addTest(TestKeyTypeToManyRelationship.suite());
fullSuite.addTest(suite);
// JPQL testing model.
diff --git a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/relationships/TestKeyTypeToManyRelationship.java b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/relationships/TestKeyTypeToManyRelationship.java
new file mode 100644
index 0000000..44b96d7
--- /dev/null
+++ b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/relationships/TestKeyTypeToManyRelationship.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 2014 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 06/25/2014-2.5.2 Rick Curtis
+ * - 438177: Test M2M map
+ *******************************************************************************/
+package org.eclipse.persistence.testing.tests.jpa.relationships;
+
+import java.util.HashMap;
+
+import javax.persistence.EntityManager;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.persistence.internal.jpa.EntityManagerImpl;
+import org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork;
+import org.eclipse.persistence.testing.framework.junit.JUnitTestCase;
+import org.eclipse.persistence.testing.models.jpa.relationships.MtoMEntityA;
+import org.eclipse.persistence.testing.models.jpa.relationships.MtoMEntityB;
+import org.eclipse.persistence.testing.models.jpa.relationships.RelationshipsTableManager;
+
+public class TestKeyTypeToManyRelationship extends JUnitTestCase{
+
+ public TestKeyTypeToManyRelationship() {
+
+ }
+
+ public TestKeyTypeToManyRelationship(String name) {
+ super(name);
+ }
+
+ public void testSetup () {
+ new RelationshipsTableManager().replaceTables(JUnitTestCase.getServerSession());
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ suite.setName("TestKeyTypeToManyRelationship");
+
+ suite.addTest(new TestKeyTypeToManyRelationship("testSetup"));
+ suite.addTest(new TestKeyTypeToManyRelationship("testManyToManyMapTypeWithDefaultKey"));
+ suite.addTest(new TestKeyTypeToManyRelationship("testManyToManyMapTypeWithDefaultJointTable"));
+
+ return suite;
+ }
+
+ public void testManyToManyMapTypeWithDefaultJointTable() throws Exception {
+ HashMap<String, String> emProps = new HashMap<String, String>();
+ emProps.put("eclipselink.cache.shared.default", "false");
+
+ EntityManager em = createEntityManager(emProps);
+
+ beginTransaction(em);
+ try {
+ MtoMEntityA entityA = new MtoMEntityA();
+ entityA.setId(2);
+ entityA.setName("Entity A");
+ em.persist(entityA);
+
+ MtoMEntityB entityB = new MtoMEntityB();
+ entityB.setId(2);
+ entityB.setName("Entity B");
+ em.persist(entityB);
+
+ entityA.getEntityBDefault().put(2, entityB);
+
+ commitTransaction(em);
+
+ beginTransaction(em);
+
+ em.clear();
+
+ MtoMEntityA entityA_find = em.find(MtoMEntityA.class, 2);
+ assertNotSame(entityA, entityA_find);
+ assertNotNull(entityA_find);
+ assertNotNull(entityA_find.getEntityBDefault());
+ assertEquals(1, entityA_find.getEntityBDefault().size());
+
+ commitTransaction(em);
+ } finally {
+ if (isTransactionActive(em)) {
+ rollbackTransaction(em);
+ }
+ closeEntityManager(em);
+ }
+ }
+
+ public void testManyToManyMapTypeWithDefaultKey() throws Exception {
+ HashMap<String, String> emProps = new HashMap<String, String>();
+ emProps.put("eclipselink.cache.shared.default", "false");
+
+ EntityManager em = createEntityManager(emProps);
+
+ beginTransaction(em);
+ try {
+ MtoMEntityA entityA = new MtoMEntityA();
+ entityA.setId(1);
+ entityA.setName("Entity A");
+ em.persist(entityA);
+
+ MtoMEntityB entityB = new MtoMEntityB();
+ entityB.setId(1);
+ entityB.setName("Entity B");
+ em.persist(entityB);
+
+ entityA.getEntityB().put(1, entityB);
+
+ commitTransaction(em);
+
+ beginTransaction(em);
+
+ em.clear();
+
+ MtoMEntityA entityA_find = em.find(MtoMEntityA.class, 1);
+ assertNotSame(entityA, entityA_find);
+ assertNotNull(entityA_find);
+ assertNotNull(entityA_find.getEntityB());
+ assertEquals(1, entityA_find.getEntityB().size());
+
+ commitTransaction(em);
+ } finally {
+ if (isTransactionActive(em)) {
+ rollbackTransaction(em);
+ }
+ closeEntityManager(em);
+ }
+ }
+}