================================================================================ Merge Diffs: /ade/gpelleti_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/accessors/CollectionAccessor.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.5 Report generated at Fri Sep 29 11:17:40 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.5 Wed Sep 27 08:51:24 2006 --- /ade/gpelleti_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/accessors/CollectionAccessor.java Fri Sep 29 11:17:34 2006 *************** *** 222,229 **** // Add all the joinColumns (source foreign keys) to the mapping. String defaultSourceFieldName; ! if (getReferenceDescriptor().hasManyToManyAccessorFor(getJavaClassName())) { ! defaultSourceFieldName = getReferenceDescriptor().getManyToManyAccessor(getJavaClassName()).getAttributeName(); } else { defaultSourceFieldName = Helper.getShortClassName(getJavaClass().getName()); } --- 222,229 ---- // Add all the joinColumns (source foreign keys) to the mapping. String defaultSourceFieldName; ! if (getReferenceDescriptor().hasBiDirectionalManyToManyAccessorFor(getJavaClassName(), getAttributeName())) { ! defaultSourceFieldName = getReferenceDescriptor().getBiDirectionalManyToManyAccessor(getJavaClassName(), getAttributeName()).getAttributeName(); } else { defaultSourceFieldName = Helper.getShortClassName(getJavaClass().getName()); } ================================================================================ Merge Diffs: /ade/gpelleti_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/MetadataDescriptor.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.43 Report generated at Fri Sep 29 11:17:40 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.43 Wed Sep 27 08:51:48 2006 --- /ade/gpelleti_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/MetadataDescriptor.java Fri Sep 29 11:17:34 2006 *************** *** 89,96 **** protected Map m_accessors; protected Map m_attributeOverrides; protected Map m_associationOverrides; ! protected Map m_manyToManyAccessors; protected Map m_relationshipAccessors; /** * INTERNAL: --- 89,97 ---- protected Map m_accessors; protected Map m_attributeOverrides; protected Map m_associationOverrides; ! protected Map m_relationshipAccessors; + protected Map> m_biDirectionalManyToManyAccessors; /** * INTERNAL: *************** *** 113,122 **** m_relationshipAccessors.put(accessor.getAttributeName(), (RelationshipAccessor) accessor); } ! // Store ManyToMany relationships so that we may look at attribute ! // names when defaulting join columns for bi and uni directional M-M's. if (accessor.isManyToMany()) { ! m_manyToManyAccessors.put(accessor.getReferenceClassName(), accessor); } } --- 114,134 ---- m_relationshipAccessors.put(accessor.getAttributeName(), (RelationshipAccessor) accessor); } ! // Store bidirectional ManyToMany relationships so that we may look at ! // attribute names when defaulting join columns. if (accessor.isManyToMany()) { ! String mappedBy = ((RelationshipAccessor) accessor).getMappedBy(); ! ! if (! mappedBy.equals("")) { ! String referenceClassName = accessor.getReferenceClassName(); ! ! // Initialize the map of bi-directional mappings for this class. ! if (! m_biDirectionalManyToManyAccessors.containsKey(referenceClassName)) { ! m_biDirectionalManyToManyAccessors.put(referenceClassName, new HashMap()); ! } ! ! m_biDirectionalManyToManyAccessors.get(referenceClassName).put(mappedBy, accessor); ! } } } *************** *** 389,397 **** /** * INTERNAL: */ ! public MetadataAccessor getManyToManyAccessor(String className) { ! return m_manyToManyAccessors.get(className); } /** --- 401,411 ---- /** * INTERNAL: + * Assumes hasBidirectionalManyToManyAccessorFor has been called before + * hand. */ ! public MetadataAccessor getBiDirectionalManyToManyAccessor(String className, String attributeName) { ! return m_biDirectionalManyToManyAccessors.get(className).get(attributeName); } /** *************** *** 585,592 **** /** * INTERNAL: */ ! public boolean hasManyToManyAccessorFor(String className) { ! return m_manyToManyAccessors.containsKey(className); } /** --- 599,610 ---- /** * INTERNAL: */ ! public boolean hasBiDirectionalManyToManyAccessorFor(String className, String attributeName) { ! if (m_biDirectionalManyToManyAccessors.containsKey(className)) { ! return m_biDirectionalManyToManyAccessors.get(className).containsKey(attributeName); ! } ! ! return false; } /** *************** *** 647,655 **** m_pkClassIDs = new HashMap(); m_accessors = new HashMap(); m_attributeOverrides = new HashMap(); - m_manyToManyAccessors = new HashMap(); m_associationOverrides = new HashMap(); m_relationshipAccessors = new HashMap(); } /** --- 665,674 ---- m_pkClassIDs = new HashMap(); m_accessors = new HashMap(); m_attributeOverrides = new HashMap(); m_associationOverrides = new HashMap(); + m_relationshipAccessors = new HashMap(); + m_biDirectionalManyToManyAccessors = new HashMap>(); } /** ================================================================================ Merge Diffs: /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/relationships/Customer.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.9 Report generated at Fri Sep 29 11:17:40 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.9 Wed Sep 27 11:19:21 2006 --- /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/relationships/Customer.java Fri Sep 29 11:17:34 2006 *************** *** 21,26 **** --- 21,27 ---- // Copyright (c) 1998, 2006, Oracle. All rights reserved. package oracle.toplink.essentials.testing.models.cmp3.relationships; + import java.util.Vector; import java.util.HashSet; import java.util.Collection; import javax.persistence.*; *************** *** 46,51 **** --- 47,53 ---- private String city; private String name; private Collection orders = new HashSet(); + private Collection controlledCustomers = new HashSet(); public Customer() {} *************** *** 110,113 **** --- 112,133 ---- public void removeOrder(Order anOrder) { getOrders().remove(anOrder); } + + @ManyToMany + @JoinTable(name="CMP3_CUSTOMER_CUSTOMER") + public Collection getCCustomers() { + if (controlledCustomers == null) { + return new Vector(); + } + + return controlledCustomers; + } + + public void setCCustomers(Collection controlledCustomers) { + this.controlledCustomers = controlledCustomers; + } + + public void addCCustomer(Customer controlledCustomer) { + getCCustomers().add(controlledCustomer); + } } ================================================================================ Merge Diffs: /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/relationships/RelationshipsTableManager.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.7 Report generated at Fri Sep 29 11:17:41 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.7 Wed Sep 27 11:19:41 2006 --- /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/relationships/RelationshipsTableManager.java Fri Sep 29 11:17:34 2006 *************** *** 37,42 **** --- 37,43 ---- addTableDefinition(buildCMP3_ORDERTable()); addTableDefinition(buildCMP3_ORDER_SEQTable()); addTableDefinition(buildCMP3_SALESPERSONTable()); + addTableDefinition(buildCUSTOMER_CUSTOMERTable()); } public static TableCreator getCreator(){ *************** *** 337,340 **** --- 338,373 ---- return table; } + + public static TableDefinition buildCUSTOMER_CUSTOMERTable() { + TableDefinition table = new TableDefinition(); + + table.setName("CMP3_CUSTOMER_CUSTOMER"); + + // SECTION: FIELD + FieldDefinition field = new FieldDefinition(); + field.setName("CUSTOMER_CUST_ID"); + field.setTypeName("NUMERIC"); + field.setSize(15); + field.setShouldAllowNull(false); + field.setIsPrimaryKey(true); + field.setUnique(false); + field.setIsIdentity(false); + field.setForeignKeyFieldName("CMP3_CUSTOMER.CUST_ID"); + table.addField(field); + + // SECTION: FIELD + FieldDefinition field1 = new FieldDefinition(); + field1.setName("CCUSTOMERS_CUST_ID"); + field1.setTypeName("NUMERIC"); + field1.setSize(15); + field1.setShouldAllowNull(false); + field1.setIsPrimaryKey(true); + field1.setUnique(false); + field1.setIsIdentity(false); + field1.setForeignKeyFieldName("CMP3_CUSTOMER.CUST_ID"); + table.addField(field1); + + return table; + } } ================================================================================ Merge Diffs: /ade/gpelleti_main/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/relationships/CMP3RelationshipsTestModel.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000005/AB0952363AC40CBFE034080020E8C54E.8 Report generated at Fri Sep 29 11:17:41 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000005/AB0952363AC40CBFE034080020E8C54E.8 Fri Sep 29 11:17:13 2006 --- /ade/gpelleti_main/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/relationships/CMP3RelationshipsTestModel.java Fri Sep 29 11:17:40 2006 *************** *** 24,29 **** addTest(new GetResultListTest()); addTest(new NamedQueryDoesNotExistTest()); addTest(new NamedQueryWithArgumentsTest()); } - } --- 24,29 ---- addTest(new GetResultListTest()); addTest(new NamedQueryDoesNotExistTest()); addTest(new NamedQueryWithArgumentsTest()); + addTests(JUnitTestCase.suite(UniAndBiDirectionalMappingTestSuite.class)); } } ================================================================================ Merge Diffs: /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/relationships/UniAndBiDirectionalMappingTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Sep 29 11:17:41 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.0 Fri Sep 29 11:17:17 2006 --- /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/relationships/UniAndBiDirectionalMappingTestSuite.java Fri Sep 29 11:17:17 2006 *************** *** 0 **** --- 1,105 ---- + /* + * The contents of this file are subject to the terms + * of the Common Development and Distribution License + * (the "License"). You may not use this file except + * in compliance with the License. + * + * You can obtain a copy of the license at + * glassfish/bootstrap/legal/CDDLv1.0.txt or + * https://glassfish.dev.java.net/public/CDDLv1.0.html. + * See the License for the specific language governing + * permissions and limitations under the License. + * + * When distributing Covered Code, include this CDDL + * HEADER in each file and include the License file at + * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable, + * add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your + * own identifying information: Portions Copyright [yyyy] + * [name of copyright owner] + */ + // Copyright (c) 1998, 2006, Oracle. All rights reserved. + package oracle.toplink.essentials.testing.tests.cmp3.relationships; + + import junit.framework.*; + import junit.extensions.TestSetup; + + import javax.persistence.*; + + import oracle.toplink.essentials.sessions.DatabaseSession; + import oracle.toplink.essentials.testing.models.cmp3.relationships.*; + import oracle.toplink.essentials.testing.framework.junit.JUnitTestCase; + import oracle.toplink.essentials.testing.models.cmp3.relationships.Customer; + + public class UniAndBiDirectionalMappingTestSuite extends JUnitTestCase { + public UniAndBiDirectionalMappingTestSuite() {} + + public UniAndBiDirectionalMappingTestSuite(String name) { + super(name); + } + + public void setUp () { + super.setUp(); + new RelationshipsTableManager().replaceTables(JUnitTestCase.getServerSession()); + } + + public static Test suite() { + TestSuite suite = new TestSuite(); + suite.setName("UniAndBiDirectionalMappingTestSuite"); + suite.addTest(new UniAndBiDirectionalMappingTestSuite("selfReferencingManyToManyTest")); + + return new TestSetup(suite) { + + protected void setUp() { + DatabaseSession session = JUnitTestCase.getServerSession(); + new RelationshipsTableManager().replaceTables(JUnitTestCase.getServerSession()); + } + + protected void tearDown() { + clearCache(); + } + }; + } + + public void selfReferencingManyToManyTest() throws Exception { + EntityManager em = createEntityManager(); + + em.getTransaction().begin(); + + Customer owen = new Customer(); + owen.setName("Owen Pelletier"); + owen.setCity("Ottawa"); + em.persist(owen); + int owenId = owen.getCustomerId(); + + Customer kirty = new Customer(); + kirty.setName("Kirsten Pelletier"); + kirty.setCity("Ottawa"); + kirty.addCCustomer(owen); + em.persist(kirty); + int kirtyId = kirty.getCustomerId(); + + Customer guy = new Customer(); + guy.setName("Guy Pelletier"); + guy.setCity("Ottawa"); + guy.addCCustomer(owen); + guy.addCCustomer(kirty); + kirty.addCCustomer(guy); // guess I'll allow this one ... ;-) + em.persist(guy); + int guyId = guy.getCustomerId(); + + em.getTransaction().commit(); + + clearCache(); + + Customer newOwen = em.find(Customer.class, owenId); + Customer newKirty = em.find(Customer.class, kirtyId); + Customer newGuy = em.find(Customer.class, guyId); + + assertTrue("Owen has controlled customers .", newOwen.getCCustomers().isEmpty()); + assertFalse("Kirty did not have any controlled customers.", newKirty.getCCustomers().isEmpty()); + assertFalse("Guy did not have any controlled customers.", newGuy.getCCustomers().isEmpty()); + + em.close(); + } + } \ No newline at end of file ================================================================================ Merge Diffs: /ade/gpelleti_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/accessors/CollectionAccessor.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.5 Report generated at Fri Sep 29 11:46:49 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.5 Wed Sep 27 08:51:24 2006 --- /ade/gpelleti_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/accessors/CollectionAccessor.java Fri Sep 29 11:46:49 2006 *************** *** 222,229 **** // Add all the joinColumns (source foreign keys) to the mapping. String defaultSourceFieldName; ! if (getReferenceDescriptor().hasManyToManyAccessorFor(getJavaClassName())) { ! defaultSourceFieldName = getReferenceDescriptor().getManyToManyAccessor(getJavaClassName()).getAttributeName(); } else { defaultSourceFieldName = Helper.getShortClassName(getJavaClass().getName()); } --- 222,229 ---- // Add all the joinColumns (source foreign keys) to the mapping. String defaultSourceFieldName; ! if (getReferenceDescriptor().hasBiDirectionalManyToManyAccessorFor(getJavaClassName(), getAttributeName())) { ! defaultSourceFieldName = getReferenceDescriptor().getBiDirectionalManyToManyAccessor(getJavaClassName(), getAttributeName()).getAttributeName(); } else { defaultSourceFieldName = Helper.getShortClassName(getJavaClass().getName()); } ================================================================================ Merge Diffs: /ade/gpelleti_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/MetadataDescriptor.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.43 Report generated at Fri Sep 29 11:46:49 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.43 Wed Sep 27 08:51:48 2006 --- /ade/gpelleti_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/MetadataDescriptor.java Fri Sep 29 11:46:49 2006 *************** *** 89,96 **** protected Map m_accessors; protected Map m_attributeOverrides; protected Map m_associationOverrides; ! protected Map m_manyToManyAccessors; protected Map m_relationshipAccessors; /** * INTERNAL: --- 89,97 ---- protected Map m_accessors; protected Map m_attributeOverrides; protected Map m_associationOverrides; ! protected Map m_relationshipAccessors; + protected Map> m_biDirectionalManyToManyAccessors; /** * INTERNAL: *************** *** 113,122 **** m_relationshipAccessors.put(accessor.getAttributeName(), (RelationshipAccessor) accessor); } ! // Store ManyToMany relationships so that we may look at attribute ! // names when defaulting join columns for bi and uni directional M-M's. if (accessor.isManyToMany()) { ! m_manyToManyAccessors.put(accessor.getReferenceClassName(), accessor); } } --- 114,134 ---- m_relationshipAccessors.put(accessor.getAttributeName(), (RelationshipAccessor) accessor); } ! // Store bidirectional ManyToMany relationships so that we may look at ! // attribute names when defaulting join columns. if (accessor.isManyToMany()) { ! String mappedBy = ((RelationshipAccessor) accessor).getMappedBy(); ! ! if (! mappedBy.equals("")) { ! String referenceClassName = accessor.getReferenceClassName(); ! ! // Initialize the map of bi-directional mappings for this class. ! if (! m_biDirectionalManyToManyAccessors.containsKey(referenceClassName)) { ! m_biDirectionalManyToManyAccessors.put(referenceClassName, new HashMap()); ! } ! ! m_biDirectionalManyToManyAccessors.get(referenceClassName).put(mappedBy, accessor); ! } } } *************** *** 389,397 **** /** * INTERNAL: */ ! public MetadataAccessor getManyToManyAccessor(String className) { ! return m_manyToManyAccessors.get(className); } /** --- 401,411 ---- /** * INTERNAL: + * Assumes hasBidirectionalManyToManyAccessorFor has been called before + * hand. */ ! public MetadataAccessor getBiDirectionalManyToManyAccessor(String className, String attributeName) { ! return m_biDirectionalManyToManyAccessors.get(className).get(attributeName); } /** *************** *** 585,592 **** /** * INTERNAL: */ ! public boolean hasManyToManyAccessorFor(String className) { ! return m_manyToManyAccessors.containsKey(className); } /** --- 599,610 ---- /** * INTERNAL: */ ! public boolean hasBiDirectionalManyToManyAccessorFor(String className, String attributeName) { ! if (m_biDirectionalManyToManyAccessors.containsKey(className)) { ! return m_biDirectionalManyToManyAccessors.get(className).containsKey(attributeName); ! } ! ! return false; } /** *************** *** 647,655 **** m_pkClassIDs = new HashMap(); m_accessors = new HashMap(); m_attributeOverrides = new HashMap(); - m_manyToManyAccessors = new HashMap(); m_associationOverrides = new HashMap(); m_relationshipAccessors = new HashMap(); } /** --- 665,674 ---- m_pkClassIDs = new HashMap(); m_accessors = new HashMap(); m_attributeOverrides = new HashMap(); m_associationOverrides = new HashMap(); + m_relationshipAccessors = new HashMap(); + m_biDirectionalManyToManyAccessors = new HashMap>(); } /** ================================================================================ Merge Diffs: /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/relationships/Customer.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.9 Report generated at Fri Sep 29 11:46:49 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.9 Wed Sep 27 11:19:21 2006 --- /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/relationships/Customer.java Fri Sep 29 11:46:49 2006 *************** *** 21,26 **** --- 21,27 ---- // Copyright (c) 1998, 2006, Oracle. All rights reserved. package oracle.toplink.essentials.testing.models.cmp3.relationships; + import java.util.Vector; import java.util.HashSet; import java.util.Collection; import javax.persistence.*; *************** *** 46,51 **** --- 47,53 ---- private String city; private String name; private Collection orders = new HashSet(); + private Collection controlledCustomers = new HashSet(); public Customer() {} *************** *** 110,113 **** --- 112,133 ---- public void removeOrder(Order anOrder) { getOrders().remove(anOrder); } + + @ManyToMany + @JoinTable(name="CMP3_CUSTOMER_CUSTOMER") + public Collection getCCustomers() { + if (controlledCustomers == null) { + return new Vector(); + } + + return controlledCustomers; + } + + public void setCCustomers(Collection controlledCustomers) { + this.controlledCustomers = controlledCustomers; + } + + public void addCCustomer(Customer controlledCustomer) { + getCCustomers().add(controlledCustomer); + } } ================================================================================ Merge Diffs: /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/relationships/RelationshipsTableManager.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.7 Report generated at Fri Sep 29 11:46:49 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.7 Wed Sep 27 11:19:41 2006 --- /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/relationships/RelationshipsTableManager.java Fri Sep 29 11:46:49 2006 *************** *** 37,42 **** --- 37,43 ---- addTableDefinition(buildCMP3_ORDERTable()); addTableDefinition(buildCMP3_ORDER_SEQTable()); addTableDefinition(buildCMP3_SALESPERSONTable()); + addTableDefinition(buildCUSTOMER_CUSTOMERTable()); } public static TableCreator getCreator(){ *************** *** 337,340 **** --- 338,373 ---- return table; } + + public static TableDefinition buildCUSTOMER_CUSTOMERTable() { + TableDefinition table = new TableDefinition(); + + table.setName("CMP3_CUSTOMER_CUSTOMER"); + + // SECTION: FIELD + FieldDefinition field = new FieldDefinition(); + field.setName("CUSTOMER_CUST_ID"); + field.setTypeName("NUMERIC"); + field.setSize(15); + field.setShouldAllowNull(false); + field.setIsPrimaryKey(true); + field.setUnique(false); + field.setIsIdentity(false); + field.setForeignKeyFieldName("CMP3_CUSTOMER.CUST_ID"); + table.addField(field); + + // SECTION: FIELD + FieldDefinition field1 = new FieldDefinition(); + field1.setName("CCUSTOMERS_CUST_ID"); + field1.setTypeName("NUMERIC"); + field1.setSize(15); + field1.setShouldAllowNull(false); + field1.setIsPrimaryKey(true); + field1.setUnique(false); + field1.setIsIdentity(false); + field1.setForeignKeyFieldName("CMP3_CUSTOMER.CUST_ID"); + table.addField(field1); + + return table; + } } ================================================================================ Merge Diffs: /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/relationships/UniAndBiDirectionalMappingTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Sep 29 11:46:49 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.0 Fri Sep 29 11:17:17 2006 --- /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/relationships/UniAndBiDirectionalMappingTestSuite.java Fri Sep 29 11:45:06 2006 *************** *** 0 **** --- 1,105 ---- + /* + * The contents of this file are subject to the terms + * of the Common Development and Distribution License + * (the "License"). You may not use this file except + * in compliance with the License. + * + * You can obtain a copy of the license at + * glassfish/bootstrap/legal/CDDLv1.0.txt or + * https://glassfish.dev.java.net/public/CDDLv1.0.html. + * See the License for the specific language governing + * permissions and limitations under the License. + * + * When distributing Covered Code, include this CDDL + * HEADER in each file and include the License file at + * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable, + * add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your + * own identifying information: Portions Copyright [yyyy] + * [name of copyright owner] + */ + // Copyright (c) 1998, 2006, Oracle. All rights reserved. + package oracle.toplink.essentials.testing.tests.cmp3.relationships; + + import junit.framework.*; + import junit.extensions.TestSetup; + + import javax.persistence.*; + + import oracle.toplink.essentials.sessions.DatabaseSession; + import oracle.toplink.essentials.testing.models.cmp3.relationships.*; + import oracle.toplink.essentials.testing.framework.junit.JUnitTestCase; + import oracle.toplink.essentials.testing.models.cmp3.relationships.Customer; + + public class UniAndBiDirectionalMappingTestSuite extends JUnitTestCase { + public UniAndBiDirectionalMappingTestSuite() {} + + public UniAndBiDirectionalMappingTestSuite(String name) { + super(name); + } + + public void setUp () { + super.setUp(); + new RelationshipsTableManager().replaceTables(JUnitTestCase.getServerSession()); + } + + public static Test suite() { + TestSuite suite = new TestSuite(); + suite.setName("UniAndBiDirectionalMappingTestSuite"); + suite.addTest(new UniAndBiDirectionalMappingTestSuite("selfReferencingManyToManyTest")); + + return new TestSetup(suite) { + + protected void setUp() { + DatabaseSession session = JUnitTestCase.getServerSession(); + new RelationshipsTableManager().replaceTables(JUnitTestCase.getServerSession()); + } + + protected void tearDown() { + clearCache(); + } + }; + } + + public void selfReferencingManyToManyTest() throws Exception { + EntityManager em = createEntityManager(); + + em.getTransaction().begin(); + + Customer owen = new Customer(); + owen.setName("Owen Pelletier"); + owen.setCity("Ottawa"); + em.persist(owen); + int owenId = owen.getCustomerId(); + + Customer kirty = new Customer(); + kirty.setName("Kirsten Pelletier"); + kirty.setCity("Ottawa"); + kirty.addCCustomer(owen); + em.persist(kirty); + int kirtyId = kirty.getCustomerId(); + + Customer guy = new Customer(); + guy.setName("Guy Pelletier"); + guy.setCity("Ottawa"); + guy.addCCustomer(owen); + guy.addCCustomer(kirty); + kirty.addCCustomer(guy); // guess I'll allow this one ... ;-) + em.persist(guy); + int guyId = guy.getCustomerId(); + + em.getTransaction().commit(); + + clearCache(); + + Customer newOwen = em.find(Customer.class, owenId); + Customer newKirty = em.find(Customer.class, kirtyId); + Customer newGuy = em.find(Customer.class, guyId); + + assertTrue("Owen has controlled customers .", newOwen.getCCustomers().isEmpty()); + assertFalse("Kirty did not have any controlled customers.", newKirty.getCCustomers().isEmpty()); + assertFalse("Guy did not have any controlled customers.", newGuy.getCCustomers().isEmpty()); + + em.close(); + } + } \ No newline at end of file ================================================================================ Merge Diffs: /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/FullRegressionTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000008/AB0952363AC40CBFE034080020E8C54E.22 Report generated at Fri Sep 29 11:46:49 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000008/AB0952363AC40CBFE034080020E8C54E.22 Fri Sep 29 11:34:45 2006 --- /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/FullRegressionTestSuite.java Fri Sep 29 11:46:49 2006 *************** *** 46,51 **** --- 46,52 ---- import oracle.toplink.essentials.testing.tests.cmp3.relationships.EMQueryJUnitTestSuite; import oracle.toplink.essentials.testing.tests.cmp3.relationships.ExpressionJUnitTestSuite; + import oracle.toplink.essentials.testing.tests.cmp3.relationships.UniAndBiDirectionalMappingTestSuite; import oracle.toplink.essentials.testing.tests.cmp3.relationships.VirtualAttributeTestSuite; import oracle.toplink.essentials.testing.tests.cmp3.validation.ValidationTestSuite; *************** *** 106,111 **** --- 107,114 ---- // Relationship model fullSuite.addTestSuite(EMQueryJUnitTestSuite.class); fullSuite.addTestSuite(ExpressionJUnitTestSuite.class); + fullSuite.addTestSuite(UniAndBiDirectionalMappingTestSuite.class); + fullSuite.addTest(VirtualAttributeTestSuite.suite()); fullSuite.addTest(ValidationTestSuite.suite()); ================================================================================ Merge Diffs: /ade/gpelleti_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/accessors/CollectionAccessor.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.5 Report generated at Fri Sep 29 12:01:58 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.5 Wed Sep 27 08:51:24 2006 --- /ade/gpelleti_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/accessors/CollectionAccessor.java Fri Sep 29 12:01:58 2006 *************** *** 222,229 **** // Add all the joinColumns (source foreign keys) to the mapping. String defaultSourceFieldName; ! if (getReferenceDescriptor().hasManyToManyAccessorFor(getJavaClassName())) { ! defaultSourceFieldName = getReferenceDescriptor().getManyToManyAccessor(getJavaClassName()).getAttributeName(); } else { defaultSourceFieldName = Helper.getShortClassName(getJavaClass().getName()); } --- 222,229 ---- // Add all the joinColumns (source foreign keys) to the mapping. String defaultSourceFieldName; ! if (getReferenceDescriptor().hasBiDirectionalManyToManyAccessorFor(getJavaClassName(), getAttributeName())) { ! defaultSourceFieldName = getReferenceDescriptor().getBiDirectionalManyToManyAccessor(getJavaClassName(), getAttributeName()).getAttributeName(); } else { defaultSourceFieldName = Helper.getShortClassName(getJavaClass().getName()); } ================================================================================ Merge Diffs: /ade/gpelleti_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/MetadataDescriptor.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.43 Report generated at Fri Sep 29 12:01:58 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.43 Wed Sep 27 08:51:48 2006 --- /ade/gpelleti_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/MetadataDescriptor.java Fri Sep 29 12:01:58 2006 *************** *** 89,96 **** protected Map m_accessors; protected Map m_attributeOverrides; protected Map m_associationOverrides; ! protected Map m_manyToManyAccessors; protected Map m_relationshipAccessors; /** * INTERNAL: --- 89,97 ---- protected Map m_accessors; protected Map m_attributeOverrides; protected Map m_associationOverrides; ! protected Map m_relationshipAccessors; + protected Map> m_biDirectionalManyToManyAccessors; /** * INTERNAL: *************** *** 113,122 **** m_relationshipAccessors.put(accessor.getAttributeName(), (RelationshipAccessor) accessor); } ! // Store ManyToMany relationships so that we may look at attribute ! // names when defaulting join columns for bi and uni directional M-M's. if (accessor.isManyToMany()) { ! m_manyToManyAccessors.put(accessor.getReferenceClassName(), accessor); } } --- 114,134 ---- m_relationshipAccessors.put(accessor.getAttributeName(), (RelationshipAccessor) accessor); } ! // Store bidirectional ManyToMany relationships so that we may look at ! // attribute names when defaulting join columns. if (accessor.isManyToMany()) { ! String mappedBy = ((RelationshipAccessor) accessor).getMappedBy(); ! ! if (! mappedBy.equals("")) { ! String referenceClassName = accessor.getReferenceClassName(); ! ! // Initialize the map of bi-directional mappings for this class. ! if (! m_biDirectionalManyToManyAccessors.containsKey(referenceClassName)) { ! m_biDirectionalManyToManyAccessors.put(referenceClassName, new HashMap()); ! } ! ! m_biDirectionalManyToManyAccessors.get(referenceClassName).put(mappedBy, accessor); ! } } } *************** *** 389,397 **** /** * INTERNAL: */ ! public MetadataAccessor getManyToManyAccessor(String className) { ! return m_manyToManyAccessors.get(className); } /** --- 401,411 ---- /** * INTERNAL: + * Assumes hasBidirectionalManyToManyAccessorFor has been called before + * hand. */ ! public MetadataAccessor getBiDirectionalManyToManyAccessor(String className, String attributeName) { ! return m_biDirectionalManyToManyAccessors.get(className).get(attributeName); } /** *************** *** 585,592 **** /** * INTERNAL: */ ! public boolean hasManyToManyAccessorFor(String className) { ! return m_manyToManyAccessors.containsKey(className); } /** --- 599,610 ---- /** * INTERNAL: */ ! public boolean hasBiDirectionalManyToManyAccessorFor(String className, String attributeName) { ! if (m_biDirectionalManyToManyAccessors.containsKey(className)) { ! return m_biDirectionalManyToManyAccessors.get(className).containsKey(attributeName); ! } ! ! return false; } /** *************** *** 647,655 **** m_pkClassIDs = new HashMap(); m_accessors = new HashMap(); m_attributeOverrides = new HashMap(); - m_manyToManyAccessors = new HashMap(); m_associationOverrides = new HashMap(); m_relationshipAccessors = new HashMap(); } /** --- 665,674 ---- m_pkClassIDs = new HashMap(); m_accessors = new HashMap(); m_attributeOverrides = new HashMap(); m_associationOverrides = new HashMap(); + m_relationshipAccessors = new HashMap(); + m_biDirectionalManyToManyAccessors = new HashMap>(); } /** ================================================================================ Merge Diffs: /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/relationships/Customer.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.9 Report generated at Fri Sep 29 12:01:58 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.9 Wed Sep 27 11:19:21 2006 --- /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/relationships/Customer.java Fri Sep 29 12:01:58 2006 *************** *** 21,26 **** --- 21,27 ---- // Copyright (c) 1998, 2006, Oracle. All rights reserved. package oracle.toplink.essentials.testing.models.cmp3.relationships; + import java.util.Vector; import java.util.HashSet; import java.util.Collection; import javax.persistence.*; *************** *** 46,51 **** --- 47,53 ---- private String city; private String name; private Collection orders = new HashSet(); + private Collection controlledCustomers = new HashSet(); public Customer() {} *************** *** 110,113 **** --- 112,133 ---- public void removeOrder(Order anOrder) { getOrders().remove(anOrder); } + + @ManyToMany + @JoinTable(name="CMP3_CUSTOMER_CUSTOMER") + public Collection getCCustomers() { + if (controlledCustomers == null) { + return new Vector(); + } + + return controlledCustomers; + } + + public void setCCustomers(Collection controlledCustomers) { + this.controlledCustomers = controlledCustomers; + } + + public void addCCustomer(Customer controlledCustomer) { + getCCustomers().add(controlledCustomer); + } } ================================================================================ Merge Diffs: /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/relationships/RelationshipsTableManager.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.7 Report generated at Fri Sep 29 12:01:58 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.7 Wed Sep 27 11:19:41 2006 --- /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/relationships/RelationshipsTableManager.java Fri Sep 29 12:01:58 2006 *************** *** 37,42 **** --- 37,43 ---- addTableDefinition(buildCMP3_ORDERTable()); addTableDefinition(buildCMP3_ORDER_SEQTable()); addTableDefinition(buildCMP3_SALESPERSONTable()); + addTableDefinition(buildCUSTOMER_CUSTOMERTable()); } public static TableCreator getCreator(){ *************** *** 337,340 **** --- 338,373 ---- return table; } + + public static TableDefinition buildCUSTOMER_CUSTOMERTable() { + TableDefinition table = new TableDefinition(); + + table.setName("CMP3_CUSTOMER_CUSTOMER"); + + // SECTION: FIELD + FieldDefinition field = new FieldDefinition(); + field.setName("CUSTOMER_CUST_ID"); + field.setTypeName("NUMERIC"); + field.setSize(15); + field.setShouldAllowNull(false); + field.setIsPrimaryKey(true); + field.setUnique(false); + field.setIsIdentity(false); + field.setForeignKeyFieldName("CMP3_CUSTOMER.CUST_ID"); + table.addField(field); + + // SECTION: FIELD + FieldDefinition field1 = new FieldDefinition(); + field1.setName("CCUSTOMERS_CUST_ID"); + field1.setTypeName("NUMERIC"); + field1.setSize(15); + field1.setShouldAllowNull(false); + field1.setIsPrimaryKey(true); + field1.setUnique(false); + field1.setIsIdentity(false); + field1.setForeignKeyFieldName("CMP3_CUSTOMER.CUST_ID"); + table.addField(field1); + + return table; + } } ================================================================================ Merge Diffs: /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/relationships/UniAndBiDirectionalMappingTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Sep 29 12:01:58 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.0 Fri Sep 29 11:17:17 2006 --- /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/relationships/UniAndBiDirectionalMappingTestSuite.java Fri Sep 29 12:01:19 2006 *************** *** 0 **** --- 1,105 ---- + /* + * The contents of this file are subject to the terms + * of the Common Development and Distribution License + * (the "License"). You may not use this file except + * in compliance with the License. + * + * You can obtain a copy of the license at + * glassfish/bootstrap/legal/CDDLv1.0.txt or + * https://glassfish.dev.java.net/public/CDDLv1.0.html. + * See the License for the specific language governing + * permissions and limitations under the License. + * + * When distributing Covered Code, include this CDDL + * HEADER in each file and include the License file at + * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable, + * add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your + * own identifying information: Portions Copyright [yyyy] + * [name of copyright owner] + */ + // Copyright (c) 1998, 2006, Oracle. All rights reserved. + package oracle.toplink.essentials.testing.tests.cmp3.relationships; + + import junit.framework.*; + import junit.extensions.TestSetup; + + import javax.persistence.*; + + import oracle.toplink.essentials.sessions.DatabaseSession; + import oracle.toplink.essentials.testing.models.cmp3.relationships.*; + import oracle.toplink.essentials.testing.framework.junit.JUnitTestCase; + import oracle.toplink.essentials.testing.models.cmp3.relationships.Customer; + + public class UniAndBiDirectionalMappingTestSuite extends JUnitTestCase { + public UniAndBiDirectionalMappingTestSuite() {} + + public UniAndBiDirectionalMappingTestSuite(String name) { + super(name); + } + + public void setUp () { + super.setUp(); + new RelationshipsTableManager().replaceTables(JUnitTestCase.getServerSession()); + } + + public static Test suite() { + TestSuite suite = new TestSuite(); + suite.setName("UniAndBiDirectionalMappingTestSuite"); + suite.addTest(new UniAndBiDirectionalMappingTestSuite("selfReferencingManyToManyTest")); + + return new TestSetup(suite) { + + protected void setUp() { + DatabaseSession session = JUnitTestCase.getServerSession(); + new RelationshipsTableManager().replaceTables(JUnitTestCase.getServerSession()); + } + + protected void tearDown() { + clearCache(); + } + }; + } + + public void selfReferencingManyToManyTest() throws Exception { + EntityManager em = createEntityManager(); + + em.getTransaction().begin(); + + Customer owen = new Customer(); + owen.setName("Owen Pelletier"); + owen.setCity("Ottawa"); + em.persist(owen); + int owenId = owen.getCustomerId(); + + Customer kirty = new Customer(); + kirty.setName("Kirsten Pelletier"); + kirty.setCity("Ottawa"); + kirty.addCCustomer(owen); + em.persist(kirty); + int kirtyId = kirty.getCustomerId(); + + Customer guy = new Customer(); + guy.setName("Guy Pelletier"); + guy.setCity("Ottawa"); + guy.addCCustomer(owen); + guy.addCCustomer(kirty); + kirty.addCCustomer(guy); // guess I'll allow this one ... ;-) + em.persist(guy); + int guyId = guy.getCustomerId(); + + em.getTransaction().commit(); + + clearCache(); + + Customer newOwen = em.find(Customer.class, owenId); + Customer newKirty = em.find(Customer.class, kirtyId); + Customer newGuy = em.find(Customer.class, guyId); + + assertTrue("Owen has controlled customers .", newOwen.getCCustomers().isEmpty()); + assertFalse("Kirty did not have any controlled customers.", newKirty.getCCustomers().isEmpty()); + assertFalse("Guy did not have any controlled customers.", newGuy.getCCustomers().isEmpty()); + + em.close(); + } + } \ No newline at end of file ================================================================================ Merge Diffs: /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/FullRegressionTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000008/AB0952363AC40CBFE034080020E8C54E.22 Report generated at Fri Sep 29 12:01:58 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000008/AB0952363AC40CBFE034080020E8C54E.22 Fri Sep 29 11:34:45 2006 --- /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/FullRegressionTestSuite.java Fri Sep 29 12:01:58 2006 *************** *** 46,51 **** --- 46,52 ---- import oracle.toplink.essentials.testing.tests.cmp3.relationships.EMQueryJUnitTestSuite; import oracle.toplink.essentials.testing.tests.cmp3.relationships.ExpressionJUnitTestSuite; + import oracle.toplink.essentials.testing.tests.cmp3.relationships.UniAndBiDirectionalMappingTestSuite; import oracle.toplink.essentials.testing.tests.cmp3.relationships.VirtualAttributeTestSuite; import oracle.toplink.essentials.testing.tests.cmp3.validation.ValidationTestSuite; *************** *** 106,111 **** --- 107,114 ---- // Relationship model fullSuite.addTestSuite(EMQueryJUnitTestSuite.class); fullSuite.addTestSuite(ExpressionJUnitTestSuite.class); + fullSuite.addTestSuite(UniAndBiDirectionalMappingTestSuite.class); + fullSuite.addTest(VirtualAttributeTestSuite.suite()); fullSuite.addTest(ValidationTestSuite.suite()); ================================================================================ Merge Diffs: /ade/gpelleti_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/accessors/CollectionAccessor.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.5 Report generated at Fri Sep 29 14:39:27 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.5 Wed Sep 27 08:51:24 2006 --- /ade/gpelleti_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/accessors/CollectionAccessor.java Fri Sep 29 14:39:27 2006 *************** *** 222,229 **** // Add all the joinColumns (source foreign keys) to the mapping. String defaultSourceFieldName; ! if (getReferenceDescriptor().hasManyToManyAccessorFor(getJavaClassName())) { ! defaultSourceFieldName = getReferenceDescriptor().getManyToManyAccessor(getJavaClassName()).getAttributeName(); } else { defaultSourceFieldName = Helper.getShortClassName(getJavaClass().getName()); } --- 222,229 ---- // Add all the joinColumns (source foreign keys) to the mapping. String defaultSourceFieldName; ! if (getReferenceDescriptor().hasBiDirectionalManyToManyAccessorFor(getJavaClassName(), getAttributeName())) { ! defaultSourceFieldName = getReferenceDescriptor().getBiDirectionalManyToManyAccessor(getJavaClassName(), getAttributeName()).getAttributeName(); } else { defaultSourceFieldName = Helper.getShortClassName(getJavaClass().getName()); } ================================================================================ Merge Diffs: /ade/gpelleti_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/MetadataDescriptor.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.43 Report generated at Fri Sep 29 14:39:27 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.43 Wed Sep 27 08:51:48 2006 --- /ade/gpelleti_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/MetadataDescriptor.java Fri Sep 29 14:39:27 2006 *************** *** 89,96 **** protected Map m_accessors; protected Map m_attributeOverrides; protected Map m_associationOverrides; ! protected Map m_manyToManyAccessors; protected Map m_relationshipAccessors; /** * INTERNAL: --- 89,97 ---- protected Map m_accessors; protected Map m_attributeOverrides; protected Map m_associationOverrides; ! protected Map m_relationshipAccessors; + protected Map> m_biDirectionalManyToManyAccessors; /** * INTERNAL: *************** *** 113,122 **** m_relationshipAccessors.put(accessor.getAttributeName(), (RelationshipAccessor) accessor); } ! // Store ManyToMany relationships so that we may look at attribute ! // names when defaulting join columns for bi and uni directional M-M's. if (accessor.isManyToMany()) { ! m_manyToManyAccessors.put(accessor.getReferenceClassName(), accessor); } } --- 114,134 ---- m_relationshipAccessors.put(accessor.getAttributeName(), (RelationshipAccessor) accessor); } ! // Store bidirectional ManyToMany relationships so that we may look at ! // attribute names when defaulting join columns. if (accessor.isManyToMany()) { ! String mappedBy = ((RelationshipAccessor) accessor).getMappedBy(); ! ! if (! mappedBy.equals("")) { ! String referenceClassName = accessor.getReferenceClassName(); ! ! // Initialize the map of bi-directional mappings for this class. ! if (! m_biDirectionalManyToManyAccessors.containsKey(referenceClassName)) { ! m_biDirectionalManyToManyAccessors.put(referenceClassName, new HashMap()); ! } ! ! m_biDirectionalManyToManyAccessors.get(referenceClassName).put(mappedBy, accessor); ! } } } *************** *** 389,397 **** /** * INTERNAL: */ ! public MetadataAccessor getManyToManyAccessor(String className) { ! return m_manyToManyAccessors.get(className); } /** --- 401,411 ---- /** * INTERNAL: + * Assumes hasBidirectionalManyToManyAccessorFor has been called before + * hand. */ ! public MetadataAccessor getBiDirectionalManyToManyAccessor(String className, String attributeName) { ! return m_biDirectionalManyToManyAccessors.get(className).get(attributeName); } /** *************** *** 585,592 **** /** * INTERNAL: */ ! public boolean hasManyToManyAccessorFor(String className) { ! return m_manyToManyAccessors.containsKey(className); } /** --- 599,610 ---- /** * INTERNAL: */ ! public boolean hasBiDirectionalManyToManyAccessorFor(String className, String attributeName) { ! if (m_biDirectionalManyToManyAccessors.containsKey(className)) { ! return m_biDirectionalManyToManyAccessors.get(className).containsKey(attributeName); ! } ! ! return false; } /** *************** *** 647,655 **** m_pkClassIDs = new HashMap(); m_accessors = new HashMap(); m_attributeOverrides = new HashMap(); - m_manyToManyAccessors = new HashMap(); m_associationOverrides = new HashMap(); m_relationshipAccessors = new HashMap(); } /** --- 665,674 ---- m_pkClassIDs = new HashMap(); m_accessors = new HashMap(); m_attributeOverrides = new HashMap(); m_associationOverrides = new HashMap(); + m_relationshipAccessors = new HashMap(); + m_biDirectionalManyToManyAccessors = new HashMap>(); } /** ================================================================================ Merge Diffs: /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/relationships/Customer.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.9 Report generated at Fri Sep 29 14:39:27 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.9 Wed Sep 27 11:19:21 2006 --- /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/relationships/Customer.java Fri Sep 29 14:39:27 2006 *************** *** 21,26 **** --- 21,27 ---- // Copyright (c) 1998, 2006, Oracle. All rights reserved. package oracle.toplink.essentials.testing.models.cmp3.relationships; + import java.util.Vector; import java.util.HashSet; import java.util.Collection; import javax.persistence.*; *************** *** 46,51 **** --- 47,53 ---- private String city; private String name; private Collection orders = new HashSet(); + private Collection controlledCustomers = new HashSet(); public Customer() {} *************** *** 110,113 **** --- 112,133 ---- public void removeOrder(Order anOrder) { getOrders().remove(anOrder); } + + @ManyToMany + @JoinTable(name="CMP3_CUSTOMER_CUSTOMER") + public Collection getCCustomers() { + if (controlledCustomers == null) { + return new Vector(); + } + + return controlledCustomers; + } + + public void setCCustomers(Collection controlledCustomers) { + this.controlledCustomers = controlledCustomers; + } + + public void addCCustomer(Customer controlledCustomer) { + getCCustomers().add(controlledCustomer); + } } ================================================================================ Merge Diffs: /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/relationships/RelationshipsTableManager.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.7 Report generated at Fri Sep 29 14:39:27 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.7 Wed Sep 27 11:19:41 2006 --- /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/relationships/RelationshipsTableManager.java Fri Sep 29 14:39:27 2006 *************** *** 37,42 **** --- 37,43 ---- addTableDefinition(buildCMP3_ORDERTable()); addTableDefinition(buildCMP3_ORDER_SEQTable()); addTableDefinition(buildCMP3_SALESPERSONTable()); + addTableDefinition(buildCUSTOMER_CUSTOMERTable()); } public static TableCreator getCreator(){ *************** *** 337,340 **** --- 338,373 ---- return table; } + + public static TableDefinition buildCUSTOMER_CUSTOMERTable() { + TableDefinition table = new TableDefinition(); + + table.setName("CMP3_CUSTOMER_CUSTOMER"); + + // SECTION: FIELD + FieldDefinition field = new FieldDefinition(); + field.setName("CUSTOMER_CUST_ID"); + field.setTypeName("NUMERIC"); + field.setSize(15); + field.setShouldAllowNull(false); + field.setIsPrimaryKey(true); + field.setUnique(false); + field.setIsIdentity(false); + field.setForeignKeyFieldName("CMP3_CUSTOMER.CUST_ID"); + table.addField(field); + + // SECTION: FIELD + FieldDefinition field1 = new FieldDefinition(); + field1.setName("CCUSTOMERS_CUST_ID"); + field1.setTypeName("NUMERIC"); + field1.setSize(15); + field1.setShouldAllowNull(false); + field1.setIsPrimaryKey(true); + field1.setUnique(false); + field1.setIsIdentity(false); + field1.setForeignKeyFieldName("CMP3_CUSTOMER.CUST_ID"); + table.addField(field1); + + return table; + } } ================================================================================ Merge Diffs: /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/relationships/UniAndBiDirectionalMappingTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Sep 29 14:39:27 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.0 Fri Sep 29 11:17:17 2006 --- /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/relationships/UniAndBiDirectionalMappingTestSuite.java Fri Sep 29 14:39:04 2006 *************** *** 0 **** --- 1,105 ---- + /* + * The contents of this file are subject to the terms + * of the Common Development and Distribution License + * (the "License"). You may not use this file except + * in compliance with the License. + * + * You can obtain a copy of the license at + * glassfish/bootstrap/legal/CDDLv1.0.txt or + * https://glassfish.dev.java.net/public/CDDLv1.0.html. + * See the License for the specific language governing + * permissions and limitations under the License. + * + * When distributing Covered Code, include this CDDL + * HEADER in each file and include the License file at + * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable, + * add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your + * own identifying information: Portions Copyright [yyyy] + * [name of copyright owner] + */ + // Copyright (c) 1998, 2006, Oracle. All rights reserved. + package oracle.toplink.essentials.testing.tests.cmp3.relationships; + + import junit.framework.*; + import junit.extensions.TestSetup; + + import javax.persistence.*; + + import oracle.toplink.essentials.sessions.DatabaseSession; + import oracle.toplink.essentials.testing.models.cmp3.relationships.*; + import oracle.toplink.essentials.testing.framework.junit.JUnitTestCase; + import oracle.toplink.essentials.testing.models.cmp3.relationships.Customer; + + public class UniAndBiDirectionalMappingTestSuite extends JUnitTestCase { + public UniAndBiDirectionalMappingTestSuite() {} + + public UniAndBiDirectionalMappingTestSuite(String name) { + super(name); + } + + public void setUp () { + super.setUp(); + new RelationshipsTableManager().replaceTables(JUnitTestCase.getServerSession()); + } + + public static Test suite() { + TestSuite suite = new TestSuite(); + suite.setName("UniAndBiDirectionalMappingTestSuite"); + suite.addTest(new UniAndBiDirectionalMappingTestSuite("selfReferencingManyToManyTest")); + + return new TestSetup(suite) { + + protected void setUp() { + DatabaseSession session = JUnitTestCase.getServerSession(); + new RelationshipsTableManager().replaceTables(JUnitTestCase.getServerSession()); + } + + protected void tearDown() { + clearCache(); + } + }; + } + + public void selfReferencingManyToManyTest() throws Exception { + EntityManager em = createEntityManager(); + + em.getTransaction().begin(); + + Customer owen = new Customer(); + owen.setName("Owen Pelletier"); + owen.setCity("Ottawa"); + em.persist(owen); + int owenId = owen.getCustomerId(); + + Customer kirty = new Customer(); + kirty.setName("Kirsten Pelletier"); + kirty.setCity("Ottawa"); + kirty.addCCustomer(owen); + em.persist(kirty); + int kirtyId = kirty.getCustomerId(); + + Customer guy = new Customer(); + guy.setName("Guy Pelletier"); + guy.setCity("Ottawa"); + guy.addCCustomer(owen); + guy.addCCustomer(kirty); + kirty.addCCustomer(guy); // guess I'll allow this one ... ;-) + em.persist(guy); + int guyId = guy.getCustomerId(); + + em.getTransaction().commit(); + + clearCache(); + + Customer newOwen = em.find(Customer.class, owenId); + Customer newKirty = em.find(Customer.class, kirtyId); + Customer newGuy = em.find(Customer.class, guyId); + + assertTrue("Owen has controlled customers .", newOwen.getCCustomers().isEmpty()); + assertFalse("Kirty did not have any controlled customers.", newKirty.getCCustomers().isEmpty()); + assertFalse("Guy did not have any controlled customers.", newGuy.getCCustomers().isEmpty()); + + em.close(); + } + } \ No newline at end of file ================================================================================ Merge Diffs: /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/FullRegressionTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000008/AB0952363AC40CBFE034080020E8C54E.22 Report generated at Fri Sep 29 14:39:27 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000008/AB0952363AC40CBFE034080020E8C54E.22 Fri Sep 29 11:34:45 2006 --- /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/FullRegressionTestSuite.java Fri Sep 29 14:39:27 2006 *************** *** 46,51 **** --- 46,52 ---- import oracle.toplink.essentials.testing.tests.cmp3.relationships.EMQueryJUnitTestSuite; import oracle.toplink.essentials.testing.tests.cmp3.relationships.ExpressionJUnitTestSuite; + import oracle.toplink.essentials.testing.tests.cmp3.relationships.UniAndBiDirectionalMappingTestSuite; import oracle.toplink.essentials.testing.tests.cmp3.relationships.VirtualAttributeTestSuite; import oracle.toplink.essentials.testing.tests.cmp3.validation.ValidationTestSuite; *************** *** 107,115 **** fullSuite.addTestSuite(EMQueryJUnitTestSuite.class); fullSuite.addTestSuite(ExpressionJUnitTestSuite.class); fullSuite.addTest(VirtualAttributeTestSuite.suite()); - fullSuite.addTest(ValidationTestSuite.suite()); fullSuite.addTest(QueryParameterValidationTestSuite.suite()); // EJBQL testing model fullSuite.addTest(JUnitEJBQLUnitTestSuite.suite()); --- 108,116 ---- fullSuite.addTestSuite(EMQueryJUnitTestSuite.class); fullSuite.addTestSuite(ExpressionJUnitTestSuite.class); fullSuite.addTest(VirtualAttributeTestSuite.suite()); fullSuite.addTest(ValidationTestSuite.suite()); fullSuite.addTest(QueryParameterValidationTestSuite.suite()); + fullSuite.addTest(UniAndBiDirectionalMappingTestSuite.suite()); // EJBQL testing model fullSuite.addTest(JUnitEJBQLUnitTestSuite.suite()); ================================================================================ Merge Diffs: /ade/gpelleti_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/accessors/CollectionAccessor.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.5 Report generated at Fri Sep 29 14:52:00 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.5 Wed Sep 27 08:51:24 2006 --- /ade/gpelleti_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/accessors/CollectionAccessor.java Fri Sep 29 14:39:27 2006 *************** *** 222,229 **** // Add all the joinColumns (source foreign keys) to the mapping. String defaultSourceFieldName; ! if (getReferenceDescriptor().hasManyToManyAccessorFor(getJavaClassName())) { ! defaultSourceFieldName = getReferenceDescriptor().getManyToManyAccessor(getJavaClassName()).getAttributeName(); } else { defaultSourceFieldName = Helper.getShortClassName(getJavaClass().getName()); } --- 222,229 ---- // Add all the joinColumns (source foreign keys) to the mapping. String defaultSourceFieldName; ! if (getReferenceDescriptor().hasBiDirectionalManyToManyAccessorFor(getJavaClassName(), getAttributeName())) { ! defaultSourceFieldName = getReferenceDescriptor().getBiDirectionalManyToManyAccessor(getJavaClassName(), getAttributeName()).getAttributeName(); } else { defaultSourceFieldName = Helper.getShortClassName(getJavaClass().getName()); } ================================================================================ Merge Diffs: /ade/gpelleti_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/MetadataDescriptor.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.43 Report generated at Fri Sep 29 14:52:00 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.43 Wed Sep 27 08:51:48 2006 --- /ade/gpelleti_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/MetadataDescriptor.java Fri Sep 29 14:39:27 2006 *************** *** 89,96 **** protected Map m_accessors; protected Map m_attributeOverrides; protected Map m_associationOverrides; ! protected Map m_manyToManyAccessors; protected Map m_relationshipAccessors; /** * INTERNAL: --- 89,97 ---- protected Map m_accessors; protected Map m_attributeOverrides; protected Map m_associationOverrides; ! protected Map m_relationshipAccessors; + protected Map> m_biDirectionalManyToManyAccessors; /** * INTERNAL: *************** *** 113,122 **** m_relationshipAccessors.put(accessor.getAttributeName(), (RelationshipAccessor) accessor); } ! // Store ManyToMany relationships so that we may look at attribute ! // names when defaulting join columns for bi and uni directional M-M's. if (accessor.isManyToMany()) { ! m_manyToManyAccessors.put(accessor.getReferenceClassName(), accessor); } } --- 114,134 ---- m_relationshipAccessors.put(accessor.getAttributeName(), (RelationshipAccessor) accessor); } ! // Store bidirectional ManyToMany relationships so that we may look at ! // attribute names when defaulting join columns. if (accessor.isManyToMany()) { ! String mappedBy = ((RelationshipAccessor) accessor).getMappedBy(); ! ! if (! mappedBy.equals("")) { ! String referenceClassName = accessor.getReferenceClassName(); ! ! // Initialize the map of bi-directional mappings for this class. ! if (! m_biDirectionalManyToManyAccessors.containsKey(referenceClassName)) { ! m_biDirectionalManyToManyAccessors.put(referenceClassName, new HashMap()); ! } ! ! m_biDirectionalManyToManyAccessors.get(referenceClassName).put(mappedBy, accessor); ! } } } *************** *** 389,397 **** /** * INTERNAL: */ ! public MetadataAccessor getManyToManyAccessor(String className) { ! return m_manyToManyAccessors.get(className); } /** --- 401,411 ---- /** * INTERNAL: + * Assumes hasBidirectionalManyToManyAccessorFor has been called before + * hand. */ ! public MetadataAccessor getBiDirectionalManyToManyAccessor(String className, String attributeName) { ! return m_biDirectionalManyToManyAccessors.get(className).get(attributeName); } /** *************** *** 585,592 **** /** * INTERNAL: */ ! public boolean hasManyToManyAccessorFor(String className) { ! return m_manyToManyAccessors.containsKey(className); } /** --- 599,610 ---- /** * INTERNAL: */ ! public boolean hasBiDirectionalManyToManyAccessorFor(String className, String attributeName) { ! if (m_biDirectionalManyToManyAccessors.containsKey(className)) { ! return m_biDirectionalManyToManyAccessors.get(className).containsKey(attributeName); ! } ! ! return false; } /** *************** *** 647,655 **** m_pkClassIDs = new HashMap(); m_accessors = new HashMap(); m_attributeOverrides = new HashMap(); - m_manyToManyAccessors = new HashMap(); m_associationOverrides = new HashMap(); m_relationshipAccessors = new HashMap(); } /** --- 665,674 ---- m_pkClassIDs = new HashMap(); m_accessors = new HashMap(); m_attributeOverrides = new HashMap(); m_associationOverrides = new HashMap(); + m_relationshipAccessors = new HashMap(); + m_biDirectionalManyToManyAccessors = new HashMap>(); } /** ================================================================================ Merge Diffs: /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/relationships/Customer.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.9 Report generated at Fri Sep 29 14:52:00 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.9 Wed Sep 27 11:19:21 2006 --- /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/relationships/Customer.java Fri Sep 29 14:39:27 2006 *************** *** 21,26 **** --- 21,27 ---- // Copyright (c) 1998, 2006, Oracle. All rights reserved. package oracle.toplink.essentials.testing.models.cmp3.relationships; + import java.util.Vector; import java.util.HashSet; import java.util.Collection; import javax.persistence.*; *************** *** 46,51 **** --- 47,53 ---- private String city; private String name; private Collection orders = new HashSet(); + private Collection controlledCustomers = new HashSet(); public Customer() {} *************** *** 110,113 **** --- 112,133 ---- public void removeOrder(Order anOrder) { getOrders().remove(anOrder); } + + @ManyToMany + @JoinTable(name="CMP3_CUSTOMER_CUSTOMER") + public Collection getCCustomers() { + if (controlledCustomers == null) { + return new Vector(); + } + + return controlledCustomers; + } + + public void setCCustomers(Collection controlledCustomers) { + this.controlledCustomers = controlledCustomers; + } + + public void addCCustomer(Customer controlledCustomer) { + getCCustomers().add(controlledCustomer); + } } ================================================================================ Merge Diffs: /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/relationships/RelationshipsTableManager.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.7 Report generated at Fri Sep 29 14:52:00 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.7 Wed Sep 27 11:19:41 2006 --- /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/relationships/RelationshipsTableManager.java Fri Sep 29 14:39:27 2006 *************** *** 37,42 **** --- 37,43 ---- addTableDefinition(buildCMP3_ORDERTable()); addTableDefinition(buildCMP3_ORDER_SEQTable()); addTableDefinition(buildCMP3_SALESPERSONTable()); + addTableDefinition(buildCUSTOMER_CUSTOMERTable()); } public static TableCreator getCreator(){ *************** *** 337,340 **** --- 338,373 ---- return table; } + + public static TableDefinition buildCUSTOMER_CUSTOMERTable() { + TableDefinition table = new TableDefinition(); + + table.setName("CMP3_CUSTOMER_CUSTOMER"); + + // SECTION: FIELD + FieldDefinition field = new FieldDefinition(); + field.setName("CUSTOMER_CUST_ID"); + field.setTypeName("NUMERIC"); + field.setSize(15); + field.setShouldAllowNull(false); + field.setIsPrimaryKey(true); + field.setUnique(false); + field.setIsIdentity(false); + field.setForeignKeyFieldName("CMP3_CUSTOMER.CUST_ID"); + table.addField(field); + + // SECTION: FIELD + FieldDefinition field1 = new FieldDefinition(); + field1.setName("CCUSTOMERS_CUST_ID"); + field1.setTypeName("NUMERIC"); + field1.setSize(15); + field1.setShouldAllowNull(false); + field1.setIsPrimaryKey(true); + field1.setUnique(false); + field1.setIsIdentity(false); + field1.setForeignKeyFieldName("CMP3_CUSTOMER.CUST_ID"); + table.addField(field1); + + return table; + } } ================================================================================ Merge Diffs: /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/relationships/UniAndBiDirectionalMappingTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Sep 29 14:52:00 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.0 Fri Sep 29 11:17:17 2006 --- /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/relationships/UniAndBiDirectionalMappingTestSuite.java Fri Sep 29 14:39:04 2006 *************** *** 0 **** --- 1,105 ---- + /* + * The contents of this file are subject to the terms + * of the Common Development and Distribution License + * (the "License"). You may not use this file except + * in compliance with the License. + * + * You can obtain a copy of the license at + * glassfish/bootstrap/legal/CDDLv1.0.txt or + * https://glassfish.dev.java.net/public/CDDLv1.0.html. + * See the License for the specific language governing + * permissions and limitations under the License. + * + * When distributing Covered Code, include this CDDL + * HEADER in each file and include the License file at + * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable, + * add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your + * own identifying information: Portions Copyright [yyyy] + * [name of copyright owner] + */ + // Copyright (c) 1998, 2006, Oracle. All rights reserved. + package oracle.toplink.essentials.testing.tests.cmp3.relationships; + + import junit.framework.*; + import junit.extensions.TestSetup; + + import javax.persistence.*; + + import oracle.toplink.essentials.sessions.DatabaseSession; + import oracle.toplink.essentials.testing.models.cmp3.relationships.*; + import oracle.toplink.essentials.testing.framework.junit.JUnitTestCase; + import oracle.toplink.essentials.testing.models.cmp3.relationships.Customer; + + public class UniAndBiDirectionalMappingTestSuite extends JUnitTestCase { + public UniAndBiDirectionalMappingTestSuite() {} + + public UniAndBiDirectionalMappingTestSuite(String name) { + super(name); + } + + public void setUp () { + super.setUp(); + new RelationshipsTableManager().replaceTables(JUnitTestCase.getServerSession()); + } + + public static Test suite() { + TestSuite suite = new TestSuite(); + suite.setName("UniAndBiDirectionalMappingTestSuite"); + suite.addTest(new UniAndBiDirectionalMappingTestSuite("selfReferencingManyToManyTest")); + + return new TestSetup(suite) { + + protected void setUp() { + DatabaseSession session = JUnitTestCase.getServerSession(); + new RelationshipsTableManager().replaceTables(JUnitTestCase.getServerSession()); + } + + protected void tearDown() { + clearCache(); + } + }; + } + + public void selfReferencingManyToManyTest() throws Exception { + EntityManager em = createEntityManager(); + + em.getTransaction().begin(); + + Customer owen = new Customer(); + owen.setName("Owen Pelletier"); + owen.setCity("Ottawa"); + em.persist(owen); + int owenId = owen.getCustomerId(); + + Customer kirty = new Customer(); + kirty.setName("Kirsten Pelletier"); + kirty.setCity("Ottawa"); + kirty.addCCustomer(owen); + em.persist(kirty); + int kirtyId = kirty.getCustomerId(); + + Customer guy = new Customer(); + guy.setName("Guy Pelletier"); + guy.setCity("Ottawa"); + guy.addCCustomer(owen); + guy.addCCustomer(kirty); + kirty.addCCustomer(guy); // guess I'll allow this one ... ;-) + em.persist(guy); + int guyId = guy.getCustomerId(); + + em.getTransaction().commit(); + + clearCache(); + + Customer newOwen = em.find(Customer.class, owenId); + Customer newKirty = em.find(Customer.class, kirtyId); + Customer newGuy = em.find(Customer.class, guyId); + + assertTrue("Owen has controlled customers .", newOwen.getCCustomers().isEmpty()); + assertFalse("Kirty did not have any controlled customers.", newKirty.getCCustomers().isEmpty()); + assertFalse("Guy did not have any controlled customers.", newGuy.getCCustomers().isEmpty()); + + em.close(); + } + } \ No newline at end of file ================================================================================ Merge Diffs: /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/FullRegressionTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000008/AB0952363AC40CBFE034080020E8C54E.22 Report generated at Fri Sep 29 14:52:00 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/gpelleti/gpelleti_ri_gf796_060927/ade_storage/000008/AB0952363AC40CBFE034080020E8C54E.22 Fri Sep 29 11:34:45 2006 --- /ade/gpelleti_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/FullRegressionTestSuite.java Fri Sep 29 14:39:27 2006 *************** *** 46,51 **** --- 46,52 ---- import oracle.toplink.essentials.testing.tests.cmp3.relationships.EMQueryJUnitTestSuite; import oracle.toplink.essentials.testing.tests.cmp3.relationships.ExpressionJUnitTestSuite; + import oracle.toplink.essentials.testing.tests.cmp3.relationships.UniAndBiDirectionalMappingTestSuite; import oracle.toplink.essentials.testing.tests.cmp3.relationships.VirtualAttributeTestSuite; import oracle.toplink.essentials.testing.tests.cmp3.validation.ValidationTestSuite; *************** *** 107,115 **** fullSuite.addTestSuite(EMQueryJUnitTestSuite.class); fullSuite.addTestSuite(ExpressionJUnitTestSuite.class); fullSuite.addTest(VirtualAttributeTestSuite.suite()); - fullSuite.addTest(ValidationTestSuite.suite()); fullSuite.addTest(QueryParameterValidationTestSuite.suite()); // EJBQL testing model fullSuite.addTest(JUnitEJBQLUnitTestSuite.suite()); --- 108,116 ---- fullSuite.addTestSuite(EMQueryJUnitTestSuite.class); fullSuite.addTestSuite(ExpressionJUnitTestSuite.class); fullSuite.addTest(VirtualAttributeTestSuite.suite()); fullSuite.addTest(ValidationTestSuite.suite()); fullSuite.addTest(QueryParameterValidationTestSuite.suite()); + fullSuite.addTest(UniAndBiDirectionalMappingTestSuite.suite()); // EJBQL testing model fullSuite.addTest(JUnitEJBQLUnitTestSuite.suite());