================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tldev/source/essentials/oracle/toplink/essentials/internal/weaving/TopLinkClassWeaver.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.11 Report generated at Thu Nov 30 17:09:32 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.11 Thu Nov 30 15:22:53 2006 --- /ade/cdelahun_toplinkmain/tldev/source/essentials/oracle/toplink/essentials/internal/weaving/TopLinkClassWeaver.java Thu Nov 30 17:09:32 2006 *************** *** 112,118 **** cv_get_VH.visitVarInsn(ALOAD, 0); // EntityC object = getFoo(); ! cv_get_VH.visitMethodInsn(INVOKEVIRTUAL, classDetails.getClassName(), attributeDetails.getGetterMethodName(), "()L" + attributeDetails.getReferenceClass().replace('.','/') + ";"); cv_get_VH.visitVarInsn(ASTORE, 1); // if (object != _toplink_foo_vh.getValue()){ --- 112,122 ---- cv_get_VH.visitVarInsn(ALOAD, 0); // EntityC object = getFoo(); ! if (attributeDetails.getGetterMethodName() != null){ ! cv_get_VH.visitMethodInsn(INVOKEVIRTUAL, classDetails.getClassName(), attributeDetails.getGetterMethodName(), "()L" + attributeDetails.getReferenceClass().replace('.','/') + ";"); ! } else { ! cv_get_VH.visitMethodInsn(INVOKEVIRTUAL, classDetails.getClassName(), "_toplink_get" + attributeDetails.attributeName, "()L" + attributeDetails.getReferenceClass().replace('.','/') + ";"); ! } cv_get_VH.visitVarInsn(ASTORE, 1); // if (object != _toplink_foo_vh.getValue()){ *************** *** 125,131 **** // setFoo(object); cv_get_VH.visitVarInsn(ALOAD, 0); cv_get_VH.visitVarInsn(ALOAD, 1); ! cv_get_VH.visitMethodInsn(INVOKEVIRTUAL, classDetails.getClassName(), attributeDetails.getSetterMethodName(), "(L" + attributeDetails.getReferenceClass().replace('.','/') + ";)V"); // } cv_get_VH.visitLabel(l1); --- 129,139 ---- // setFoo(object); cv_get_VH.visitVarInsn(ALOAD, 0); cv_get_VH.visitVarInsn(ALOAD, 1); ! if (attributeDetails.getSetterMethodName() != null){ ! cv_get_VH.visitMethodInsn(INVOKEVIRTUAL, classDetails.getClassName(), attributeDetails.getSetterMethodName(), "(L" + attributeDetails.getReferenceClass().replace('.','/') + ";)V"); ! } else { ! cv_get_VH.visitMethodInsn(INVOKEVIRTUAL, classDetails.getClassName(), "_toplink_set" + attributeDetails.getAttributeName(), "(L" + attributeDetails.getReferenceClass().replace('.','/') + ";)V"); ! } // } cv_get_VH.visitLabel(l1); *************** *** 172,178 **** // Object object = getFoo(); cv_set_value.visitVarInsn(ALOAD, 0); ! cv_set_value.visitMethodInsn(INVOKEVIRTUAL, className, attributeDetails.getGetterMethodName(), "()L" + attributeDetails.getReferenceClass().replace('.','/') + ";"); cv_set_value.visitVarInsn(ASTORE, 2); // Object value = valueholderinterface.getValue(); --- 180,190 ---- // Object object = getFoo(); cv_set_value.visitVarInsn(ALOAD, 0); ! if (attributeDetails.getGetterMethodName() != null){ ! cv_set_value.visitMethodInsn(INVOKEVIRTUAL, className, attributeDetails.getGetterMethodName(), "()L" + attributeDetails.getReferenceClass().replace('.','/') + ";"); ! } else { ! cv_set_value.visitMethodInsn(INVOKEVIRTUAL, className, "_toplink_get" + attributeDetails.attributeName, "()L" + attributeDetails.getReferenceClass().replace('.','/') + ";"); ! } cv_set_value.visitVarInsn(ASTORE, 2); // Object value = valueholderinterface.getValue(); *************** *** 189,195 **** cv_set_value.visitVarInsn(ALOAD, 0); cv_set_value.visitVarInsn(ALOAD, 3); cv_set_value.visitTypeInsn(CHECKCAST, attributeDetails.getReferenceClass().replace('.','/')); ! cv_set_value.visitMethodInsn(INVOKEVIRTUAL, className, attributeDetails.getSetterMethodName(), "(L" + attributeDetails.getReferenceClass().replace('.','/') + ";)V"); // } cv_set_value.visitLabel(l0); --- 201,211 ---- cv_set_value.visitVarInsn(ALOAD, 0); cv_set_value.visitVarInsn(ALOAD, 3); cv_set_value.visitTypeInsn(CHECKCAST, attributeDetails.getReferenceClass().replace('.','/')); ! if (attributeDetails.getSetterMethodName() != null){ ! cv_set_value.visitMethodInsn(INVOKEVIRTUAL, className, attributeDetails.getSetterMethodName(), "(L" + attributeDetails.getReferenceClass().replace('.','/') + ";)V"); ! } else { ! cv_set_value.visitMethodInsn(INVOKEVIRTUAL, className, "_toplink_set" + attributeDetails.getAttributeName(), "(L" + attributeDetails.getReferenceClass().replace('.','/') + ";)V"); ! } // } cv_set_value.visitLabel(l0); ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/AllCMP3TestRunModel.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000005/AB0952363AC40CBFE034080020E8C54E.8 Report generated at Thu Nov 30 17:09:33 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000005/AB0952363AC40CBFE034080020E8C54E.8 Thu Nov 30 15:27:01 2006 --- /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/AllCMP3TestRunModel.java Thu Nov 30 17:09:32 2006 *************** *** 20,25 **** --- 20,26 ---- public AllCMP3TestRunModel() { addTest(new oracle.toplink.essentials.testing.tests.cmp3.advanced.CMP3AdvancedTestModel()); addTest(new oracle.toplink.essentials.testing.tests.cmp3.relationships.CMP3RelationshipsTestModel()); + addTest(new oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.CMP3FieldAccessTestModel()); addTest(new oracle.toplink.essentials.testing.tests.cmp3.inheritance.CMP3InheritanceTestModel()); addTest(new oracle.toplink.essentials.testing.tests.cmp3.complexaggregate.CMP3ComplexAggregateTestModel()); addTest(FullRegressionTestSuite.suite()); ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/CMP3FieldAccessTestModel.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000006/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Thu Nov 30 17:09:33 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000006/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:05:21 2006 --- /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/CMP3FieldAccessTestModel.java Thu Nov 30 17:05:20 2006 *************** *** 0 **** --- 1,37 ---- + package oracle.toplink.essentials.testing.tests.cmp3.fieldaccess; + + import oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships.RelationshipsTableManager; + import oracle.toplink.essentials.testing.tests.cmp3.CMP3TestModel; + import oracle.toplink.essentials.testing.framework.JUnitTestCase; + import oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships.ExecuteUpdateTest; + import oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships.GetResultCollectionTest; + import oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships.GetResultListTest; + import oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships.GetSingleResultTest; + import oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships.IsolatedCacheTestSuite; + import oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships.NamedQueryDoesNotExistTest; + import oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships.NamedQueryWithArgumentsTest; + + /** + *

Purpose: To collect the tests that will run using field level annotation. + * Currently the tests contained are a duplicate of the tests in the + * CMP3RelationshipsTestModel. In order for this test model to work correctly the + * EntityContainer must be initialized thought the comandline agent. + */ + public class CMP3FieldAccessTestModel extends CMP3TestModel{ + + public void setup(){ + super.setup(); + RelationshipsTableManager.getCreator().replaceTables(getServerSession()); + } + + public void addTests(){ + addTest(new GetSingleResultTest()); + addTest(new ExecuteUpdateTest()); + addTest(new GetResultCollectionTest()); + addTest(new GetResultListTest()); + addTest(new NamedQueryDoesNotExistTest()); + addTest(new NamedQueryWithArgumentsTest()); + addTests(JUnitTestCase.suite(IsolatedCacheTestSuite.class)); + } + + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/ExecuteUpdateTest.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Thu Nov 30 17:09:33 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:05:25 2006 --- /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/ExecuteUpdateTest.java Thu Nov 30 17:05:24 2006 *************** *** 0 **** --- 1,137 ---- + package oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships; + + import oracle.toplink.essentials.ejb.cmp3.EntityManager; + import oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl; + import oracle.toplink.essentials.queryframework.UpdateAllQuery; + import oracle.toplink.essentials.testing.framework.*; + import javax.persistence.Query; + import oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships.*; + import oracle.toplink.essentials.testing.tests.cmp3.EntityContainerTestBase; + import oracle.toplink.essentials.exceptions.QueryException; + + /* + * Tests for the executeUpdate method on the EJBQueryImpl class + * Also tests bugs 4288845 and 4293920, that params are passed in and used correctly + */ + public class ExecuteUpdateTest extends EntityContainerTestBase { + + //reset gets called twice on error + protected boolean reset = false; + + //used for verification + protected Customer returnedCustomer=null; + public Integer[] cusIDs = new Integer[2]; + + public java.net.URL n=null; + + protected String nameChange1 = "New Name1"; + protected String nameChange2 = "New Name2"; + protected String nameChange3 = "New Name3"; + protected String returnedName1,returnedName2,returnedName3 = null; + protected Exception expectedException =null; + public ExecuteUpdateTest() { + } + + public void setup (){ + super.setup(); + this.reset = true; + + Customer cusClone1 = RelationshipsExamples.customerExample1(); + try { + beginTransaction(); + getEntityManager().persist(cusClone1); + commitTransaction(); + } catch (Exception ex) { + throw new TestException("Unable to setup Test" + ex); + } + ((EntityManagerImpl)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + + cusIDs[0] = cusClone1.getCustomerId(); + + getSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + } + + public void reset (){ + if (reset){//ensures it is only done once + try { + beginTransaction(); + Customer cus1 = (Customer)getEntityManager().find(Customer.class,cusIDs[0]); + getEntityManager().remove(cus1); + commitTransaction(); + reset = false; + }catch (Exception ex) { + throw new TestException("Unable to reset Test" + ex); + } + } + } + + public void test(){ + + try { + beginTransaction(); + Customer cus = (Customer)getEntityManager().find(Customer.class,cusIDs[0]); + Query query = getEntityManager().createQuery("UPDATE FieldAccessCustomer customer SET customer.name = '"+nameChange1+"' WHERE customer.customerId = "+cusIDs[0]); + query.executeUpdate(); + + + ((EntityManagerImpl)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + getSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + //getEntityManager().refresh(cus); + cus = (Customer)getEntityManager().find(Customer.class,cusIDs[0]); + returnedName1 = cus.getName(); + + //tests bug 4288845 + Query query2 = getEntityManager().createQuery("UPDATE FieldAccessCustomer customer SET customer.name = :name WHERE customer.customerId = "+cusIDs[0]); + query2.setParameter("name", nameChange2); + query2.executeUpdate(); + + ((EntityManagerImpl)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + getSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + //getEntityManager().refresh(cus); + cus = (Customer)getEntityManager().find(Customer.class,cusIDs[0]); + returnedName2 = cus.getName(); + + //tests bug 4293920 + Query query3 = getEntityManager().createQuery("UPDATE FieldAccessCustomer customer SET customer.name = :name WHERE customer.customerId = :id"); + query3.setParameter("name", nameChange3); + query3.setParameter("id", cusIDs[0]); + query3.executeUpdate(); + + ((EntityManagerImpl)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + getSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + //getEntityManager().refresh(cus); + cus = (Customer)getEntityManager().find(Customer.class,cusIDs[0]); + returnedName3 = cus.getName(); + + //tests bug 4294241 + try{ + Query query4 = getEntityManager().createNamedQuery("findAllCustomersFieldAccess"); + int someValue = query4.executeUpdate(); + }catch(IllegalStateException expected){ + expectedException=expected; + } + + commitTransaction(); + + } catch (Exception ex) { + try{ + commitTransaction(); + }catch(Exception comitEx){} + throw new TestErrorException("Exception thrown while executing updates" + ex, ex); + } + } + + public void verify(){ + if ( (returnedName1==null || !returnedName1.equals(nameChange1))){ + throw new TestErrorException("Customer name did not get updated correctly should be:"+nameChange1 +" is :"+returnedName1); + } + if ( (returnedName2==null || !returnedName2.equals(nameChange2))){ + throw new TestErrorException("Customer name did not get updated correctly should be:"+nameChange2 +" is :"+returnedName2); + } + if ( (returnedName3==null || !returnedName3.equals(nameChange3))){ + throw new TestErrorException("Customer name did not get updated correctly should be:"+nameChange3 +" is :"+returnedName3); + } + if ( expectedException==null) + throw new TestErrorException("excuteUpdate did not result in an exception on findAllCustomersFieldAccess named ReadAllQuery"); + } + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/GetResultCollectionTest.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000008/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Thu Nov 30 17:09:33 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000008/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:05:28 2006 --- /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/GetResultCollectionTest.java Thu Nov 30 17:05:28 2006 *************** *** 0 **** --- 1,137 ---- + package oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships; + + import java.util.HashMap; + + import oracle.toplink.essentials.exceptions.QueryException; + import oracle.toplink.essentials.internal.ejb.cmp3.EJBQueryImpl; + import oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl; + import oracle.toplink.essentials.internal.queryframework.MapContainerPolicy; + import oracle.toplink.essentials.queryframework.ReadAllQuery; + import oracle.toplink.essentials.queryframework.ReadObjectQuery; + import oracle.toplink.essentials.testing.framework.*; + import oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships.*; + import oracle.toplink.essentials.testing.tests.cmp3.EntityContainerTestBase; + import java.util.Collection; + /* + * Tests using the 'getSingleResult' api on a Query object obtained from the EntityManager + * Also tests bugs 4300879 - check non Collection container policy error + * and 4297903 - check ReadObjectQuery fails + */ + public class GetResultCollectionTest extends EntityContainerTestBase { + + //reset gets called twice on error + protected boolean reset = false; + + //used for verification + protected Customer returnedCustomer=null; + protected Collection returnedCustomers1, returnedCustomers2,returnedCustomers3,returnedCustomers4 = null; + protected QueryException expectedException1,expectedException2 = null; + + protected String searchString = "notAnItemName"; + protected String ejbql1 = "SELECT OBJECT(thecust) FROM FieldAccessCustomer thecust WHERE thecust.customerId = :id"; + + public Integer[] cusIDs = new Integer[3]; + + public GetResultCollectionTest() { + } + + public void setup (){ + super.setup(); + this.reset = true; + + Customer cusClone1 = RelationshipsExamples.customerExample1(); + Customer cusClone2 = RelationshipsExamples.customerExample2(); + try { + beginTransaction(); + getEntityManager().persist(cusClone1); + getEntityManager().persist(cusClone2); + commitTransaction(); + } catch (Exception ex) { + throw new TestException("Unable to setup Test" + ex); + } + ((EntityManagerImpl)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + + cusIDs[0] = cusClone1.getCustomerId(); + cusIDs[1] = cusClone2.getCustomerId(); + + getSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + } + + public void reset (){ + if (reset){//ensures it is only done once + try { + beginTransaction(); + Customer cus1 = (Customer)getEntityManager().find(Customer.class,cusIDs[0]); + getEntityManager().remove(cus1); + Customer cus2 = (Customer)getEntityManager().find(Customer.class,cusIDs[1]); + getEntityManager().remove(cus2); + commitTransaction(); + reset = false; + } catch (Exception ex) { + throw new TestException("Unable to reset Test" + ex); + } + } + } + + public void test(){ + try{ + beginTransaction(); + EntityManagerImpl entityManagerImpl = (EntityManagerImpl)getEntityManager(); + + EJBQueryImpl query1 = (EJBQueryImpl)entityManagerImpl.createNamedQuery("findAllCustomersFieldAccess"); + returnedCustomers1= query1.getResultCollection(); + + EJBQueryImpl query2 = (EJBQueryImpl) entityManagerImpl.createQuery(ejbql1); + query2.setParameter("id",new Integer(-10)); + returnedCustomers2 = query2.getResultCollection(); + + //bug:4297903, check container policy failure + EJBQueryImpl query3 = (EJBQueryImpl) entityManagerImpl.createQuery(ejbql1); + ReadAllQuery readAllQuery = new ReadAllQuery(Customer.class); + MapContainerPolicy mapContainerPolicy = new MapContainerPolicy(); + mapContainerPolicy.setContainerClass(HashMap.class); + mapContainerPolicy.setKeyName("hashCode"); + readAllQuery.setContainerPolicy(mapContainerPolicy); + query3.setDatabaseQuery(readAllQuery); + try{ + returnedCustomers3 = query3.getResultCollection(); + }catch(QueryException exceptionExpected1){//QueryException.INVALID_CONTAINER_CLASS + expectedException1 = exceptionExpected1; + } + + //bug:4300879, check ReadObjectQuery fails + EJBQueryImpl query4 = (EJBQueryImpl) entityManagerImpl.createQuery(ejbql1); + query4.setParameter("id",new Integer(-10)); + ReadObjectQuery readObjectQuery2 = new ReadObjectQuery(Customer.class); + readObjectQuery2.setEJBQLString(ejbql1); + query4.setDatabaseQuery(readObjectQuery2); + try{ + returnedCustomers4 = query4.getResultCollection(); + }catch(QueryException exceptionExpected2){ + expectedException2 = exceptionExpected2; + } + + commitTransaction(); + }catch (Exception unexpectedException){ + try{ + commitTransaction(); + }catch(Exception comitEx){} + throw new TestErrorException("Problem in GetResultCollectionTest: "+unexpectedException); + } + } + + public void verify(){ + if ( returnedCustomers1==null || (returnedCustomers1.size()<2) ){ + throw new TestErrorException("Not all customers were returned from findAllCustomersFieldAccess query "); + } + if ( returnedCustomers2==null || (returnedCustomers2.size()!=0) ){ + throw new TestErrorException("Customer from ReadObjectQuery was not returned using getResultCollection"); + } + if ( expectedException1==null || (expectedException1.getErrorCode()!= QueryException.INVALID_CONTAINER_CLASS)){ + throw new TestErrorException("getResultCollection on query returning a hashtable did not throw expected INVALID_CONTAINER_CLASS QueryException"); + } + if ( expectedException2==null || (expectedException2.getErrorCode()!= QueryException.INCORRECT_QUERY_FOUND)){ + throw new TestErrorException("getResultCollection on ReadObjectQuery did not throw expected INCORRECT_QUERY_FOUND QueryException"); + } + } + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/GetResultListTest.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000009/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Thu Nov 30 17:09:33 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000009/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:05:32 2006 --- /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/GetResultListTest.java Thu Nov 30 17:05:32 2006 *************** *** 0 **** --- 1,95 ---- + package oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships; + + import java.util.HashMap; + import oracle.toplink.essentials.exceptions.QueryException; + import javax.persistence.Query; + import oracle.toplink.essentials.internal.ejb.cmp3.EJBQueryImpl; + import oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl; + import oracle.toplink.essentials.internal.queryframework.MapContainerPolicy; + import oracle.toplink.essentials.queryframework.ReadAllQuery; + import oracle.toplink.essentials.queryframework.ReadObjectQuery; + import oracle.toplink.essentials.testing.framework.*; + import oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships.*; + import java.util.List; + /* + * Tests using the 'getSingleResult' api on a Query object obtained from the EntityManager + * Also tests bugs 4300879 - check non List container policy error + * and 4297903 - check ReadObjectQuery fails + */ + public class GetResultListTest extends GetResultCollectionTest { + + //reset gets called twice on error + protected boolean reset = false; + + //used for verification + protected List returnedCustomers1, returnedCustomers2,returnedCustomers3,returnedCustomers4 = null; + + public Integer[] cusIDs = new Integer[3]; + + public GetResultListTest() { + } + + + public void test(){ + try{ + beginTransaction(); + EntityManagerImpl entityManagerImpl = (EntityManagerImpl)getEntityManager(); + + Query query1 = entityManagerImpl.createNamedQuery("findAllCustomersFieldAccess"); + returnedCustomers1= query1.getResultList(); + + EJBQueryImpl query2 = (EJBQueryImpl) entityManagerImpl.createQuery(ejbql1); + query2.setParameter("id",new Integer(-10)); + returnedCustomers2 = query2.getResultList(); + + //bug:4297903, check container policy failure + EJBQueryImpl query3 = (EJBQueryImpl) entityManagerImpl.createQuery(ejbql1); + ReadAllQuery readAllQuery = new ReadAllQuery(Customer.class); + MapContainerPolicy mapContainerPolicy = new MapContainerPolicy(); + mapContainerPolicy.setContainerClass(HashMap.class); + mapContainerPolicy.setKeyName("hashCode"); + readAllQuery.setContainerPolicy(mapContainerPolicy); + query3.setDatabaseQuery(readAllQuery); + try{ + returnedCustomers3 = query3.getResultList(); + }catch(QueryException exceptionExpected1){//QueryException.INVALID_CONTAINER_CLASS + expectedException1 = exceptionExpected1; + } + + //bug:4300879, check ReadObjectQuery fails + EJBQueryImpl query4 = (EJBQueryImpl) entityManagerImpl.createQuery(ejbql1); + query4.setParameter("id",new Integer(-10)); + ReadObjectQuery readObjectQuery2 = new ReadObjectQuery(Customer.class); + readObjectQuery2.setEJBQLString(ejbql1); + query4.setDatabaseQuery(readObjectQuery2); + try{ + returnedCustomers4 = query4.getResultList(); + }catch(QueryException exceptionExpected2){ + expectedException2 = exceptionExpected2; + } + + commitTransaction(); + }catch (Exception unexpectedException){ + try{ + commitTransaction(); + }catch(Exception comitEx){} + throw new TestErrorException("Problem in GetResultListTest: "+unexpectedException); + } + } + + public void verify(){ + if ( returnedCustomers1==null || (returnedCustomers1.size()<2) ){ + throw new TestErrorException("Not all customers were returned from findAllCustomersFieldAccess query "); + } + if ( returnedCustomers2==null || (returnedCustomers2.size()!=0) ){ + throw new TestErrorException("Customer from ReadObjectQuery was not returned using getResultList"); + } + if ( expectedException1==null || (expectedException1.getErrorCode()!= QueryException.INVALID_CONTAINER_CLASS)){ + throw new TestErrorException("getResultList on query returning a hashtable did not throw expected INVALID_CONTAINER_CLASS QueryException"); + } + if ( expectedException2==null || (expectedException2.getErrorCode()!= QueryException.INCORRECT_QUERY_FOUND)){ + throw new TestErrorException("getResultList on ReadObjectQuery did not throw expected INCORRECT_QUERY_FOUNDQueryException"); + } + } + + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/GetSingleResultTest.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000010/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Thu Nov 30 17:09:33 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000010/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:05:36 2006 --- /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/GetSingleResultTest.java Thu Nov 30 17:05:35 2006 *************** *** 0 **** --- 1,148 ---- + package oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships; + + import java.util.HashMap; + import javax.persistence.NoResultException; + import javax.persistence.NonUniqueResultException; + import javax.persistence.Query; + import oracle.toplink.essentials.exceptions.QueryException; + import oracle.toplink.essentials.internal.ejb.cmp3.EJBQueryImpl; + import oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl; + import oracle.toplink.essentials.internal.queryframework.MapContainerPolicy; + import oracle.toplink.essentials.queryframework.ReadAllQuery; + import oracle.toplink.essentials.queryframework.ReadObjectQuery; + import oracle.toplink.essentials.testing.framework.*; + import oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships.*; + import oracle.toplink.essentials.testing.tests.cmp3.EntityContainerTestBase; + /* + * Tests using the 'getSingleResult' api on a Query object obtained from the EntityManager + * Tests fixes for bugs 4202835 and 4301674 + * + * modified for changes in bug:4628215 (EntityNotFoundException) + * EntityNotFoundException changed to NoResultException as per new spec + */ + public class GetSingleResultTest extends EntityContainerTestBase { + + //reset gets called twice on error + protected boolean reset = false; + + //used for verification + protected Customer returnedCustomer1,returnedCustomer2=null; + protected NonUniqueResultException expectedException1 = null; + protected NoResultException expectedException2 = null; + protected QueryException expectedException3 = null; + + protected String searchString = "notAnItemName"; + + public Integer[] cusIDs = new Integer[3]; + + public GetSingleResultTest() { + } + + public void setup (){ + super.setup(); + this.reset = true; + + Customer cusClone1 = RelationshipsExamples.customerExample1(); + Customer cusClone2 = RelationshipsExamples.customerExample2(); + try { + beginTransaction(); + getEntityManager().persist(cusClone1); + getEntityManager().persist(cusClone2); + commitTransaction(); + } catch (Exception ex) { + throw new TestException("Unable to setup Test" + ex); + } + ((EntityManagerImpl)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + + cusIDs[0] = cusClone1.getCustomerId(); + cusIDs[1] = cusClone2.getCustomerId(); + + getSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + } + + public void reset (){ + if (reset){//ensures it is only done once + try { + beginTransaction(); + Customer cus1 = (Customer)getEntityManager().find(Customer.class,cusIDs[0]); + getEntityManager().remove(cus1); + Customer cus2 = (Customer)getEntityManager().find(Customer.class,cusIDs[1]); + getEntityManager().remove(cus2); + commitTransaction(); + reset = false; + } catch (Exception ex) { + throw new TestException("Unable to reset Test" + ex); + } + } + } + + public void test(){ + try{ + beginTransaction(); + try { + returnedCustomer1 = (Customer)getEntityManager().createNamedQuery("findAllCustomersFieldAccess").getSingleResult(); + } catch (NonUniqueResultException exceptionExpected1) { + expectedException1 =exceptionExpected1; + } + try { + //should be no Items to find, which should cause an NoResultException + Query query1 = getEntityManager().createNamedQuery("findAllItemsByName"); + Item item =(Item)query1.setParameter(1, searchString).getSingleResult(); + } catch (NoResultException exceptionExpected2) { + expectedException2 =exceptionExpected2; + } + //bug 4301674 test + EJBQueryImpl query2 = (EJBQueryImpl) getEntityManager().createNamedQuery("findAllCustomersFieldAccess"); + ReadAllQuery readAllQuery = new ReadAllQuery(Customer.class); + MapContainerPolicy mapContainerPolicy = new MapContainerPolicy(); + mapContainerPolicy.setContainerClass(HashMap.class); + mapContainerPolicy.setKeyName("hashCode"); + readAllQuery.setContainerPolicy(mapContainerPolicy); + query2.setDatabaseQuery(readAllQuery); + try{ + returnedCustomer1 = (Customer)query2.getSingleResult(); + }catch(QueryException exceptionExpected3){//QueryException.INVALID_CONTAINER_CLASS + expectedException3 = exceptionExpected3; + } + + //check for single result found. + Query query3 = getEntityManager().createQuery("SELECT OBJECT(thecust) FROM FieldAccessCustomer thecust WHERE thecust.customerId = :id"); + returnedCustomer1 = (Customer)query3.setParameter("id", cusIDs[0]).getSingleResult(); + + + //check for single result using a ReadObjectQuery (tests previous fix for 4202835) + EJBQueryImpl query4 = (EJBQueryImpl)getEntityManager().createQuery("SELECT OBJECT(thecust) FROM FieldAccessCustomer thecust WHERE thecust.customerId = :id"); + query4.setParameter("id", cusIDs[0]); + ReadObjectQuery readObjectQuery = new ReadObjectQuery(Customer.class); + readObjectQuery.setEJBQLString("SELECT OBJECT(thecust) FROM FieldAccessCustomer thecust WHERE thecust.customerId = :id"); + query4.setDatabaseQuery(readObjectQuery); + returnedCustomer2 = (Customer)query4.getSingleResult(); + + commitTransaction(); + }catch (Exception unexpectedException){ + try{ + commitTransaction(); + }catch(Exception comitEx){} + throw new TestErrorException("Problem in GetSingleResultTest: "+unexpectedException); + } + } + + public void verify(){ + if ( expectedException1==null ){ + throw new TestErrorException("getSingelResult on query returning multiple values did not throw a NonUniqueResultException"); + } + if ( expectedException2==null ){ + throw new TestErrorException("getSingelResult on query returning multiple values did not throw an NoResultException"); + } + if ( ( expectedException3==null ) || ( expectedException3.getErrorCode()!= QueryException.INVALID_CONTAINER_CLASS ) ){ + throw new TestErrorException("getSingelResult using ReadAllQuery with MapContainerPolicy did not throw expected INVALID_CONTAINER_CLASS QueryException"); + } + if ( returnedCustomer1==null || (!returnedCustomer1.getCustomerId().equals(cusIDs[0])) ){ + throw new TestErrorException("Incorrect Single Customer returned, found: "+returnedCustomer1); + } + if ( returnedCustomer2==null || (!returnedCustomer2.getCustomerId().equals(cusIDs[0])) ){ + throw new TestErrorException("Incorrect Single Customer returned, found: "+returnedCustomer2); + } + } + + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/NamedQueryDoesNotExistTest.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000011/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Thu Nov 30 17:09:33 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000011/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:05:40 2006 --- /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/NamedQueryDoesNotExistTest.java Thu Nov 30 17:05:39 2006 *************** *** 0 **** --- 1,58 ---- + package oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships; + + import oracle.toplink.essentials.testing.framework.*; + import oracle.toplink.essentials.testing.tests.cmp3.EntityContainerTestBase; + + /** + * Tests trying to execute a named query that does not exist. + * + * @author Guy Pelletier + */ + public class NamedQueryDoesNotExistTest extends EntityContainerTestBase { + protected boolean m_reset = false; // reset gets called twice on error + + protected Exception m_exception; + protected boolean m_npeCaught; + protected boolean m_illegalArgumentExceptionCaught; + + public NamedQueryDoesNotExistTest() { + setDescription("Looks for an expected exception when running a named query that does not exist."); + } + + public void setup (){ + super.setup(); + m_reset = true; + m_npeCaught = false; + m_illegalArgumentExceptionCaught = false; + } + + public void reset (){ + if (m_reset) { //ensures it is only done once + m_reset = false; + } + } + + public void test(){ + try { + getEntityManager().createNamedQuery("doesNotExist").getResultList(); + } catch (NullPointerException e) { + m_npeCaught = true; + } catch (IllegalArgumentException e) { + m_illegalArgumentExceptionCaught = true; + } catch (Exception e) { + m_exception = e; + } + } + + public void verify(){ + if (m_npeCaught) { + throw new TestErrorException("A null pointer exception caught on the query."); + } else if (!m_illegalArgumentExceptionCaught) { + if (m_exception != null) { + throw new TestErrorException("Expected IllegalArgumentException, caught: " + m_exception); + } else { + throw new TestErrorException("No exception was caught on a named query that does not exist."); + } + } + } + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/NamedQueryWithArgumentsTest.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000012/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Thu Nov 30 17:09:33 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000012/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:05:43 2006 --- /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/NamedQueryWithArgumentsTest.java Thu Nov 30 17:05:43 2006 *************** *** 0 **** --- 1,83 ---- + package oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships; + + import java.util.List; + import java.util.Vector; + + import oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl; + import oracle.toplink.essentials.testing.framework.*; + import oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships.*; + import oracle.toplink.essentials.testing.tests.cmp3.EntityContainerTestBase; + import oracle.toplink.essentials.threetier.ServerSession; + + //Bug#4646580 Query arguments are added in EJBQL + public class NamedQueryWithArgumentsTest extends EntityContainerTestBase { + + public Integer[] cusIDs = new Integer[3]; + public Integer[] orderIDs = new Integer[3]; + public Integer[] itemIDs = new Integer[3]; + Exception exception; + List list; + + public NamedQueryWithArgumentsTest() { + setDescription("Named query with arguments can be executed through Session's executeQuery(String queryName, Vector argumentValues)."); + } + + public void setup (){ + super.setup(); + + Customer cusClone1 = RelationshipsExamples.customerExample1(); + Item item1 = RelationshipsExamples.itemExample1(); + Order order1 = RelationshipsExamples.orderExample1(); + order1.setCustomer(cusClone1); + order1.setItem(item1); + + try { + beginTransaction(); + getEntityManager().persist(cusClone1); + getEntityManager().persist(order1); + commitTransaction(); + } catch (Exception ex) { + throw new TestException("Unable to setup Test" + ex); + } + cusIDs[0] = cusClone1.getCustomerId(); + orderIDs[0] = order1.getOrderId(); + itemIDs[0] = item1.getItemId(); + + getSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + } + + public void reset (){ + try { + beginTransaction(); + Customer cus1 = (Customer)getEntityManager().find(Customer.class, cusIDs[0]); + getEntityManager().remove(cus1); + Order ord1 = (Order)getEntityManager().find(Order.class, orderIDs[0]); + getEntityManager().remove(ord1); + Item it1 = (Item)getEntityManager().find(Item.class, itemIDs[0]); + getEntityManager().remove(it1); + commitTransaction(); + } catch (Exception ex) { + throw new TestException("Unable to reset Test" + ex); + } + } + + public void test(){ + try { + ServerSession ss = ((EntityManagerImpl)getEntityManager()).getServerSession(); + Vector vec = new Vector(); + vec.add(itemIDs[0]); + list = (List)ss.executeQuery("findAllFieldAccessOrdersByItem", vec); + } catch (Exception ex) { + exception = ex; + } + } + + public void verify(){ + if (exception != null) { + throw new TestErrorException("An exception is thrown: " + exception); + } + if (list.size() != 1) { + throw new TestErrorException("One order is expected but " + list.size() + " was returned"); + } + } + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/Customer.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000016/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Thu Nov 30 17:09:33 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000016/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:05:47 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/Customer.java Thu Nov 30 17:05:46 2006 *************** *** 0 **** --- 1,133 ---- + /* + * 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.models.cmp3.fieldaccess.relationships; + + import java.util.Vector; + import java.util.HashSet; + import java.util.Collection; + import javax.persistence.*; + import static javax.persistence.GenerationType.*; + import static javax.persistence.CascadeType.*; + + @Entity(name="FieldAccessCustomer") + @Table(name="CMP3_FIELDACCESS_CUSTOMER") + @NamedQuery( + name="findAllCustomersFieldAccess", + query="SELECT OBJECT(thecust) FROM FieldAccessCustomer thecust" + ) + @NamedNativeQueries(value={ + @NamedNativeQuery(name="findAllSQLCustomersFieldAccess", + query="select * from CMP3_FIELDACCESS_CUSTOMER"), + @NamedNativeQuery(name="insertCustomer1111SQLFieldAccess", + query="INSERT INTO CMP3_FIELDACCESS_CUSTOMER (CUST_ID, NAME, CITY, CUST_VERSION) VALUES (1111, NULL, NULL, 1)"), + @NamedNativeQuery(name="deleteCustomer1111SQLFieldAccess", + query="DELETE FROM CMP3_FIELDACCESS_CUSTOMER WHERE (CUST_ID=1111)")}) + public class Customer implements java.io.Serializable{ + @Id + @GeneratedValue(strategy=TABLE, generator="FIELDACCESS_CUSTOMER_TABLE_GENERATOR") + @TableGenerator( + name="FIELDACCESS_CUSTOMER_GENERATOR_TABLE", + table="CMP3_FIELDACCESS_CUSTOMER_SEQ", + pkColumnName="SEQ_NAME", + valueColumnName="SEQ_COUNT", + pkColumnValue="CUST_SEQ" + ) + @Column(name="CUST_ID") + private Integer customerId; + @Version + @Column(name="CUST_VERSION") + private int version; + private String city; + private String name; + @OneToMany(cascade=ALL, mappedBy="customer") + private Collection orders = new HashSet(); + @ManyToMany + @JoinTable(name="CMP3_FIELDACCESS_CUST_CUST") + private Collection controlledCustomers = new HashSet(); + + public Customer() {} + + public Integer getCustomerId() { + return customerId; + } + + public void setCustomerId(Integer id) { + this.customerId = id; + } + + public int getVersion() { + return version; + } + + protected void setVersion(int version) { + this.version = version; + } + + public String getCity() { + return city; + } + + public void setCity(String aCity) { + this.city = aCity; + } + + public String getName() { + return name; + } + + public void setName(String aName) { + this.name = aName; + } + + public Collection getOrders() { + return orders; + } + + public void setOrders(Collection newValue) { + this.orders = newValue; + } + + public void addOrder(Order anOrder) { + getOrders().add(anOrder); + anOrder.setCustomer(this); + } + + public void removeOrder(Order anOrder) { + getOrders().remove(anOrder); + } + + 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/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/CustomerDetails.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000017/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Thu Nov 30 17:09:33 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000017/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:05:51 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/CustomerDetails.java Thu Nov 30 17:05:50 2006 *************** *** 0 **** --- 1,17 ---- + package oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships; + + public class CustomerDetails + { + private Integer custId; + private int orderCount; + + public CustomerDetails() + { + } + + public CustomerDetails(Integer custId, int orderCount) + { + this.custId = custId; + this.orderCount = orderCount; + } + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/IsolatedItem.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000018/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Thu Nov 30 17:09:33 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000018/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:05:54 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/IsolatedItem.java Thu Nov 30 17:05:54 2006 *************** *** 0 **** --- 1,69 ---- + /* + * 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.models.cmp3.fieldaccess.relationships; + + import javax.persistence.*; + import static javax.persistence.GenerationType.*; + + @Entity(name="FieldAccessIsolatedItem") + @Table(name="CMP3_FIELDACCESS_ISOLATED_ITEM") + public class IsolatedItem implements java.io.Serializable { + @Id + @GeneratedValue(strategy=TABLE, generator="FIELDACCESS_ISOLATED_ITEM_TABLE_GENERATOR") + @TableGenerator( + name="FIELDACCESS_ISOLATED_ITEM_TABLE_GENERATOR", + table="CMP3_FIELDACCESS_CUSTOMER_SEQ", + pkColumnName="SEQ_NAME", + valueColumnName="SEQ_COUNT", + pkColumnValue="ISOLATED_ITEM_SEQ" + ) + @Column(name="ID") + private Integer itemId; + private String name; + private String description; + + public IsolatedItem() {} + + public Integer getItemId() { + return itemId; + } + + public void setItemId(Integer id) { + this.itemId = id; + } + + public String getDescription() { + return description; + } + + public void setDescription(String desc) { + this.description = desc; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/Item.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000019/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Thu Nov 30 17:09:33 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000019/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:06:08 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/Item.java Thu Nov 30 17:06:08 2006 *************** *** 0 **** --- 1,84 ---- + /* + * 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.models.cmp3.fieldaccess.relationships; + + import javax.persistence.*; + import static javax.persistence.GenerationType.*; + + @Entity(name="FieldAccessItem") + @Table(name="CMP3_FIELDACCESS_ITEM") + @NamedQuery( + name="findAllItemsByName", + query="SELECT OBJECT(item) FROM FieldAccessItem item WHERE item.name = ?1" + ) + public class Item implements java.io.Serializable { + @Id + @GeneratedValue(strategy=TABLE, generator="FIELDACCESS_ITEM_TABLE_GENERATOR") + @TableGenerator( + name="FIELDACCESS_ITEM_TABLE_GENERATOR", + table="CMP3_FIELDACCESS_CUSTOMER_SEQ", + pkColumnName="SEQ_NAME", + valueColumnName="SEQ_COUNT", + pkColumnValue="ITEM_SEQ" + ) + @Column(name="ID") + private Integer itemId; + @Version + @Column(name="ITEM_VERSION") + private int version; + private String name; + private String description; + + public Item() {} + + public Integer getItemId() { + return itemId; + } + + public void setItemId(Integer id) { + this.itemId = id; + } + + protected int getVersion() { + return version; + } + + protected void setVersion(int version) { + this.version = version; + } + + public String getDescription() { + return description; + } + + public void setDescription(String desc) { + this.description = desc; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/Order.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000020/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Thu Nov 30 17:09:33 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000020/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:06:12 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/Order.java Thu Nov 30 17:06:11 2006 *************** *** 0 **** --- 1,127 ---- + /* + * 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.models.cmp3.fieldaccess.relationships; + + import javax.persistence.*; + import static javax.persistence.GenerationType.*; + import static javax.persistence.CascadeType.*; + import static javax.persistence.FetchType.*; + + @Entity(name="FieldAccessOrderBean") + @Table(name="CMP3_FIELDACCESS_ORDER") + @NamedQuery( + name="findAllFieldAccessOrdersByItem", + query="SELECT OBJECT(theorder) FROM FieldAccessOrderBean theorder WHERE theorder.item.itemId = :id" + ) + public class Order implements java.io.Serializable { + @Id + @GeneratedValue(strategy=TABLE, generator="FIELDACCESS_ORDER_TABLE_GENERATOR") + @TableGenerator( + name="FIELDACCESS_ORDER_TABLE_GENERATOR", + table="CMP3_FIELDACCESS_CUSTOMER_SEQ", + pkColumnName="SEQ_NAME", + valueColumnName="SEQ_COUNT", + pkColumnValue="ORDER_SEQ" + ) + @Column(name="ORDER_ID") + private Integer orderId; + @Version + @Column(name="ORDER_VERSION") + private int version; + @OneToOne(cascade=PERSIST, fetch=LAZY) + private Item item; + private int quantity; + @Column(name="SHIP_ADDR") + private String shippingAddress; + @ManyToOne(fetch=LAZY) + private Customer customer; + @ManyToOne(fetch=LAZY) + private Customer billedCustomer; + @ManyToOne(fetch=LAZY) + private SalesPerson salesPerson; + + public Order() {} + + public Integer getOrderId() { + return orderId; + } + + public void setOrderId(Integer id) { + this.orderId = id; + } + + protected int getVersion() { + return version; + } + + protected void setVersion(int version) { + this.version = version; + } + + public Item getItem() { + return item; + } + + public void setItem(Item item) { + this.item = item; + } + + public int getQuantity() { + return quantity; + } + + public void setQuantity(int quantity) { + this.quantity = quantity; + } + + public String getShippingAddress() { + return shippingAddress; + } + + public void setShippingAddress(String shippingAddress) { + this.shippingAddress = shippingAddress; + } + + public Customer getCustomer() { + return customer; + } + + public void setCustomer(Customer customer) { + this.customer = customer; + } + + public Customer getBilledCustomer() { + return billedCustomer; + } + + public void setBilledCustomer(Customer billedCustomer) { + this.billedCustomer = billedCustomer; + } + + public SalesPerson getSalesPerson() { + return salesPerson; + } + + public void setSalesPerson(SalesPerson salesPerson) { + this.salesPerson = salesPerson; + } + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/RelationshipsExamples.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000021/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Thu Nov 30 17:09:33 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000021/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:06:16 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/RelationshipsExamples.java Thu Nov 30 17:06:15 2006 *************** *** 0 **** --- 1,190 ---- + /* + * 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.models.cmp3.fieldaccess.relationships; + import java.util.Vector; + import oracle.toplink.essentials.sessions.Session; + import oracle.toplink.essentials.sessions.UnitOfWork; + import oracle.toplink.essentials.tools.schemaframework.PopulationManager; + + public class RelationshipsExamples + { + private PopulationManager populationManager; + + public RelationshipsExamples() + { + this.populationManager = PopulationManager.getDefaultManager(); + } + + public void buildExamples(Session session) + { + PopulationManager.getDefaultManager().getRegisteredObjects().remove(Order.class); + PopulationManager.getDefaultManager().getRegisteredObjects().remove(Customer.class); + PopulationManager.getDefaultManager().getRegisteredObjects().remove(Item.class); + PopulationManager.getDefaultManager().getRegisteredObjects().remove(SalesPerson.class); + + Vector allObjects = new Vector(); + Order orderExample1 = orderExample1(); + Customer customerExample1 = customerExample1(); + Customer customerExample2 = customerExample2(); + SalesPerson salesPerson1 = salesPersonExample1(); + + /* + * Set relationships: + * Order1 has customer1 as the billed customer + * Order1 has customer2 as the customer + * OrdersList contains Order1 and is set as customer2's orders + * SalesPerson1 is set as salesPerson to Order1 + */ + orderExample1.setBilledCustomer(customerExample1); + orderExample1.setCustomer(customerExample2); + Vector ordersList = new Vector(); + ordersList.add(orderExample1); + customerExample2.setOrders(ordersList); + orderExample1.setSalesPerson(salesPerson1); + + Order orderExample2 = orderExample2(); + Customer customerExample3 = customerExample3(); + Customer customerExample4 = customerExample4(); + SalesPerson salesPerson2 = salesPersonExample2(); + /* + * Set relationships: + * Order2 has customer3 as the billed customer + * Order2 has customer4 as the customer + * Order2 is added to the OrdersList and is set as customer2's orders + * SalesPerson2 is set as salesPerson to Order2 + */ + orderExample2.setBilledCustomer(customerExample3); + orderExample2.setCustomer(customerExample4); + ordersList.add(orderExample2); + customerExample4.setOrders(ordersList); + orderExample2.setSalesPerson(salesPerson2); + + + allObjects.add(customerExample1); + allObjects.add(customerExample2); + allObjects.add(orderExample1); + allObjects.add(customerExample3); + allObjects.add(customerExample4); + allObjects.add(orderExample2); + + allObjects.add(itemExample1()); + allObjects.add(itemExample2()); + allObjects.add(itemExample3()); + allObjects.add(itemExample4()); + + allObjects.add(orderExample3()); + allObjects.add(orderExample4()); + allObjects.add(salesPerson1); + allObjects.add(salesPerson2); + + UnitOfWork unitOfWork = session.acquireUnitOfWork(); + unitOfWork.registerAllObjects(allObjects); + unitOfWork.commit(); + } + + public static Customer customerExample1(){ + Customer customer1 = new Customer(); + customer1.setName("John Smith"); + customer1.setCity("Ottawa"); + return customer1; + } + public static Customer customerExample2(){ + Customer customer2 = new Customer(); + customer2.setName("Jane Smith"); + customer2.setCity("Orleans"); + return customer2; + } + public static Customer customerExample3(){ + Customer customer3 = new Customer(); + customer3.setName("Karen McDonald"); + customer3.setCity("Nepean"); + return customer3; + } + public static Customer customerExample4(){ + Customer customer4 = new Customer(); + customer4.setName("Robert Sampson"); + customer4.setCity("Manotick"); + return customer4; + } + public static Item itemExample1(){ + Item item = new Item(); + item.setName("item1"); + item.setDescription("Item1 description"); + return item; + } + public static Item itemExample2(){ + Item item = new Item(); + item.setName("item2"); + item.setDescription("Item2 description"); + return item; + } + public static Item itemExample3(){ + Item item = new Item(); + item.setName("item3"); + item.setDescription("Item3 description"); + return item; + } + public static Item itemExample4(){ + Item item = new Item(); + item.setName("item4"); + item.setDescription("Item4 description"); + return item; + } + public static Order orderExample1(){ + Order order = new Order(); + order.setQuantity(70); + order.setShippingAddress("100 Argyle Street"); + return order; + } + public static Order orderExample2(){ + Order order = new Order(); + order.setQuantity(680); + order.setShippingAddress("500 Oracle Parkway"); + return order; + } + public static Order orderExample3(){ + Order order = new Order(); + order.setQuantity(22); + order.setShippingAddress("240 Queen Street"); + return order; + } + public static Order orderExample4(){ + Order order = new Order(); + order.setQuantity(1); + order.setShippingAddress("50 O'Connor"); + return order; + } + + public static SalesPerson salesPersonExample1(){ + SalesPerson salesPerson = new SalesPerson(); + salesPerson.setName("Sales Person 1"); + return salesPerson; + } + + public static SalesPerson salesPersonExample2(){ + SalesPerson salesPerson = new SalesPerson(); + salesPerson.setName("Sales Person 2"); + return salesPerson; + } + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/RelationshipsTableManager.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000022/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Thu Nov 30 17:09:33 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000022/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:06:19 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/RelationshipsTableManager.java Thu Nov 30 17:06:19 2006 *************** *** 0 **** --- 1,373 ---- + /* + * 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.models.cmp3.fieldaccess.relationships; + + import oracle.toplink.essentials.tools.schemaframework.FieldDefinition; + import oracle.toplink.essentials.tools.schemaframework.TableCreator; + import oracle.toplink.essentials.tools.schemaframework.TableDefinition; + + public class RelationshipsTableManager extends TableCreator { + + public static TableCreator tableCreator; + + public RelationshipsTableManager() { + setName("Relationships"); + addTableDefinition(buildCMP3_CUSTOMERTable()); + addTableDefinition(buildCMP3_ITEMTable()); + addTableDefinition(buildCMP3_ISOLATEDITEMTable()); + addTableDefinition(buildCMP3_ORDERTable()); + addTableDefinition(buildCMP3_ORDER_SEQTable()); + addTableDefinition(buildCMP3_SALESPERSONTable()); + addTableDefinition(buildCUSTOMER_CUSTOMERTable()); + } + + public static TableCreator getCreator(){ + if (RelationshipsTableManager.tableCreator == null){ + RelationshipsTableManager.tableCreator = new RelationshipsTableManager(); + } + return RelationshipsTableManager.tableCreator; + } + + public static TableDefinition buildCMP3_CUSTOMERTable() { + TableDefinition table = new TableDefinition(); + table.setName("CMP3_FIELDACCESS_CUSTOMER"); + + FieldDefinition fieldCITY = new FieldDefinition(); + fieldCITY.setName("CITY"); + fieldCITY.setTypeName("VARCHAR2"); + fieldCITY.setSize(80); + fieldCITY.setSubSize(0); + fieldCITY.setIsPrimaryKey(false); + fieldCITY.setIsIdentity(false); + fieldCITY.setUnique(false); + fieldCITY.setShouldAllowNull(true); + table.addField(fieldCITY); + + FieldDefinition fieldCUST_ID = new FieldDefinition(); + fieldCUST_ID.setName("CUST_ID"); + fieldCUST_ID.setTypeName("NUMBER"); + fieldCUST_ID.setSize(15); + fieldCUST_ID.setSubSize(0); + fieldCUST_ID.setIsPrimaryKey(true); + fieldCUST_ID.setIsIdentity(false); + fieldCUST_ID.setUnique(false); + fieldCUST_ID.setShouldAllowNull(false); + table.addField(fieldCUST_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); + + FieldDefinition field10 = new FieldDefinition(); + field10.setName("CUST_VERSION"); + field10.setTypeName("NUMERIC"); + field10.setSize(15); + field10.setShouldAllowNull(true ); + field10.setIsPrimaryKey(false ); + field10.setUnique(false ); + field10.setIsIdentity(false ); + table.addField(field10); + + return table; + } + + public static TableDefinition buildCMP3_ISOLATEDITEMTable() { + TableDefinition table = new TableDefinition(); + table.setName("CMP3_FIELDACCESS_ISOLATED_ITEM"); + + FieldDefinition fieldDESCRIPTION = new FieldDefinition(); + fieldDESCRIPTION.setName("DESCRIPTION"); + fieldDESCRIPTION.setTypeName("VARCHAR2"); + fieldDESCRIPTION.setSize(80); + fieldDESCRIPTION.setSubSize(0); + fieldDESCRIPTION.setIsPrimaryKey(false); + fieldDESCRIPTION.setIsIdentity(false); + fieldDESCRIPTION.setUnique(false); + fieldDESCRIPTION.setShouldAllowNull(true); + table.addField(fieldDESCRIPTION); + + FieldDefinition fieldITEM_ID = new FieldDefinition(); + fieldITEM_ID.setName("ID"); + fieldITEM_ID.setTypeName("NUMBER"); + fieldITEM_ID.setSize(15); + fieldITEM_ID.setSubSize(0); + fieldITEM_ID.setIsPrimaryKey(true); + fieldITEM_ID.setIsIdentity(false); + fieldITEM_ID.setUnique(false); + fieldITEM_ID.setShouldAllowNull(false); + table.addField(fieldITEM_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 buildCMP3_ITEMTable() { + TableDefinition table = new TableDefinition(); + table.setName("CMP3_FIELDACCESS_ITEM"); + + FieldDefinition fieldDESCRIPTION = new FieldDefinition(); + fieldDESCRIPTION.setName("DESCRIPTION"); + fieldDESCRIPTION.setTypeName("VARCHAR2"); + fieldDESCRIPTION.setSize(80); + fieldDESCRIPTION.setSubSize(0); + fieldDESCRIPTION.setIsPrimaryKey(false); + fieldDESCRIPTION.setIsIdentity(false); + fieldDESCRIPTION.setUnique(false); + fieldDESCRIPTION.setShouldAllowNull(true); + table.addField(fieldDESCRIPTION); + + FieldDefinition fieldITEM_ID = new FieldDefinition(); + fieldITEM_ID.setName("ID"); + fieldITEM_ID.setTypeName("NUMBER"); + fieldITEM_ID.setSize(15); + fieldITEM_ID.setSubSize(0); + fieldITEM_ID.setIsPrimaryKey(true); + fieldITEM_ID.setIsIdentity(false); + fieldITEM_ID.setUnique(false); + fieldITEM_ID.setShouldAllowNull(false); + table.addField(fieldITEM_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); + + FieldDefinition field10 = new FieldDefinition(); + field10.setName("ITEM_VERSION"); + field10.setTypeName("NUMERIC"); + field10.setSize(15); + field10.setShouldAllowNull(true ); + field10.setIsPrimaryKey(false ); + field10.setUnique(false ); + field10.setIsIdentity(false ); + table.addField(field10); + + return table; + } + + public static TableDefinition buildCMP3_ORDERTable() { + TableDefinition table = new TableDefinition(); + table.setName("CMP3_FIELDACCESS_ORDER"); + + FieldDefinition fieldCUST_ID = new FieldDefinition(); + fieldCUST_ID.setName("CUSTOMER_CUST_ID"); + fieldCUST_ID.setTypeName("NUMBER"); + fieldCUST_ID.setSize(15); + fieldCUST_ID.setSubSize(0); + fieldCUST_ID.setIsPrimaryKey(false); + fieldCUST_ID.setIsIdentity(false); + fieldCUST_ID.setUnique(false); + fieldCUST_ID.setShouldAllowNull(true); + table.addField(fieldCUST_ID); + + FieldDefinition fieldBILLED_CUST_ID = new FieldDefinition(); + fieldBILLED_CUST_ID.setName("BILLEDCUSTOMER_CUST_ID"); + fieldBILLED_CUST_ID.setTypeName("NUMBER"); + fieldBILLED_CUST_ID.setSize(15); + fieldBILLED_CUST_ID.setSubSize(0); + fieldBILLED_CUST_ID.setIsPrimaryKey(false); + fieldBILLED_CUST_ID.setIsIdentity(false); + fieldBILLED_CUST_ID.setUnique(false); + fieldBILLED_CUST_ID.setShouldAllowNull(true); + table.addField(fieldBILLED_CUST_ID); + + FieldDefinition fieldSALESPERSON_ID = new FieldDefinition(); + fieldSALESPERSON_ID.setName("SALESPERSON_ID"); + fieldSALESPERSON_ID.setTypeName("NUMBER"); + fieldSALESPERSON_ID.setSize(15); + fieldSALESPERSON_ID.setSubSize(0); + fieldSALESPERSON_ID.setIsPrimaryKey(false); + fieldSALESPERSON_ID.setIsIdentity(false); + fieldSALESPERSON_ID.setUnique(false); + fieldSALESPERSON_ID.setShouldAllowNull(true); + table.addField(fieldSALESPERSON_ID); + + FieldDefinition fieldITEM_ID = new FieldDefinition(); + fieldITEM_ID.setName("ITEM_ID"); + fieldITEM_ID.setTypeName("NUMBER"); + fieldITEM_ID.setSize(15); + fieldITEM_ID.setSubSize(0); + fieldITEM_ID.setIsPrimaryKey(false); + fieldITEM_ID.setIsIdentity(false); + fieldITEM_ID.setUnique(false); + fieldITEM_ID.setShouldAllowNull(true); + table.addField(fieldITEM_ID); + + FieldDefinition fieldORDER_ID = new FieldDefinition(); + fieldORDER_ID.setName("ORDER_ID"); + fieldORDER_ID.setTypeName("NUMBER"); + fieldORDER_ID.setSize(15); + fieldORDER_ID.setSubSize(0); + fieldORDER_ID.setIsPrimaryKey(true); + fieldORDER_ID.setIsIdentity(false); + fieldORDER_ID.setUnique(false); + fieldORDER_ID.setShouldAllowNull(false); + table.addField(fieldORDER_ID); + + FieldDefinition fieldQUANTITY = new FieldDefinition(); + fieldQUANTITY.setName("QUANTITY"); + fieldQUANTITY.setTypeName("NUMBER"); + fieldQUANTITY.setSize(15); + fieldQUANTITY.setSubSize(0); + fieldQUANTITY.setIsPrimaryKey(false); + fieldQUANTITY.setIsIdentity(false); + fieldQUANTITY.setUnique(false); + fieldQUANTITY.setShouldAllowNull(false); + table.addField(fieldQUANTITY); + + FieldDefinition fieldSHIP_ADDR = new FieldDefinition(); + fieldSHIP_ADDR.setName("SHIP_ADDR"); + fieldSHIP_ADDR.setTypeName("VARCHAR2"); + fieldSHIP_ADDR.setSize(80); + fieldSHIP_ADDR.setSubSize(0); + fieldSHIP_ADDR.setIsPrimaryKey(false); + fieldSHIP_ADDR.setIsIdentity(false); + fieldSHIP_ADDR.setUnique(false); + fieldSHIP_ADDR.setShouldAllowNull(true); + table.addField(fieldSHIP_ADDR); + + FieldDefinition field10 = new FieldDefinition(); + field10.setName("ORDER_VERSION"); + field10.setTypeName("NUMERIC"); + field10.setSize(15); + field10.setShouldAllowNull(true ); + field10.setIsPrimaryKey(false ); + field10.setUnique(false ); + field10.setIsIdentity(false ); + table.addField(field10); + + return table; + } + + public static TableDefinition buildCMP3_ORDER_SEQTable() { + TableDefinition table = new TableDefinition(); + table.setName("CMP3_FIELDACCESS_CUSTOMER_SEQ"); + + FieldDefinition fieldSEQ_NAME = new FieldDefinition(); + fieldSEQ_NAME.setName("SEQ_NAME"); + fieldSEQ_NAME.setTypeName("VARCHAR"); + fieldSEQ_NAME.setSize(80); + fieldSEQ_NAME.setSubSize(0); + fieldSEQ_NAME.setIsPrimaryKey(true); + fieldSEQ_NAME.setIsIdentity(false); + fieldSEQ_NAME.setUnique(false); + fieldSEQ_NAME.setShouldAllowNull(false); + table.addField(fieldSEQ_NAME); + + FieldDefinition fieldSEQ_VALUE = new FieldDefinition(); + fieldSEQ_VALUE.setName("SEQ_COUNT"); + fieldSEQ_VALUE.setTypeName("NUMERIC"); + fieldSEQ_VALUE.setSize(15); + fieldSEQ_VALUE.setSubSize(0); + fieldSEQ_VALUE.setIsPrimaryKey(false); + fieldSEQ_VALUE.setIsIdentity(false); + fieldSEQ_VALUE.setUnique(false); + fieldSEQ_VALUE.setShouldAllowNull(false); + table.addField(fieldSEQ_VALUE); + + return table; + } + + public static TableDefinition buildCMP3_SALESPERSONTable() { + TableDefinition table = new TableDefinition(); + table.setName("CMP3_FIELDACCESS_SALESPERSON"); + + FieldDefinition fieldID = new FieldDefinition(); + fieldID.setName("ID"); + fieldID.setTypeName("NUMBER"); + fieldID.setSize(15); + fieldID.setSubSize(0); + fieldID.setIsPrimaryKey(true); + fieldID.setIsIdentity(false); + fieldID.setUnique(false); + fieldID.setShouldAllowNull(false); + table.addField(fieldID); + + 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 buildCUSTOMER_CUSTOMERTable() { + TableDefinition table = new TableDefinition(); + + table.setName("CMP3_FIELDACCESS_CUST_CUST"); + + // 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_FIELDACCESS_CUSTOMER.CUST_ID"); + table.addField(field); + + // SECTION: FIELD + FieldDefinition field1 = new FieldDefinition(); + field1.setName("CONTROLLEDCUSTOMERS_CUST_ID"); + field1.setTypeName("NUMERIC"); + field1.setSize(15); + field1.setShouldAllowNull(false); + field1.setIsPrimaryKey(true); + field1.setUnique(false); + field1.setIsIdentity(false); + field1.setForeignKeyFieldName("CMP3_FIELDACCESS_CUSTOMER.CUST_ID"); + table.addField(field1); + + return table; + } + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/SalesPerson.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000023/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Thu Nov 30 17:09:33 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000023/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:06:23 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/SalesPerson.java Thu Nov 30 17:06:22 2006 *************** *** 0 **** --- 1,52 ---- + package oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships; + + + import javax.persistence.*; + import static javax.persistence.GenerationType.*; + import static javax.persistence.CascadeType.*; + import static javax.persistence.FetchType.*; + import java.util.Collection; + + @Entity(name="FieldAccessSalesPerson") + @Table(name="CMP3_FIELDACCESS_SALESPERSON") + public class SalesPerson + { + private String name; + @Id + @GeneratedValue(strategy=TABLE, generator="FIELDACCESS_SALESPERSON_TABLE_GENERATOR") + @TableGenerator( + name="FIELDACCESS_SALESPERSON_TABLE_GENERATOR", + table="CMP3_FIELDACCESS_CUSTOMER_SEQ", + pkColumnName="SEQ_NAME", + valueColumnName="SEQ_COUNT", + pkColumnValue="SALESPERSON_SEQ" + ) + @Column(name="ID") + private int id; + @OneToMany(cascade=ALL, mappedBy="salesPerson") + private Collection orders; + + public SalesPerson() {}; + + 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 Collection getOrders() { + return orders; + } + public void setOrders(Collection orders) { + this.orders = orders; + } + } \ No newline at end of file ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/ExpressionJUnitTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000027/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Thu Nov 30 17:09:33 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000027/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:06:27 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/ExpressionJUnitTestSuite.java Thu Nov 30 17:06:26 2006 *************** *** 0 **** --- 1,319 ---- + /* + * 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.fieldaccess.relationships; + + import java.util.Vector; + + import javax.persistence.EntityManager; + + import oracle.toplink.essentials.expressions.Expression; + import oracle.toplink.essentials.expressions.ExpressionBuilder; + import oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl; + import oracle.toplink.essentials.internal.databaseaccess.Platform; + import oracle.toplink.essentials.queryframework.ReadAllQuery; + import oracle.toplink.essentials.testing.framework.junit.JUnitTestCase; + + import oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships.*; + + public class ExpressionJUnitTestSuite extends JUnitTestCase { + + public ExpressionJUnitTestSuite() { + } + + public ExpressionJUnitTestSuite(String name) { + super(name); + } + + public void setUp () { + super.setUp(); + clearCache(); + new RelationshipsTableManager().replaceTables(JUnitTestCase.getServerSession()); + } + + + /* + * lefTrim(string) feature test + * tests that leftTrim(trim_char) works. + */ + public void testLeftTrimWithTrimChar() throws Exception { + Platform dbPlatform = getDbPlatform(); + if (dbPlatform.isDerby() || dbPlatform.isDB2()) { + getServerSession().logMessage("Test testLeftTrimWithTrimChar skipped for this platform"); + return; + } + + Customer c = RelationshipsExamples.customerExample4(); + //customer4.setCity("Manotick"); + EntityManager em = createEntityManager(); + try{ + + em.getTransaction().begin(); + em.persist(c); + em.getTransaction().commit(); + }catch (Exception e){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + throw e; + } + em.close(); + try{ + ExpressionBuilder builder = new ExpressionBuilder(); + Expression expression = builder.get("city").leftTrim("M").equal("anotick"); + + ReadAllQuery r = new ReadAllQuery(); + r.setReferenceClass(Customer.class); + r.setSelectionCriteria(expression); + Vector v = (Vector)getServerSession().executeQuery(r); + assertTrue("Test error: No Customers found",v.size()!=0 ); + Customer returned = (Customer)v.firstElement(); + assertTrue("Test error: No Customers found","Manotick".equals(returned.getCity()) ); + + }catch(Exception e){ + em = createEntityManager(); + em.getTransaction().begin(); + c = (Customer)em.find(Customer.class, c.getCustomerId()); + em.remove(c); + try{ + em.getTransaction().commit(); + }catch (Throwable t){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + }finally{ + em.close(); + throw e; + } + } + } + + /* + * trim(string) feature test + * tests that trim(trim_char) works. + */ + public void testTrimWithTrimChar() throws Exception { + Platform dbPlatform = getDbPlatform(); + if (dbPlatform.isDerby() || dbPlatform.isDB2()) { + getServerSession().logMessage("Test testTrimWithTrimChar skipped for this platform"); + return; + } + Item i = new Item(); + i.setName("itemi"); + i.setDescription("itemi description"); + EntityManager em = createEntityManager(); + try{ + em.getTransaction().begin(); + em.persist(i); + em.getTransaction().commit(); + }catch (Exception e){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + throw e; + } + em.close(); + try{ + ExpressionBuilder builder = new ExpressionBuilder(); + Expression expression = builder.get("name").trim("i").equal("tem"); + + ReadAllQuery r = new ReadAllQuery(); + r.setReferenceClass(Item.class); + r.setSelectionCriteria(expression); + Vector v = (Vector)getServerSession().executeQuery(r); + assertTrue("Test error: No Items found",v.size()!=0 ); + Item returned = (Item)v.firstElement(); + assertTrue("Test error: No Items found","itemi".equals(returned.getName()) ); + + }catch(Exception e){ + em = createEntityManager(); + try{ + em.getTransaction().begin(); + i = (Item)em.find(Item.class, i.getItemId()); + em.remove(i); + em.getTransaction().commit(); + }catch (Throwable t){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + }finally{ + em.close(); + throw e; + } + } + } + + /* + * trim(string) feature test + * tests that trim() works. + */ + public void testTrimWithoutTrimChar() throws Exception { + Platform dbPlatform = getDbPlatform(); + if (dbPlatform.isDerby() || dbPlatform.isDB2()) { + getServerSession().logMessage("Test testTrimWithTrimChar skipped for this platform"); + return; + } + Item i = new Item(); + i.setName(" tem "); + i.setDescription("itemi description"); + EntityManager em = createEntityManager(); + try{ + em.getTransaction().begin(); + em.persist(i); + em.getTransaction().commit(); + }catch (Exception e){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + throw e; + } + em.close(); + try{ + ExpressionBuilder builder = new ExpressionBuilder(); + Expression expression = builder.get("name").trim().equal("tem"); + + ReadAllQuery r = new ReadAllQuery(); + r.setReferenceClass(Item.class); + r.setSelectionCriteria(expression); + Vector v = (Vector)getServerSession().executeQuery(r); + assertTrue("Test error: No Items found",v.size()!=0 ); + Item returned = (Item)v.firstElement(); + assertTrue("Test error: No Items found"," tem ".equals(returned.getName()) ); + }catch(Exception e){ + em = createEntityManager(); + try{ + em.getTransaction().begin(); + i = (Item)em.find(Item.class, i.getItemId()); + em.remove(i); + em.getTransaction().commit(); + }catch (Throwable t){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + }finally{ + em.close(); + throw e; + } + } + } + + /* + * locate(string) feature test + * tests that locate(string) works. + */ + public void testLocateWithSingleArgument() throws Exception { + Item i = new Item(); + i.setName("itemi"); + i.setDescription("itemi description"); + EntityManager em = createEntityManager(); + try{ + em.getTransaction().begin(); + em.persist(i); + em.getTransaction().commit(); + }catch (Exception e){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + throw e; + } + em.close(); + try{ + ExpressionBuilder builder = new ExpressionBuilder(); + Expression expression = builder.get("name").locate("t").equal(new Integer(2)); + + ReadAllQuery r = new ReadAllQuery(); + r.setReferenceClass(Item.class); + r.setSelectionCriteria(expression); + Vector v = (Vector)getServerSession().executeQuery(r); + assertTrue("Test error: No Items found", v.size()!=0 ); + Item returned = (Item)v.firstElement(); + assertTrue("Test error: IncorrectItem found","itemi".equals(returned.getName()) ); + + }catch(Exception e){ + em = createEntityManager(); + try{ + em.getTransaction().begin(); + i = (Item)em.find(Item.class, i.getItemId()); + em.remove(i); + em.getTransaction().commit(); + }catch (Throwable t){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + }finally{ + em.close(); + throw e; + } + } + } + + /* + * locate(string, int) feature test + * tests that locate(string, int) works. + */ + public void testLocateWithDoubleArgument() throws Exception { + Item i = new Item(); + i.setName("itemi"); + i.setDescription("itemi description"); + EntityManager em = createEntityManager(); + try{ + em.getTransaction().begin(); + em.persist(i); + em.getTransaction().commit(); + }catch (Exception e){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + throw e; + } + em.close(); + try{ + ExpressionBuilder builder = new ExpressionBuilder(); + Expression expression = builder.get("name").locate("i", 2).equal(new Integer(5)); + + ReadAllQuery r = new ReadAllQuery(); + r.setReferenceClass(Item.class); + r.setSelectionCriteria(expression); + Vector v = (Vector)getServerSession().executeQuery(r); + assertTrue("Test error: No Items found", v.size()!=0 ); + Item returned = (Item)v.firstElement(); + assertTrue("Test error: IncorrectItem found","itemi".equals(returned.getName()) ); + + }catch(Exception e){ + em = createEntityManager(); + try{ + em.getTransaction().begin(); + i = (Item)em.find(Item.class, i.getItemId()); + em.remove(i); + em.getTransaction().commit(); + }catch (Throwable t){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + }finally{ + em.close(); + throw e; + } + } + } + + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/IsolatedCacheTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000028/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Thu Nov 30 17:09:33 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000028/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:06:31 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/IsolatedCacheTestSuite.java Thu Nov 30 17:06:30 2006 *************** *** 0 **** --- 1,81 ---- + /* + * 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.fieldaccess.relationships; + + import junit.framework.Test; + import junit.framework.TestSuite; + + import javax.persistence.*; + + import oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl; + import oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork; + import oracle.toplink.essentials.testing.framework.junit.JUnitTestCase; + import oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships.IsolatedItem; + + import oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships.*; + + public class IsolatedCacheTestSuite extends JUnitTestCase { + public IsolatedCacheTestSuite() {} + + public IsolatedCacheTestSuite(String name) { + super(name); + } + + public void setUp () { + super.setUp(); + new RelationshipsTableManager().replaceTables(JUnitTestCase.getServerSession()); + } + + public static Test suite() { + return new TestSuite(IsolatedCacheTestSuite.class) { + protected void setUp(){} + protected void tearDown(){} + }; + } + + public void testCacheIsolationDBQueryHit() throws Exception { + EntityManager em = createEntityManager(); + + // Step 1 - get an isolated item in the cache. + em.getTransaction().begin(); + + IsolatedItem item = new IsolatedItem(); + item.setDescription("A phoney item"); + item.setName("Phoney name"); + em.persist(item); + + em.getTransaction().commit(); + + // Step 2 - clear the entity manager and see if the item still exists + // in the uow cache. + em.getTransaction().begin(); + + em.clear(); + RepeatableWriteUnitOfWork uow = (RepeatableWriteUnitOfWork) ((EntityManagerImpl) em.getDelegate()).getActivePersistenceContext(em.getTransaction()); + + assertFalse("The isolated item was not cleared from the shared cache", uow.getIdentityMapAccessor().containsObjectInIdentityMap(item)); + assertFalse("The isolated item was not cleared from the uow cache", uow.getParent().getIdentityMapAccessor().containsObjectInIdentityMap(item)); + + em.getTransaction().commit(); + em.close(); + } + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/UniAndBiDirectionalMappingTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000029/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Thu Nov 30 17:09:33 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000029/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:06:34 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/UniAndBiDirectionalMappingTestSuite.java Thu Nov 30 17:06:34 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.fieldaccess.relationships; + + import junit.framework.*; + import junit.extensions.TestSetup; + + import javax.persistence.*; + + import oracle.toplink.essentials.sessions.DatabaseSession; + import oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships.*; + import oracle.toplink.essentials.testing.framework.junit.JUnitTestCase; + import oracle.toplink.essentials.testing.models.cmp3.fieldaccess.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/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/VirtualAttributeTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000030/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Thu Nov 30 17:09:33 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000030/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:06:38 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/VirtualAttributeTestSuite.java Thu Nov 30 17:06:37 2006 *************** *** 0 **** --- 1,152 ---- + /* + * 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.fieldaccess.relationships; + + import javax.persistence.EntityManager; + + import oracle.toplink.essentials.testing.framework.junit.JUnitTestCase; + import oracle.toplink.essentials.testing.models.cmp3.virtualattribute.*; + + import oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl; + + import junit.extensions.TestSetup; + import junit.framework.*; + + public class VirtualAttributeTestSuite extends JUnitTestCase { + + protected static int id; + + public VirtualAttributeTestSuite() { + super(); + } + + public VirtualAttributeTestSuite(String name) { + super(name); + } + + public static Test suite() { + TestSuite suite = new TestSuite(); + suite.addTest(new VirtualAttributeTestSuite("testInsertVirtualAttribute")); + suite.addTest(new VirtualAttributeTestSuite("testReadVirtualAttribute")); + suite.addTest(new VirtualAttributeTestSuite("testUpdateVirtualAttribute")); + suite.addTest(new VirtualAttributeTestSuite("testDeleteVirtualAttribute")); + + return new TestSetup(suite) { + protected void setUp(){ + new VirtualAttributeTableCreator().replaceTables(JUnitTestCase.getServerSession()); + } + + protected void tearDown() { + clearCache(); + } + }; + } + + public void setUp () { + super.setUp(); + clearCache(); + } + + public void testInsertVirtualAttribute(){ + EntityManager em = createEntityManager(); + em.getTransaction().begin(); + try{ + OneToOneVirtualAttributeHolder holder = new OneToOneVirtualAttributeHolder(); + VirtualAttribute attribute = new VirtualAttribute(); + attribute.setDescription("virtualAttribute"); + holder.setVirtualAttribute(attribute); + em.persist(holder); + em.flush(); + id = holder.getId(); + em.getTransaction().commit(); + }catch (RuntimeException ex){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + em.close(); + throw ex; + } + } + + public void testReadVirtualAttribute(){ + OneToOneVirtualAttributeHolder holder = createEntityManager().find(OneToOneVirtualAttributeHolder.class, id); + assertNotNull("Object with virtual attributes could not be read.", holder); + assertNotNull("Object held as a virtual attribute was not read with it's owner", holder.getVirtualAttribute()); + } + + public void testUpdateVirtualAttribute(){ + OneToOneVirtualAttributeHolder holder = null; + EntityManager em = createEntityManager(); + em.getTransaction().begin(); + try{ + holder = em.find(OneToOneVirtualAttributeHolder.class, id); + VirtualAttribute attribute = new VirtualAttribute(); + attribute.setDescription("virtualAttribute2"); + holder.setVirtualAttribute(attribute); + em.getTransaction().commit(); + }catch (RuntimeException ex){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + em.close(); + throw ex; + } + clearCache(); + holder = em.find(OneToOneVirtualAttributeHolder.class, id); + em.close(); + assertNotNull("Updated object with virtual attributes could not be read.", holder); + assertNotNull("Updated object held as a virtual attribute was not read with it's owner", holder.getVirtualAttribute()); + assertTrue("Virtual Attribute Object was not updated.", holder.getVirtualAttribute().getDescription().equals("virtualAttribute2")); + } + + public void testDeleteVirtualAttribute(){ + OneToOneVirtualAttributeHolder holder = null; + VirtualAttribute attribute = null; + int attributeId = 0; + EntityManager em = createEntityManager(); + em.getTransaction().begin(); + try{ + holder = em.find(OneToOneVirtualAttributeHolder.class, id); + + attribute = holder.getVirtualAttribute(); + attributeId = attribute.getId(); + holder.setVirtualAttribute(null); + em.remove(attribute); + em.remove(holder); + em.getTransaction().commit(); + }catch (RuntimeException ex){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + em.close(); + throw ex; + } + holder = em.find(OneToOneVirtualAttributeHolder.class, id); + assertNull("Object holding virtual attribute was not properly deleted", holder); + attribute =em.find(VirtualAttribute.class, attributeId); + assertNull("Virtual Attribute Object was not properly removed.", attribute); + } + + + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/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/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000031/AB0952363AC40CBFE034080020E8C54E.27 Report generated at Thu Nov 30 17:09:33 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000031/AB0952363AC40CBFE034080020E8C54E.27 Thu Nov 30 15:43:18 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/FullRegressionTestSuite.java Thu Nov 30 17:09:32 2006 *************** *** 114,119 **** --- 114,124 ---- fullSuite.addTest(ValidationTestSuite.suite()); fullSuite.addTest(QueryParameterValidationTestSuite.suite()); fullSuite.addTest(UniAndBiDirectionalMappingTestSuite.suite()); + + // FieldAccess relationship model + fullSuite.addTest(oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships.UniAndBiDirectionalMappingTestSuite.suite()); + fullSuite.addTestSuite(oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships.ExpressionJUnitTestSuite.class); + fullSuite.addTest(oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships.VirtualAttributeTestSuite.suite()); // EJBQL testing model fullSuite.addTest(JUnitEJBQLUnitTestSuite.suite()); ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/resource/essentials/ejb30-testing/META-INF/persistence.xml vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000032/AB0952363AC40CBFE034080020E8C54E.53 Report generated at Thu Nov 30 17:09:33 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000032/AB0952363AC40CBFE034080020E8C54E.53 Thu Nov 30 16:01:25 2006 --- /ade/cdelahun_toplinkmain/tltest/resource/essentials/ejb30-testing/META-INF/persistence.xml Thu Nov 30 17:09:32 2006 *************** *** 49,54 **** --- 49,55 ---- + ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tldev/source/essentials/oracle/toplink/essentials/internal/weaving/TopLinkClassWeaver.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.11 Report generated at Fri Dec 1 15:50:23 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.11 Thu Nov 30 15:22:53 2006 --- /ade/cdelahun_toplinkmain/tldev/source/essentials/oracle/toplink/essentials/internal/weaving/TopLinkClassWeaver.java Fri Dec 1 15:50:23 2006 *************** *** 70,76 **** public void addValueHolder(AttributeDetails attributeDetails){ String attribute = attributeDetails.getAttributeName(); RuntimeVisibleAnnotations annotations = null; ! if (attributeDetails.getMapping().getGetMethodName() == null || attributeDetails.getMapping().getGetMethodName().equals("")){ annotations = getTransientAnnotation(); } weavedVH = true; --- 70,76 ---- public void addValueHolder(AttributeDetails attributeDetails){ String attribute = attributeDetails.getAttributeName(); RuntimeVisibleAnnotations annotations = null; ! if (attributeDetails.getGetterMethodName() == null || attributeDetails.getGetterMethodName().equals("")){ annotations = getTransientAnnotation(); } weavedVH = true; *************** *** 112,118 **** cv_get_VH.visitVarInsn(ALOAD, 0); // EntityC object = getFoo(); ! cv_get_VH.visitMethodInsn(INVOKEVIRTUAL, classDetails.getClassName(), attributeDetails.getGetterMethodName(), "()L" + attributeDetails.getReferenceClass().replace('.','/') + ";"); cv_get_VH.visitVarInsn(ASTORE, 1); // if (object != _toplink_foo_vh.getValue()){ --- 112,122 ---- cv_get_VH.visitVarInsn(ALOAD, 0); // EntityC object = getFoo(); ! if (attributeDetails.getGetterMethodName() != null){ ! cv_get_VH.visitMethodInsn(INVOKEVIRTUAL, classDetails.getClassName(), attributeDetails.getGetterMethodName(), "()L" + attributeDetails.getReferenceClass().replace('.','/') + ";"); ! } else { ! cv_get_VH.visitMethodInsn(INVOKEVIRTUAL, classDetails.getClassName(), "_toplink_get" + attributeDetails.attributeName, "()L" + attributeDetails.getReferenceClass().replace('.','/') + ";"); ! } cv_get_VH.visitVarInsn(ASTORE, 1); // if (object != _toplink_foo_vh.getValue()){ *************** *** 125,131 **** // setFoo(object); cv_get_VH.visitVarInsn(ALOAD, 0); cv_get_VH.visitVarInsn(ALOAD, 1); ! cv_get_VH.visitMethodInsn(INVOKEVIRTUAL, classDetails.getClassName(), attributeDetails.getSetterMethodName(), "(L" + attributeDetails.getReferenceClass().replace('.','/') + ";)V"); // } cv_get_VH.visitLabel(l1); --- 129,139 ---- // setFoo(object); cv_get_VH.visitVarInsn(ALOAD, 0); cv_get_VH.visitVarInsn(ALOAD, 1); ! if (attributeDetails.getSetterMethodName() != null){ ! cv_get_VH.visitMethodInsn(INVOKEVIRTUAL, classDetails.getClassName(), attributeDetails.getSetterMethodName(), "(L" + attributeDetails.getReferenceClass().replace('.','/') + ";)V"); ! } else { ! cv_get_VH.visitMethodInsn(INVOKEVIRTUAL, classDetails.getClassName(), "_toplink_set" + attributeDetails.getAttributeName(), "(L" + attributeDetails.getReferenceClass().replace('.','/') + ";)V"); ! } // } cv_get_VH.visitLabel(l1); *************** *** 172,178 **** // Object object = getFoo(); cv_set_value.visitVarInsn(ALOAD, 0); ! cv_set_value.visitMethodInsn(INVOKEVIRTUAL, className, attributeDetails.getGetterMethodName(), "()L" + attributeDetails.getReferenceClass().replace('.','/') + ";"); cv_set_value.visitVarInsn(ASTORE, 2); // Object value = valueholderinterface.getValue(); --- 180,190 ---- // Object object = getFoo(); cv_set_value.visitVarInsn(ALOAD, 0); ! if (attributeDetails.getGetterMethodName() != null){ ! cv_set_value.visitMethodInsn(INVOKEVIRTUAL, className, attributeDetails.getGetterMethodName(), "()L" + attributeDetails.getReferenceClass().replace('.','/') + ";"); ! } else { ! cv_set_value.visitMethodInsn(INVOKEVIRTUAL, className, "_toplink_get" + attributeDetails.attributeName, "()L" + attributeDetails.getReferenceClass().replace('.','/') + ";"); ! } cv_set_value.visitVarInsn(ASTORE, 2); // Object value = valueholderinterface.getValue(); *************** *** 189,195 **** cv_set_value.visitVarInsn(ALOAD, 0); cv_set_value.visitVarInsn(ALOAD, 3); cv_set_value.visitTypeInsn(CHECKCAST, attributeDetails.getReferenceClass().replace('.','/')); ! cv_set_value.visitMethodInsn(INVOKEVIRTUAL, className, attributeDetails.getSetterMethodName(), "(L" + attributeDetails.getReferenceClass().replace('.','/') + ";)V"); // } cv_set_value.visitLabel(l0); --- 201,211 ---- cv_set_value.visitVarInsn(ALOAD, 0); cv_set_value.visitVarInsn(ALOAD, 3); cv_set_value.visitTypeInsn(CHECKCAST, attributeDetails.getReferenceClass().replace('.','/')); ! if (attributeDetails.getSetterMethodName() != null){ ! cv_set_value.visitMethodInsn(INVOKEVIRTUAL, className, attributeDetails.getSetterMethodName(), "(L" + attributeDetails.getReferenceClass().replace('.','/') + ";)V"); ! } else { ! cv_set_value.visitMethodInsn(INVOKEVIRTUAL, className, "_toplink_set" + attributeDetails.getAttributeName(), "(L" + attributeDetails.getReferenceClass().replace('.','/') + ";)V"); ! } // } cv_set_value.visitLabel(l0); ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/AllCMP3TestRunModel.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000005/AB0952363AC40CBFE034080020E8C54E.8 Report generated at Fri Dec 1 15:50:23 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000005/AB0952363AC40CBFE034080020E8C54E.8 Thu Nov 30 15:27:01 2006 --- /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/AllCMP3TestRunModel.java Fri Dec 1 15:50:23 2006 *************** *** 20,25 **** --- 20,26 ---- public AllCMP3TestRunModel() { addTest(new oracle.toplink.essentials.testing.tests.cmp3.advanced.CMP3AdvancedTestModel()); addTest(new oracle.toplink.essentials.testing.tests.cmp3.relationships.CMP3RelationshipsTestModel()); + addTest(new oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.CMP3FieldAccessTestModel()); addTest(new oracle.toplink.essentials.testing.tests.cmp3.inheritance.CMP3InheritanceTestModel()); addTest(new oracle.toplink.essentials.testing.tests.cmp3.complexaggregate.CMP3ComplexAggregateTestModel()); addTest(FullRegressionTestSuite.suite()); ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/CMP3FieldAccessTestModel.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000006/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Dec 1 15:50:23 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000006/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:05:21 2006 --- /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/CMP3FieldAccessTestModel.java Fri Dec 1 15:43:02 2006 *************** *** 0 **** --- 1,37 ---- + package oracle.toplink.essentials.testing.tests.cmp3.fieldaccess; + + import oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships.RelationshipsTableManager; + import oracle.toplink.essentials.testing.tests.cmp3.CMP3TestModel; + import oracle.toplink.essentials.testing.framework.JUnitTestCase; + import oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships.ExecuteUpdateTest; + import oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships.GetResultCollectionTest; + import oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships.GetResultListTest; + import oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships.GetSingleResultTest; + import oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships.IsolatedCacheTestSuite; + import oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships.NamedQueryDoesNotExistTest; + import oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships.NamedQueryWithArgumentsTest; + + /** + *

Purpose: To collect the tests that will run using field level annotation. + * Currently the tests contained are a duplicate of the tests in the + * CMP3RelationshipsTestModel. In order for this test model to work correctly the + * EntityContainer must be initialized thought the comandline agent. + */ + public class CMP3FieldAccessTestModel extends CMP3TestModel{ + + public void setup(){ + super.setup(); + RelationshipsTableManager.getCreator().replaceTables(getServerSession()); + } + + public void addTests(){ + addTest(new GetSingleResultTest()); + addTest(new ExecuteUpdateTest()); + addTest(new GetResultCollectionTest()); + addTest(new GetResultListTest()); + addTest(new NamedQueryDoesNotExistTest()); + addTest(new NamedQueryWithArgumentsTest()); + addTests(JUnitTestCase.suite(IsolatedCacheTestSuite.class)); + } + + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/ExecuteUpdateTest.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Dec 1 15:50:23 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:05:25 2006 --- /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/ExecuteUpdateTest.java Fri Dec 1 15:43:05 2006 *************** *** 0 **** --- 1,137 ---- + package oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships; + + import oracle.toplink.essentials.ejb.cmp3.EntityManager; + import oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl; + import oracle.toplink.essentials.queryframework.UpdateAllQuery; + import oracle.toplink.essentials.testing.framework.*; + import javax.persistence.Query; + import oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships.*; + import oracle.toplink.essentials.testing.tests.cmp3.EntityContainerTestBase; + import oracle.toplink.essentials.exceptions.QueryException; + + /* + * Tests for the executeUpdate method on the EJBQueryImpl class + * Also tests bugs 4288845 and 4293920, that params are passed in and used correctly + */ + public class ExecuteUpdateTest extends EntityContainerTestBase { + + //reset gets called twice on error + protected boolean reset = false; + + //used for verification + protected Customer returnedCustomer=null; + public Integer[] cusIDs = new Integer[2]; + + public java.net.URL n=null; + + protected String nameChange1 = "New Name1"; + protected String nameChange2 = "New Name2"; + protected String nameChange3 = "New Name3"; + protected String returnedName1,returnedName2,returnedName3 = null; + protected Exception expectedException =null; + public ExecuteUpdateTest() { + } + + public void setup (){ + super.setup(); + this.reset = true; + + Customer cusClone1 = RelationshipsExamples.customerExample1(); + try { + beginTransaction(); + getEntityManager().persist(cusClone1); + commitTransaction(); + } catch (Exception ex) { + throw new TestException("Unable to setup Test" + ex); + } + ((EntityManagerImpl)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + + cusIDs[0] = cusClone1.getCustomerId(); + + getSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + } + + public void reset (){ + if (reset){//ensures it is only done once + try { + beginTransaction(); + Customer cus1 = (Customer)getEntityManager().find(Customer.class,cusIDs[0]); + getEntityManager().remove(cus1); + commitTransaction(); + reset = false; + }catch (Exception ex) { + throw new TestException("Unable to reset Test" + ex); + } + } + } + + public void test(){ + + try { + beginTransaction(); + Customer cus = (Customer)getEntityManager().find(Customer.class,cusIDs[0]); + Query query = getEntityManager().createQuery("UPDATE FieldAccessCustomer customer SET customer.name = '"+nameChange1+"' WHERE customer.customerId = "+cusIDs[0]); + query.executeUpdate(); + + + ((EntityManagerImpl)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + getSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + //getEntityManager().refresh(cus); + cus = (Customer)getEntityManager().find(Customer.class,cusIDs[0]); + returnedName1 = cus.getName(); + + //tests bug 4288845 + Query query2 = getEntityManager().createQuery("UPDATE FieldAccessCustomer customer SET customer.name = :name WHERE customer.customerId = "+cusIDs[0]); + query2.setParameter("name", nameChange2); + query2.executeUpdate(); + + ((EntityManagerImpl)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + getSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + //getEntityManager().refresh(cus); + cus = (Customer)getEntityManager().find(Customer.class,cusIDs[0]); + returnedName2 = cus.getName(); + + //tests bug 4293920 + Query query3 = getEntityManager().createQuery("UPDATE FieldAccessCustomer customer SET customer.name = :name WHERE customer.customerId = :id"); + query3.setParameter("name", nameChange3); + query3.setParameter("id", cusIDs[0]); + query3.executeUpdate(); + + ((EntityManagerImpl)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + getSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + //getEntityManager().refresh(cus); + cus = (Customer)getEntityManager().find(Customer.class,cusIDs[0]); + returnedName3 = cus.getName(); + + //tests bug 4294241 + try{ + Query query4 = getEntityManager().createNamedQuery("findAllCustomersFieldAccess"); + int someValue = query4.executeUpdate(); + }catch(IllegalStateException expected){ + expectedException=expected; + } + + commitTransaction(); + + } catch (Exception ex) { + try{ + commitTransaction(); + }catch(Exception comitEx){} + throw new TestErrorException("Exception thrown while executing updates" + ex, ex); + } + } + + public void verify(){ + if ( (returnedName1==null || !returnedName1.equals(nameChange1))){ + throw new TestErrorException("Customer name did not get updated correctly should be:"+nameChange1 +" is :"+returnedName1); + } + if ( (returnedName2==null || !returnedName2.equals(nameChange2))){ + throw new TestErrorException("Customer name did not get updated correctly should be:"+nameChange2 +" is :"+returnedName2); + } + if ( (returnedName3==null || !returnedName3.equals(nameChange3))){ + throw new TestErrorException("Customer name did not get updated correctly should be:"+nameChange3 +" is :"+returnedName3); + } + if ( expectedException==null) + throw new TestErrorException("excuteUpdate did not result in an exception on findAllCustomersFieldAccess named ReadAllQuery"); + } + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/GetResultCollectionTest.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000008/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Dec 1 15:50:23 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000008/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:05:28 2006 --- /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/GetResultCollectionTest.java Fri Dec 1 15:43:09 2006 *************** *** 0 **** --- 1,137 ---- + package oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships; + + import java.util.HashMap; + + import oracle.toplink.essentials.exceptions.QueryException; + import oracle.toplink.essentials.internal.ejb.cmp3.EJBQueryImpl; + import oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl; + import oracle.toplink.essentials.internal.queryframework.MapContainerPolicy; + import oracle.toplink.essentials.queryframework.ReadAllQuery; + import oracle.toplink.essentials.queryframework.ReadObjectQuery; + import oracle.toplink.essentials.testing.framework.*; + import oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships.*; + import oracle.toplink.essentials.testing.tests.cmp3.EntityContainerTestBase; + import java.util.Collection; + /* + * Tests using the 'getSingleResult' api on a Query object obtained from the EntityManager + * Also tests bugs 4300879 - check non Collection container policy error + * and 4297903 - check ReadObjectQuery fails + */ + public class GetResultCollectionTest extends EntityContainerTestBase { + + //reset gets called twice on error + protected boolean reset = false; + + //used for verification + protected Customer returnedCustomer=null; + protected Collection returnedCustomers1, returnedCustomers2,returnedCustomers3,returnedCustomers4 = null; + protected QueryException expectedException1,expectedException2 = null; + + protected String searchString = "notAnItemName"; + protected String ejbql1 = "SELECT OBJECT(thecust) FROM FieldAccessCustomer thecust WHERE thecust.customerId = :id"; + + public Integer[] cusIDs = new Integer[3]; + + public GetResultCollectionTest() { + } + + public void setup (){ + super.setup(); + this.reset = true; + + Customer cusClone1 = RelationshipsExamples.customerExample1(); + Customer cusClone2 = RelationshipsExamples.customerExample2(); + try { + beginTransaction(); + getEntityManager().persist(cusClone1); + getEntityManager().persist(cusClone2); + commitTransaction(); + } catch (Exception ex) { + throw new TestException("Unable to setup Test" + ex); + } + ((EntityManagerImpl)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + + cusIDs[0] = cusClone1.getCustomerId(); + cusIDs[1] = cusClone2.getCustomerId(); + + getSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + } + + public void reset (){ + if (reset){//ensures it is only done once + try { + beginTransaction(); + Customer cus1 = (Customer)getEntityManager().find(Customer.class,cusIDs[0]); + getEntityManager().remove(cus1); + Customer cus2 = (Customer)getEntityManager().find(Customer.class,cusIDs[1]); + getEntityManager().remove(cus2); + commitTransaction(); + reset = false; + } catch (Exception ex) { + throw new TestException("Unable to reset Test" + ex); + } + } + } + + public void test(){ + try{ + beginTransaction(); + EntityManagerImpl entityManagerImpl = (EntityManagerImpl)getEntityManager(); + + EJBQueryImpl query1 = (EJBQueryImpl)entityManagerImpl.createNamedQuery("findAllCustomersFieldAccess"); + returnedCustomers1= query1.getResultCollection(); + + EJBQueryImpl query2 = (EJBQueryImpl) entityManagerImpl.createQuery(ejbql1); + query2.setParameter("id",new Integer(-10)); + returnedCustomers2 = query2.getResultCollection(); + + //bug:4297903, check container policy failure + EJBQueryImpl query3 = (EJBQueryImpl) entityManagerImpl.createQuery(ejbql1); + ReadAllQuery readAllQuery = new ReadAllQuery(Customer.class); + MapContainerPolicy mapContainerPolicy = new MapContainerPolicy(); + mapContainerPolicy.setContainerClass(HashMap.class); + mapContainerPolicy.setKeyName("hashCode"); + readAllQuery.setContainerPolicy(mapContainerPolicy); + query3.setDatabaseQuery(readAllQuery); + try{ + returnedCustomers3 = query3.getResultCollection(); + }catch(QueryException exceptionExpected1){//QueryException.INVALID_CONTAINER_CLASS + expectedException1 = exceptionExpected1; + } + + //bug:4300879, check ReadObjectQuery fails + EJBQueryImpl query4 = (EJBQueryImpl) entityManagerImpl.createQuery(ejbql1); + query4.setParameter("id",new Integer(-10)); + ReadObjectQuery readObjectQuery2 = new ReadObjectQuery(Customer.class); + readObjectQuery2.setEJBQLString(ejbql1); + query4.setDatabaseQuery(readObjectQuery2); + try{ + returnedCustomers4 = query4.getResultCollection(); + }catch(QueryException exceptionExpected2){ + expectedException2 = exceptionExpected2; + } + + commitTransaction(); + }catch (Exception unexpectedException){ + try{ + commitTransaction(); + }catch(Exception comitEx){} + throw new TestErrorException("Problem in GetResultCollectionTest: "+unexpectedException); + } + } + + public void verify(){ + if ( returnedCustomers1==null || (returnedCustomers1.size()<2) ){ + throw new TestErrorException("Not all customers were returned from findAllCustomersFieldAccess query "); + } + if ( returnedCustomers2==null || (returnedCustomers2.size()!=0) ){ + throw new TestErrorException("Customer from ReadObjectQuery was not returned using getResultCollection"); + } + if ( expectedException1==null || (expectedException1.getErrorCode()!= QueryException.INVALID_CONTAINER_CLASS)){ + throw new TestErrorException("getResultCollection on query returning a hashtable did not throw expected INVALID_CONTAINER_CLASS QueryException"); + } + if ( expectedException2==null || (expectedException2.getErrorCode()!= QueryException.INCORRECT_QUERY_FOUND)){ + throw new TestErrorException("getResultCollection on ReadObjectQuery did not throw expected INCORRECT_QUERY_FOUND QueryException"); + } + } + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/GetResultListTest.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000009/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Dec 1 15:50:23 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000009/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:05:32 2006 --- /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/GetResultListTest.java Fri Dec 1 15:43:12 2006 *************** *** 0 **** --- 1,95 ---- + package oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships; + + import java.util.HashMap; + import oracle.toplink.essentials.exceptions.QueryException; + import javax.persistence.Query; + import oracle.toplink.essentials.internal.ejb.cmp3.EJBQueryImpl; + import oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl; + import oracle.toplink.essentials.internal.queryframework.MapContainerPolicy; + import oracle.toplink.essentials.queryframework.ReadAllQuery; + import oracle.toplink.essentials.queryframework.ReadObjectQuery; + import oracle.toplink.essentials.testing.framework.*; + import oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships.*; + import java.util.List; + /* + * Tests using the 'getSingleResult' api on a Query object obtained from the EntityManager + * Also tests bugs 4300879 - check non List container policy error + * and 4297903 - check ReadObjectQuery fails + */ + public class GetResultListTest extends GetResultCollectionTest { + + //reset gets called twice on error + protected boolean reset = false; + + //used for verification + protected List returnedCustomers1, returnedCustomers2,returnedCustomers3,returnedCustomers4 = null; + + public Integer[] cusIDs = new Integer[3]; + + public GetResultListTest() { + } + + + public void test(){ + try{ + beginTransaction(); + EntityManagerImpl entityManagerImpl = (EntityManagerImpl)getEntityManager(); + + Query query1 = entityManagerImpl.createNamedQuery("findAllCustomersFieldAccess"); + returnedCustomers1= query1.getResultList(); + + EJBQueryImpl query2 = (EJBQueryImpl) entityManagerImpl.createQuery(ejbql1); + query2.setParameter("id",new Integer(-10)); + returnedCustomers2 = query2.getResultList(); + + //bug:4297903, check container policy failure + EJBQueryImpl query3 = (EJBQueryImpl) entityManagerImpl.createQuery(ejbql1); + ReadAllQuery readAllQuery = new ReadAllQuery(Customer.class); + MapContainerPolicy mapContainerPolicy = new MapContainerPolicy(); + mapContainerPolicy.setContainerClass(HashMap.class); + mapContainerPolicy.setKeyName("hashCode"); + readAllQuery.setContainerPolicy(mapContainerPolicy); + query3.setDatabaseQuery(readAllQuery); + try{ + returnedCustomers3 = query3.getResultList(); + }catch(QueryException exceptionExpected1){//QueryException.INVALID_CONTAINER_CLASS + expectedException1 = exceptionExpected1; + } + + //bug:4300879, check ReadObjectQuery fails + EJBQueryImpl query4 = (EJBQueryImpl) entityManagerImpl.createQuery(ejbql1); + query4.setParameter("id",new Integer(-10)); + ReadObjectQuery readObjectQuery2 = new ReadObjectQuery(Customer.class); + readObjectQuery2.setEJBQLString(ejbql1); + query4.setDatabaseQuery(readObjectQuery2); + try{ + returnedCustomers4 = query4.getResultList(); + }catch(QueryException exceptionExpected2){ + expectedException2 = exceptionExpected2; + } + + commitTransaction(); + }catch (Exception unexpectedException){ + try{ + commitTransaction(); + }catch(Exception comitEx){} + throw new TestErrorException("Problem in GetResultListTest: "+unexpectedException); + } + } + + public void verify(){ + if ( returnedCustomers1==null || (returnedCustomers1.size()<2) ){ + throw new TestErrorException("Not all customers were returned from findAllCustomersFieldAccess query "); + } + if ( returnedCustomers2==null || (returnedCustomers2.size()!=0) ){ + throw new TestErrorException("Customer from ReadObjectQuery was not returned using getResultList"); + } + if ( expectedException1==null || (expectedException1.getErrorCode()!= QueryException.INVALID_CONTAINER_CLASS)){ + throw new TestErrorException("getResultList on query returning a hashtable did not throw expected INVALID_CONTAINER_CLASS QueryException"); + } + if ( expectedException2==null || (expectedException2.getErrorCode()!= QueryException.INCORRECT_QUERY_FOUND)){ + throw new TestErrorException("getResultList on ReadObjectQuery did not throw expected INCORRECT_QUERY_FOUNDQueryException"); + } + } + + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/GetSingleResultTest.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000010/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Dec 1 15:50:23 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000010/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:05:36 2006 --- /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/GetSingleResultTest.java Fri Dec 1 15:43:15 2006 *************** *** 0 **** --- 1,148 ---- + package oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships; + + import java.util.HashMap; + import javax.persistence.NoResultException; + import javax.persistence.NonUniqueResultException; + import javax.persistence.Query; + import oracle.toplink.essentials.exceptions.QueryException; + import oracle.toplink.essentials.internal.ejb.cmp3.EJBQueryImpl; + import oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl; + import oracle.toplink.essentials.internal.queryframework.MapContainerPolicy; + import oracle.toplink.essentials.queryframework.ReadAllQuery; + import oracle.toplink.essentials.queryframework.ReadObjectQuery; + import oracle.toplink.essentials.testing.framework.*; + import oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships.*; + import oracle.toplink.essentials.testing.tests.cmp3.EntityContainerTestBase; + /* + * Tests using the 'getSingleResult' api on a Query object obtained from the EntityManager + * Tests fixes for bugs 4202835 and 4301674 + * + * modified for changes in bug:4628215 (EntityNotFoundException) + * EntityNotFoundException changed to NoResultException as per new spec + */ + public class GetSingleResultTest extends EntityContainerTestBase { + + //reset gets called twice on error + protected boolean reset = false; + + //used for verification + protected Customer returnedCustomer1,returnedCustomer2=null; + protected NonUniqueResultException expectedException1 = null; + protected NoResultException expectedException2 = null; + protected QueryException expectedException3 = null; + + protected String searchString = "notAnItemName"; + + public Integer[] cusIDs = new Integer[3]; + + public GetSingleResultTest() { + } + + public void setup (){ + super.setup(); + this.reset = true; + + Customer cusClone1 = RelationshipsExamples.customerExample1(); + Customer cusClone2 = RelationshipsExamples.customerExample2(); + try { + beginTransaction(); + getEntityManager().persist(cusClone1); + getEntityManager().persist(cusClone2); + commitTransaction(); + } catch (Exception ex) { + throw new TestException("Unable to setup Test" + ex); + } + ((EntityManagerImpl)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + + cusIDs[0] = cusClone1.getCustomerId(); + cusIDs[1] = cusClone2.getCustomerId(); + + getSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + } + + public void reset (){ + if (reset){//ensures it is only done once + try { + beginTransaction(); + Customer cus1 = (Customer)getEntityManager().find(Customer.class,cusIDs[0]); + getEntityManager().remove(cus1); + Customer cus2 = (Customer)getEntityManager().find(Customer.class,cusIDs[1]); + getEntityManager().remove(cus2); + commitTransaction(); + reset = false; + } catch (Exception ex) { + throw new TestException("Unable to reset Test" + ex); + } + } + } + + public void test(){ + try{ + beginTransaction(); + try { + returnedCustomer1 = (Customer)getEntityManager().createNamedQuery("findAllCustomersFieldAccess").getSingleResult(); + } catch (NonUniqueResultException exceptionExpected1) { + expectedException1 =exceptionExpected1; + } + try { + //should be no Items to find, which should cause an NoResultException + Query query1 = getEntityManager().createNamedQuery("findAllItemsByName"); + Item item =(Item)query1.setParameter(1, searchString).getSingleResult(); + } catch (NoResultException exceptionExpected2) { + expectedException2 =exceptionExpected2; + } + //bug 4301674 test + EJBQueryImpl query2 = (EJBQueryImpl) getEntityManager().createNamedQuery("findAllCustomersFieldAccess"); + ReadAllQuery readAllQuery = new ReadAllQuery(Customer.class); + MapContainerPolicy mapContainerPolicy = new MapContainerPolicy(); + mapContainerPolicy.setContainerClass(HashMap.class); + mapContainerPolicy.setKeyName("hashCode"); + readAllQuery.setContainerPolicy(mapContainerPolicy); + query2.setDatabaseQuery(readAllQuery); + try{ + returnedCustomer1 = (Customer)query2.getSingleResult(); + }catch(QueryException exceptionExpected3){//QueryException.INVALID_CONTAINER_CLASS + expectedException3 = exceptionExpected3; + } + + //check for single result found. + Query query3 = getEntityManager().createQuery("SELECT OBJECT(thecust) FROM FieldAccessCustomer thecust WHERE thecust.customerId = :id"); + returnedCustomer1 = (Customer)query3.setParameter("id", cusIDs[0]).getSingleResult(); + + + //check for single result using a ReadObjectQuery (tests previous fix for 4202835) + EJBQueryImpl query4 = (EJBQueryImpl)getEntityManager().createQuery("SELECT OBJECT(thecust) FROM FieldAccessCustomer thecust WHERE thecust.customerId = :id"); + query4.setParameter("id", cusIDs[0]); + ReadObjectQuery readObjectQuery = new ReadObjectQuery(Customer.class); + readObjectQuery.setEJBQLString("SELECT OBJECT(thecust) FROM FieldAccessCustomer thecust WHERE thecust.customerId = :id"); + query4.setDatabaseQuery(readObjectQuery); + returnedCustomer2 = (Customer)query4.getSingleResult(); + + commitTransaction(); + }catch (Exception unexpectedException){ + try{ + commitTransaction(); + }catch(Exception comitEx){} + throw new TestErrorException("Problem in GetSingleResultTest: "+unexpectedException); + } + } + + public void verify(){ + if ( expectedException1==null ){ + throw new TestErrorException("getSingelResult on query returning multiple values did not throw a NonUniqueResultException"); + } + if ( expectedException2==null ){ + throw new TestErrorException("getSingelResult on query returning multiple values did not throw an NoResultException"); + } + if ( ( expectedException3==null ) || ( expectedException3.getErrorCode()!= QueryException.INVALID_CONTAINER_CLASS ) ){ + throw new TestErrorException("getSingelResult using ReadAllQuery with MapContainerPolicy did not throw expected INVALID_CONTAINER_CLASS QueryException"); + } + if ( returnedCustomer1==null || (!returnedCustomer1.getCustomerId().equals(cusIDs[0])) ){ + throw new TestErrorException("Incorrect Single Customer returned, found: "+returnedCustomer1); + } + if ( returnedCustomer2==null || (!returnedCustomer2.getCustomerId().equals(cusIDs[0])) ){ + throw new TestErrorException("Incorrect Single Customer returned, found: "+returnedCustomer2); + } + } + + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/NamedQueryDoesNotExistTest.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000011/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Dec 1 15:50:23 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000011/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:05:40 2006 --- /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/NamedQueryDoesNotExistTest.java Fri Dec 1 15:43:18 2006 *************** *** 0 **** --- 1,58 ---- + package oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships; + + import oracle.toplink.essentials.testing.framework.*; + import oracle.toplink.essentials.testing.tests.cmp3.EntityContainerTestBase; + + /** + * Tests trying to execute a named query that does not exist. + * + * @author Guy Pelletier + */ + public class NamedQueryDoesNotExistTest extends EntityContainerTestBase { + protected boolean m_reset = false; // reset gets called twice on error + + protected Exception m_exception; + protected boolean m_npeCaught; + protected boolean m_illegalArgumentExceptionCaught; + + public NamedQueryDoesNotExistTest() { + setDescription("Looks for an expected exception when running a named query that does not exist."); + } + + public void setup (){ + super.setup(); + m_reset = true; + m_npeCaught = false; + m_illegalArgumentExceptionCaught = false; + } + + public void reset (){ + if (m_reset) { //ensures it is only done once + m_reset = false; + } + } + + public void test(){ + try { + getEntityManager().createNamedQuery("doesNotExist").getResultList(); + } catch (NullPointerException e) { + m_npeCaught = true; + } catch (IllegalArgumentException e) { + m_illegalArgumentExceptionCaught = true; + } catch (Exception e) { + m_exception = e; + } + } + + public void verify(){ + if (m_npeCaught) { + throw new TestErrorException("A null pointer exception caught on the query."); + } else if (!m_illegalArgumentExceptionCaught) { + if (m_exception != null) { + throw new TestErrorException("Expected IllegalArgumentException, caught: " + m_exception); + } else { + throw new TestErrorException("No exception was caught on a named query that does not exist."); + } + } + } + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/NamedQueryWithArgumentsTest.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000012/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Dec 1 15:50:23 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000012/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:05:43 2006 --- /ade/cdelahun_toplinkmain/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/NamedQueryWithArgumentsTest.java Fri Dec 1 15:43:22 2006 *************** *** 0 **** --- 1,83 ---- + package oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships; + + import java.util.List; + import java.util.Vector; + + import oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl; + import oracle.toplink.essentials.testing.framework.*; + import oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships.*; + import oracle.toplink.essentials.testing.tests.cmp3.EntityContainerTestBase; + import oracle.toplink.essentials.threetier.ServerSession; + + //Bug#4646580 Query arguments are added in EJBQL + public class NamedQueryWithArgumentsTest extends EntityContainerTestBase { + + public Integer[] cusIDs = new Integer[3]; + public Integer[] orderIDs = new Integer[3]; + public Integer[] itemIDs = new Integer[3]; + Exception exception; + List list; + + public NamedQueryWithArgumentsTest() { + setDescription("Named query with arguments can be executed through Session's executeQuery(String queryName, Vector argumentValues)."); + } + + public void setup (){ + super.setup(); + + Customer cusClone1 = RelationshipsExamples.customerExample1(); + Item item1 = RelationshipsExamples.itemExample1(); + Order order1 = RelationshipsExamples.orderExample1(); + order1.setCustomer(cusClone1); + order1.setItem(item1); + + try { + beginTransaction(); + getEntityManager().persist(cusClone1); + getEntityManager().persist(order1); + commitTransaction(); + } catch (Exception ex) { + throw new TestException("Unable to setup Test" + ex); + } + cusIDs[0] = cusClone1.getCustomerId(); + orderIDs[0] = order1.getOrderId(); + itemIDs[0] = item1.getItemId(); + + getSession().getIdentityMapAccessor().initializeAllIdentityMaps(); + } + + public void reset (){ + try { + beginTransaction(); + Customer cus1 = (Customer)getEntityManager().find(Customer.class, cusIDs[0]); + getEntityManager().remove(cus1); + Order ord1 = (Order)getEntityManager().find(Order.class, orderIDs[0]); + getEntityManager().remove(ord1); + Item it1 = (Item)getEntityManager().find(Item.class, itemIDs[0]); + getEntityManager().remove(it1); + commitTransaction(); + } catch (Exception ex) { + throw new TestException("Unable to reset Test" + ex); + } + } + + public void test(){ + try { + ServerSession ss = ((EntityManagerImpl)getEntityManager()).getServerSession(); + Vector vec = new Vector(); + vec.add(itemIDs[0]); + list = (List)ss.executeQuery("findAllFieldAccessOrdersByItem", vec); + } catch (Exception ex) { + exception = ex; + } + } + + public void verify(){ + if (exception != null) { + throw new TestErrorException("An exception is thrown: " + exception); + } + if (list.size() != 1) { + throw new TestErrorException("One order is expected but " + list.size() + " was returned"); + } + } + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/Customer.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000016/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Dec 1 15:50:23 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000016/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:05:47 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/Customer.java Fri Dec 1 15:43:25 2006 *************** *** 0 **** --- 1,133 ---- + /* + * 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.models.cmp3.fieldaccess.relationships; + + import java.util.Vector; + import java.util.HashSet; + import java.util.Collection; + import javax.persistence.*; + import static javax.persistence.GenerationType.*; + import static javax.persistence.CascadeType.*; + + @Entity(name="FieldAccessCustomer") + @Table(name="CMP3_FIELDACCESS_CUSTOMER") + @NamedQuery( + name="findAllCustomersFieldAccess", + query="SELECT OBJECT(thecust) FROM FieldAccessCustomer thecust" + ) + @NamedNativeQueries(value={ + @NamedNativeQuery(name="findAllSQLCustomersFieldAccess", + query="select * from CMP3_FIELDACCESS_CUSTOMER"), + @NamedNativeQuery(name="insertCustomer1111SQLFieldAccess", + query="INSERT INTO CMP3_FIELDACCESS_CUSTOMER (CUST_ID, NAME, CITY, CUST_VERSION) VALUES (1111, NULL, NULL, 1)"), + @NamedNativeQuery(name="deleteCustomer1111SQLFieldAccess", + query="DELETE FROM CMP3_FIELDACCESS_CUSTOMER WHERE (CUST_ID=1111)")}) + public class Customer implements java.io.Serializable{ + @Id + @GeneratedValue(strategy=TABLE, generator="FIELDACCESS_CUSTOMER_TABLE_GENERATOR") + @TableGenerator( + name="FIELDACCESS_CUSTOMER_GENERATOR_TABLE", + table="CMP3_FIELDACCESS_CUSTOMER_SEQ", + pkColumnName="SEQ_NAME", + valueColumnName="SEQ_COUNT", + pkColumnValue="CUST_SEQ" + ) + @Column(name="CUST_ID") + private Integer customerId; + @Version + @Column(name="CUST_VERSION") + private int version; + private String city; + private String name; + @OneToMany(cascade=ALL, mappedBy="customer") + private Collection orders = new HashSet(); + @ManyToMany + @JoinTable(name="CMP3_FIELDACCESS_CUST_CUST") + private Collection controlledCustomers = new HashSet(); + + public Customer() {} + + public Integer getCustomerId() { + return customerId; + } + + public void setCustomerId(Integer id) { + this.customerId = id; + } + + public int getVersion() { + return version; + } + + protected void setVersion(int version) { + this.version = version; + } + + public String getCity() { + return city; + } + + public void setCity(String aCity) { + this.city = aCity; + } + + public String getName() { + return name; + } + + public void setName(String aName) { + this.name = aName; + } + + public Collection getOrders() { + return orders; + } + + public void setOrders(Collection newValue) { + this.orders = newValue; + } + + public void addOrder(Order anOrder) { + getOrders().add(anOrder); + anOrder.setCustomer(this); + } + + public void removeOrder(Order anOrder) { + getOrders().remove(anOrder); + } + + 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/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/CustomerDetails.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000017/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Dec 1 15:50:23 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000017/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:05:51 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/CustomerDetails.java Fri Dec 1 15:43:28 2006 *************** *** 0 **** --- 1,17 ---- + package oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships; + + public class CustomerDetails + { + private Integer custId; + private int orderCount; + + public CustomerDetails() + { + } + + public CustomerDetails(Integer custId, int orderCount) + { + this.custId = custId; + this.orderCount = orderCount; + } + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/IsolatedItem.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000018/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Dec 1 15:50:23 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000018/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:05:54 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/IsolatedItem.java Fri Dec 1 15:43:33 2006 *************** *** 0 **** --- 1,69 ---- + /* + * 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.models.cmp3.fieldaccess.relationships; + + import javax.persistence.*; + import static javax.persistence.GenerationType.*; + + @Entity(name="FieldAccessIsolatedItem") + @Table(name="CMP3_FIELDACCESS_ISOLATED_ITEM") + public class IsolatedItem implements java.io.Serializable { + @Id + @GeneratedValue(strategy=TABLE, generator="FIELDACCESS_ISOLATED_ITEM_TABLE_GENERATOR") + @TableGenerator( + name="FIELDACCESS_ISOLATED_ITEM_TABLE_GENERATOR", + table="CMP3_FIELDACCESS_CUSTOMER_SEQ", + pkColumnName="SEQ_NAME", + valueColumnName="SEQ_COUNT", + pkColumnValue="ISOLATED_ITEM_SEQ" + ) + @Column(name="ID") + private Integer itemId; + private String name; + private String description; + + public IsolatedItem() {} + + public Integer getItemId() { + return itemId; + } + + public void setItemId(Integer id) { + this.itemId = id; + } + + public String getDescription() { + return description; + } + + public void setDescription(String desc) { + this.description = desc; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/Item.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000019/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Dec 1 15:50:23 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000019/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:06:08 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/Item.java Fri Dec 1 15:43:37 2006 *************** *** 0 **** --- 1,84 ---- + /* + * 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.models.cmp3.fieldaccess.relationships; + + import javax.persistence.*; + import static javax.persistence.GenerationType.*; + + @Entity(name="FieldAccessItem") + @Table(name="CMP3_FIELDACCESS_ITEM") + @NamedQuery( + name="findAllItemsByName", + query="SELECT OBJECT(item) FROM FieldAccessItem item WHERE item.name = ?1" + ) + public class Item implements java.io.Serializable { + @Id + @GeneratedValue(strategy=TABLE, generator="FIELDACCESS_ITEM_TABLE_GENERATOR") + @TableGenerator( + name="FIELDACCESS_ITEM_TABLE_GENERATOR", + table="CMP3_FIELDACCESS_CUSTOMER_SEQ", + pkColumnName="SEQ_NAME", + valueColumnName="SEQ_COUNT", + pkColumnValue="ITEM_SEQ" + ) + @Column(name="ID") + private Integer itemId; + @Version + @Column(name="ITEM_VERSION") + private int version; + private String name; + private String description; + + public Item() {} + + public Integer getItemId() { + return itemId; + } + + public void setItemId(Integer id) { + this.itemId = id; + } + + protected int getVersion() { + return version; + } + + protected void setVersion(int version) { + this.version = version; + } + + public String getDescription() { + return description; + } + + public void setDescription(String desc) { + this.description = desc; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/Order.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000020/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Dec 1 15:50:23 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000020/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:06:12 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/Order.java Fri Dec 1 15:43:40 2006 *************** *** 0 **** --- 1,127 ---- + /* + * 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.models.cmp3.fieldaccess.relationships; + + import javax.persistence.*; + import static javax.persistence.GenerationType.*; + import static javax.persistence.CascadeType.*; + import static javax.persistence.FetchType.*; + + @Entity(name="FieldAccessOrderBean") + @Table(name="CMP3_FIELDACCESS_ORDER") + @NamedQuery( + name="findAllFieldAccessOrdersByItem", + query="SELECT OBJECT(theorder) FROM FieldAccessOrderBean theorder WHERE theorder.item.itemId = :id" + ) + public class Order implements java.io.Serializable { + @Id + @GeneratedValue(strategy=TABLE, generator="FIELDACCESS_ORDER_TABLE_GENERATOR") + @TableGenerator( + name="FIELDACCESS_ORDER_TABLE_GENERATOR", + table="CMP3_FIELDACCESS_CUSTOMER_SEQ", + pkColumnName="SEQ_NAME", + valueColumnName="SEQ_COUNT", + pkColumnValue="ORDER_SEQ" + ) + @Column(name="ORDER_ID") + private Integer orderId; + @Version + @Column(name="ORDER_VERSION") + private int version; + @OneToOne(cascade=PERSIST, fetch=LAZY) + private Item item; + private int quantity; + @Column(name="SHIP_ADDR") + private String shippingAddress; + @ManyToOne(fetch=LAZY) + private Customer customer; + @ManyToOne(fetch=LAZY) + private Customer billedCustomer; + @ManyToOne(fetch=LAZY) + private SalesPerson salesPerson; + + public Order() {} + + public Integer getOrderId() { + return orderId; + } + + public void setOrderId(Integer id) { + this.orderId = id; + } + + protected int getVersion() { + return version; + } + + protected void setVersion(int version) { + this.version = version; + } + + public Item getItem() { + return item; + } + + public void setItem(Item item) { + this.item = item; + } + + public int getQuantity() { + return quantity; + } + + public void setQuantity(int quantity) { + this.quantity = quantity; + } + + public String getShippingAddress() { + return shippingAddress; + } + + public void setShippingAddress(String shippingAddress) { + this.shippingAddress = shippingAddress; + } + + public Customer getCustomer() { + return customer; + } + + public void setCustomer(Customer customer) { + this.customer = customer; + } + + public Customer getBilledCustomer() { + return billedCustomer; + } + + public void setBilledCustomer(Customer billedCustomer) { + this.billedCustomer = billedCustomer; + } + + public SalesPerson getSalesPerson() { + return salesPerson; + } + + public void setSalesPerson(SalesPerson salesPerson) { + this.salesPerson = salesPerson; + } + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/RelationshipsExamples.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000021/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Dec 1 15:50:23 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000021/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:06:16 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/RelationshipsExamples.java Fri Dec 1 15:43:43 2006 *************** *** 0 **** --- 1,190 ---- + /* + * 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.models.cmp3.fieldaccess.relationships; + import java.util.Vector; + import oracle.toplink.essentials.sessions.Session; + import oracle.toplink.essentials.sessions.UnitOfWork; + import oracle.toplink.essentials.tools.schemaframework.PopulationManager; + + public class RelationshipsExamples + { + private PopulationManager populationManager; + + public RelationshipsExamples() + { + this.populationManager = PopulationManager.getDefaultManager(); + } + + public void buildExamples(Session session) + { + PopulationManager.getDefaultManager().getRegisteredObjects().remove(Order.class); + PopulationManager.getDefaultManager().getRegisteredObjects().remove(Customer.class); + PopulationManager.getDefaultManager().getRegisteredObjects().remove(Item.class); + PopulationManager.getDefaultManager().getRegisteredObjects().remove(SalesPerson.class); + + Vector allObjects = new Vector(); + Order orderExample1 = orderExample1(); + Customer customerExample1 = customerExample1(); + Customer customerExample2 = customerExample2(); + SalesPerson salesPerson1 = salesPersonExample1(); + + /* + * Set relationships: + * Order1 has customer1 as the billed customer + * Order1 has customer2 as the customer + * OrdersList contains Order1 and is set as customer2's orders + * SalesPerson1 is set as salesPerson to Order1 + */ + orderExample1.setBilledCustomer(customerExample1); + orderExample1.setCustomer(customerExample2); + Vector ordersList = new Vector(); + ordersList.add(orderExample1); + customerExample2.setOrders(ordersList); + orderExample1.setSalesPerson(salesPerson1); + + Order orderExample2 = orderExample2(); + Customer customerExample3 = customerExample3(); + Customer customerExample4 = customerExample4(); + SalesPerson salesPerson2 = salesPersonExample2(); + /* + * Set relationships: + * Order2 has customer3 as the billed customer + * Order2 has customer4 as the customer + * Order2 is added to the OrdersList and is set as customer2's orders + * SalesPerson2 is set as salesPerson to Order2 + */ + orderExample2.setBilledCustomer(customerExample3); + orderExample2.setCustomer(customerExample4); + ordersList.add(orderExample2); + customerExample4.setOrders(ordersList); + orderExample2.setSalesPerson(salesPerson2); + + + allObjects.add(customerExample1); + allObjects.add(customerExample2); + allObjects.add(orderExample1); + allObjects.add(customerExample3); + allObjects.add(customerExample4); + allObjects.add(orderExample2); + + allObjects.add(itemExample1()); + allObjects.add(itemExample2()); + allObjects.add(itemExample3()); + allObjects.add(itemExample4()); + + allObjects.add(orderExample3()); + allObjects.add(orderExample4()); + allObjects.add(salesPerson1); + allObjects.add(salesPerson2); + + UnitOfWork unitOfWork = session.acquireUnitOfWork(); + unitOfWork.registerAllObjects(allObjects); + unitOfWork.commit(); + } + + public static Customer customerExample1(){ + Customer customer1 = new Customer(); + customer1.setName("John Smith"); + customer1.setCity("Ottawa"); + return customer1; + } + public static Customer customerExample2(){ + Customer customer2 = new Customer(); + customer2.setName("Jane Smith"); + customer2.setCity("Orleans"); + return customer2; + } + public static Customer customerExample3(){ + Customer customer3 = new Customer(); + customer3.setName("Karen McDonald"); + customer3.setCity("Nepean"); + return customer3; + } + public static Customer customerExample4(){ + Customer customer4 = new Customer(); + customer4.setName("Robert Sampson"); + customer4.setCity("Manotick"); + return customer4; + } + public static Item itemExample1(){ + Item item = new Item(); + item.setName("item1"); + item.setDescription("Item1 description"); + return item; + } + public static Item itemExample2(){ + Item item = new Item(); + item.setName("item2"); + item.setDescription("Item2 description"); + return item; + } + public static Item itemExample3(){ + Item item = new Item(); + item.setName("item3"); + item.setDescription("Item3 description"); + return item; + } + public static Item itemExample4(){ + Item item = new Item(); + item.setName("item4"); + item.setDescription("Item4 description"); + return item; + } + public static Order orderExample1(){ + Order order = new Order(); + order.setQuantity(70); + order.setShippingAddress("100 Argyle Street"); + return order; + } + public static Order orderExample2(){ + Order order = new Order(); + order.setQuantity(680); + order.setShippingAddress("500 Oracle Parkway"); + return order; + } + public static Order orderExample3(){ + Order order = new Order(); + order.setQuantity(22); + order.setShippingAddress("240 Queen Street"); + return order; + } + public static Order orderExample4(){ + Order order = new Order(); + order.setQuantity(1); + order.setShippingAddress("50 O'Connor"); + return order; + } + + public static SalesPerson salesPersonExample1(){ + SalesPerson salesPerson = new SalesPerson(); + salesPerson.setName("Sales Person 1"); + return salesPerson; + } + + public static SalesPerson salesPersonExample2(){ + SalesPerson salesPerson = new SalesPerson(); + salesPerson.setName("Sales Person 2"); + return salesPerson; + } + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/RelationshipsTableManager.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000022/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Dec 1 15:50:23 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000022/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:06:19 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/RelationshipsTableManager.java Fri Dec 1 15:43:47 2006 *************** *** 0 **** --- 1,373 ---- + /* + * 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.models.cmp3.fieldaccess.relationships; + + import oracle.toplink.essentials.tools.schemaframework.FieldDefinition; + import oracle.toplink.essentials.tools.schemaframework.TableCreator; + import oracle.toplink.essentials.tools.schemaframework.TableDefinition; + + public class RelationshipsTableManager extends TableCreator { + + public static TableCreator tableCreator; + + public RelationshipsTableManager() { + setName("Relationships"); + addTableDefinition(buildCMP3_CUSTOMERTable()); + addTableDefinition(buildCMP3_ITEMTable()); + addTableDefinition(buildCMP3_ISOLATEDITEMTable()); + addTableDefinition(buildCMP3_ORDERTable()); + addTableDefinition(buildCMP3_ORDER_SEQTable()); + addTableDefinition(buildCMP3_SALESPERSONTable()); + addTableDefinition(buildCUSTOMER_CUSTOMERTable()); + } + + public static TableCreator getCreator(){ + if (RelationshipsTableManager.tableCreator == null){ + RelationshipsTableManager.tableCreator = new RelationshipsTableManager(); + } + return RelationshipsTableManager.tableCreator; + } + + public static TableDefinition buildCMP3_CUSTOMERTable() { + TableDefinition table = new TableDefinition(); + table.setName("CMP3_FIELDACCESS_CUSTOMER"); + + FieldDefinition fieldCITY = new FieldDefinition(); + fieldCITY.setName("CITY"); + fieldCITY.setTypeName("VARCHAR2"); + fieldCITY.setSize(80); + fieldCITY.setSubSize(0); + fieldCITY.setIsPrimaryKey(false); + fieldCITY.setIsIdentity(false); + fieldCITY.setUnique(false); + fieldCITY.setShouldAllowNull(true); + table.addField(fieldCITY); + + FieldDefinition fieldCUST_ID = new FieldDefinition(); + fieldCUST_ID.setName("CUST_ID"); + fieldCUST_ID.setTypeName("NUMBER"); + fieldCUST_ID.setSize(15); + fieldCUST_ID.setSubSize(0); + fieldCUST_ID.setIsPrimaryKey(true); + fieldCUST_ID.setIsIdentity(false); + fieldCUST_ID.setUnique(false); + fieldCUST_ID.setShouldAllowNull(false); + table.addField(fieldCUST_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); + + FieldDefinition field10 = new FieldDefinition(); + field10.setName("CUST_VERSION"); + field10.setTypeName("NUMERIC"); + field10.setSize(15); + field10.setShouldAllowNull(true ); + field10.setIsPrimaryKey(false ); + field10.setUnique(false ); + field10.setIsIdentity(false ); + table.addField(field10); + + return table; + } + + public static TableDefinition buildCMP3_ISOLATEDITEMTable() { + TableDefinition table = new TableDefinition(); + table.setName("CMP3_FIELDACCESS_ISOLATED_ITEM"); + + FieldDefinition fieldDESCRIPTION = new FieldDefinition(); + fieldDESCRIPTION.setName("DESCRIPTION"); + fieldDESCRIPTION.setTypeName("VARCHAR2"); + fieldDESCRIPTION.setSize(80); + fieldDESCRIPTION.setSubSize(0); + fieldDESCRIPTION.setIsPrimaryKey(false); + fieldDESCRIPTION.setIsIdentity(false); + fieldDESCRIPTION.setUnique(false); + fieldDESCRIPTION.setShouldAllowNull(true); + table.addField(fieldDESCRIPTION); + + FieldDefinition fieldITEM_ID = new FieldDefinition(); + fieldITEM_ID.setName("ID"); + fieldITEM_ID.setTypeName("NUMBER"); + fieldITEM_ID.setSize(15); + fieldITEM_ID.setSubSize(0); + fieldITEM_ID.setIsPrimaryKey(true); + fieldITEM_ID.setIsIdentity(false); + fieldITEM_ID.setUnique(false); + fieldITEM_ID.setShouldAllowNull(false); + table.addField(fieldITEM_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 buildCMP3_ITEMTable() { + TableDefinition table = new TableDefinition(); + table.setName("CMP3_FIELDACCESS_ITEM"); + + FieldDefinition fieldDESCRIPTION = new FieldDefinition(); + fieldDESCRIPTION.setName("DESCRIPTION"); + fieldDESCRIPTION.setTypeName("VARCHAR2"); + fieldDESCRIPTION.setSize(80); + fieldDESCRIPTION.setSubSize(0); + fieldDESCRIPTION.setIsPrimaryKey(false); + fieldDESCRIPTION.setIsIdentity(false); + fieldDESCRIPTION.setUnique(false); + fieldDESCRIPTION.setShouldAllowNull(true); + table.addField(fieldDESCRIPTION); + + FieldDefinition fieldITEM_ID = new FieldDefinition(); + fieldITEM_ID.setName("ID"); + fieldITEM_ID.setTypeName("NUMBER"); + fieldITEM_ID.setSize(15); + fieldITEM_ID.setSubSize(0); + fieldITEM_ID.setIsPrimaryKey(true); + fieldITEM_ID.setIsIdentity(false); + fieldITEM_ID.setUnique(false); + fieldITEM_ID.setShouldAllowNull(false); + table.addField(fieldITEM_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); + + FieldDefinition field10 = new FieldDefinition(); + field10.setName("ITEM_VERSION"); + field10.setTypeName("NUMERIC"); + field10.setSize(15); + field10.setShouldAllowNull(true ); + field10.setIsPrimaryKey(false ); + field10.setUnique(false ); + field10.setIsIdentity(false ); + table.addField(field10); + + return table; + } + + public static TableDefinition buildCMP3_ORDERTable() { + TableDefinition table = new TableDefinition(); + table.setName("CMP3_FIELDACCESS_ORDER"); + + FieldDefinition fieldCUST_ID = new FieldDefinition(); + fieldCUST_ID.setName("CUSTOMER_CUST_ID"); + fieldCUST_ID.setTypeName("NUMBER"); + fieldCUST_ID.setSize(15); + fieldCUST_ID.setSubSize(0); + fieldCUST_ID.setIsPrimaryKey(false); + fieldCUST_ID.setIsIdentity(false); + fieldCUST_ID.setUnique(false); + fieldCUST_ID.setShouldAllowNull(true); + table.addField(fieldCUST_ID); + + FieldDefinition fieldBILLED_CUST_ID = new FieldDefinition(); + fieldBILLED_CUST_ID.setName("BILLEDCUSTOMER_CUST_ID"); + fieldBILLED_CUST_ID.setTypeName("NUMBER"); + fieldBILLED_CUST_ID.setSize(15); + fieldBILLED_CUST_ID.setSubSize(0); + fieldBILLED_CUST_ID.setIsPrimaryKey(false); + fieldBILLED_CUST_ID.setIsIdentity(false); + fieldBILLED_CUST_ID.setUnique(false); + fieldBILLED_CUST_ID.setShouldAllowNull(true); + table.addField(fieldBILLED_CUST_ID); + + FieldDefinition fieldSALESPERSON_ID = new FieldDefinition(); + fieldSALESPERSON_ID.setName("SALESPERSON_ID"); + fieldSALESPERSON_ID.setTypeName("NUMBER"); + fieldSALESPERSON_ID.setSize(15); + fieldSALESPERSON_ID.setSubSize(0); + fieldSALESPERSON_ID.setIsPrimaryKey(false); + fieldSALESPERSON_ID.setIsIdentity(false); + fieldSALESPERSON_ID.setUnique(false); + fieldSALESPERSON_ID.setShouldAllowNull(true); + table.addField(fieldSALESPERSON_ID); + + FieldDefinition fieldITEM_ID = new FieldDefinition(); + fieldITEM_ID.setName("ITEM_ID"); + fieldITEM_ID.setTypeName("NUMBER"); + fieldITEM_ID.setSize(15); + fieldITEM_ID.setSubSize(0); + fieldITEM_ID.setIsPrimaryKey(false); + fieldITEM_ID.setIsIdentity(false); + fieldITEM_ID.setUnique(false); + fieldITEM_ID.setShouldAllowNull(true); + table.addField(fieldITEM_ID); + + FieldDefinition fieldORDER_ID = new FieldDefinition(); + fieldORDER_ID.setName("ORDER_ID"); + fieldORDER_ID.setTypeName("NUMBER"); + fieldORDER_ID.setSize(15); + fieldORDER_ID.setSubSize(0); + fieldORDER_ID.setIsPrimaryKey(true); + fieldORDER_ID.setIsIdentity(false); + fieldORDER_ID.setUnique(false); + fieldORDER_ID.setShouldAllowNull(false); + table.addField(fieldORDER_ID); + + FieldDefinition fieldQUANTITY = new FieldDefinition(); + fieldQUANTITY.setName("QUANTITY"); + fieldQUANTITY.setTypeName("NUMBER"); + fieldQUANTITY.setSize(15); + fieldQUANTITY.setSubSize(0); + fieldQUANTITY.setIsPrimaryKey(false); + fieldQUANTITY.setIsIdentity(false); + fieldQUANTITY.setUnique(false); + fieldQUANTITY.setShouldAllowNull(false); + table.addField(fieldQUANTITY); + + FieldDefinition fieldSHIP_ADDR = new FieldDefinition(); + fieldSHIP_ADDR.setName("SHIP_ADDR"); + fieldSHIP_ADDR.setTypeName("VARCHAR2"); + fieldSHIP_ADDR.setSize(80); + fieldSHIP_ADDR.setSubSize(0); + fieldSHIP_ADDR.setIsPrimaryKey(false); + fieldSHIP_ADDR.setIsIdentity(false); + fieldSHIP_ADDR.setUnique(false); + fieldSHIP_ADDR.setShouldAllowNull(true); + table.addField(fieldSHIP_ADDR); + + FieldDefinition field10 = new FieldDefinition(); + field10.setName("ORDER_VERSION"); + field10.setTypeName("NUMERIC"); + field10.setSize(15); + field10.setShouldAllowNull(true ); + field10.setIsPrimaryKey(false ); + field10.setUnique(false ); + field10.setIsIdentity(false ); + table.addField(field10); + + return table; + } + + public static TableDefinition buildCMP3_ORDER_SEQTable() { + TableDefinition table = new TableDefinition(); + table.setName("CMP3_FIELDACCESS_CUSTOMER_SEQ"); + + FieldDefinition fieldSEQ_NAME = new FieldDefinition(); + fieldSEQ_NAME.setName("SEQ_NAME"); + fieldSEQ_NAME.setTypeName("VARCHAR"); + fieldSEQ_NAME.setSize(80); + fieldSEQ_NAME.setSubSize(0); + fieldSEQ_NAME.setIsPrimaryKey(true); + fieldSEQ_NAME.setIsIdentity(false); + fieldSEQ_NAME.setUnique(false); + fieldSEQ_NAME.setShouldAllowNull(false); + table.addField(fieldSEQ_NAME); + + FieldDefinition fieldSEQ_VALUE = new FieldDefinition(); + fieldSEQ_VALUE.setName("SEQ_COUNT"); + fieldSEQ_VALUE.setTypeName("NUMERIC"); + fieldSEQ_VALUE.setSize(15); + fieldSEQ_VALUE.setSubSize(0); + fieldSEQ_VALUE.setIsPrimaryKey(false); + fieldSEQ_VALUE.setIsIdentity(false); + fieldSEQ_VALUE.setUnique(false); + fieldSEQ_VALUE.setShouldAllowNull(false); + table.addField(fieldSEQ_VALUE); + + return table; + } + + public static TableDefinition buildCMP3_SALESPERSONTable() { + TableDefinition table = new TableDefinition(); + table.setName("CMP3_FIELDACCESS_SALESPERSON"); + + FieldDefinition fieldID = new FieldDefinition(); + fieldID.setName("ID"); + fieldID.setTypeName("NUMBER"); + fieldID.setSize(15); + fieldID.setSubSize(0); + fieldID.setIsPrimaryKey(true); + fieldID.setIsIdentity(false); + fieldID.setUnique(false); + fieldID.setShouldAllowNull(false); + table.addField(fieldID); + + 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 buildCUSTOMER_CUSTOMERTable() { + TableDefinition table = new TableDefinition(); + + table.setName("CMP3_FIELDACCESS_CUST_CUST"); + + // 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_FIELDACCESS_CUSTOMER.CUST_ID"); + table.addField(field); + + // SECTION: FIELD + FieldDefinition field1 = new FieldDefinition(); + field1.setName("CONTROLLEDCUSTOMERS_CUST_ID"); + field1.setTypeName("NUMERIC"); + field1.setSize(15); + field1.setShouldAllowNull(false); + field1.setIsPrimaryKey(true); + field1.setUnique(false); + field1.setIsIdentity(false); + field1.setForeignKeyFieldName("CMP3_FIELDACCESS_CUSTOMER.CUST_ID"); + table.addField(field1); + + return table; + } + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/SalesPerson.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000023/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Dec 1 15:50:23 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000023/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:06:23 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/fieldaccess/relationships/SalesPerson.java Fri Dec 1 15:43:50 2006 *************** *** 0 **** --- 1,52 ---- + package oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships; + + + import javax.persistence.*; + import static javax.persistence.GenerationType.*; + import static javax.persistence.CascadeType.*; + import static javax.persistence.FetchType.*; + import java.util.Collection; + + @Entity(name="FieldAccessSalesPerson") + @Table(name="CMP3_FIELDACCESS_SALESPERSON") + public class SalesPerson + { + private String name; + @Id + @GeneratedValue(strategy=TABLE, generator="FIELDACCESS_SALESPERSON_TABLE_GENERATOR") + @TableGenerator( + name="FIELDACCESS_SALESPERSON_TABLE_GENERATOR", + table="CMP3_FIELDACCESS_CUSTOMER_SEQ", + pkColumnName="SEQ_NAME", + valueColumnName="SEQ_COUNT", + pkColumnValue="SALESPERSON_SEQ" + ) + @Column(name="ID") + private int id; + @OneToMany(cascade=ALL, mappedBy="salesPerson") + private Collection orders; + + public SalesPerson() {}; + + 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 Collection getOrders() { + return orders; + } + public void setOrders(Collection orders) { + this.orders = orders; + } + } \ No newline at end of file ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/ExpressionJUnitTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000027/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Dec 1 15:50:23 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000027/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:06:27 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/ExpressionJUnitTestSuite.java Fri Dec 1 15:43:53 2006 *************** *** 0 **** --- 1,319 ---- + /* + * 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.fieldaccess.relationships; + + import java.util.Vector; + + import javax.persistence.EntityManager; + + import oracle.toplink.essentials.expressions.Expression; + import oracle.toplink.essentials.expressions.ExpressionBuilder; + import oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl; + import oracle.toplink.essentials.internal.databaseaccess.Platform; + import oracle.toplink.essentials.queryframework.ReadAllQuery; + import oracle.toplink.essentials.testing.framework.junit.JUnitTestCase; + + import oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships.*; + + public class ExpressionJUnitTestSuite extends JUnitTestCase { + + public ExpressionJUnitTestSuite() { + } + + public ExpressionJUnitTestSuite(String name) { + super(name); + } + + public void setUp () { + super.setUp(); + clearCache(); + new RelationshipsTableManager().replaceTables(JUnitTestCase.getServerSession()); + } + + + /* + * lefTrim(string) feature test + * tests that leftTrim(trim_char) works. + */ + public void testLeftTrimWithTrimChar() throws Exception { + Platform dbPlatform = getDbPlatform(); + if (dbPlatform.isDerby() || dbPlatform.isDB2()) { + getServerSession().logMessage("Test testLeftTrimWithTrimChar skipped for this platform"); + return; + } + + Customer c = RelationshipsExamples.customerExample4(); + //customer4.setCity("Manotick"); + EntityManager em = createEntityManager(); + try{ + + em.getTransaction().begin(); + em.persist(c); + em.getTransaction().commit(); + }catch (Exception e){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + throw e; + } + em.close(); + try{ + ExpressionBuilder builder = new ExpressionBuilder(); + Expression expression = builder.get("city").leftTrim("M").equal("anotick"); + + ReadAllQuery r = new ReadAllQuery(); + r.setReferenceClass(Customer.class); + r.setSelectionCriteria(expression); + Vector v = (Vector)getServerSession().executeQuery(r); + assertTrue("Test error: No Customers found",v.size()!=0 ); + Customer returned = (Customer)v.firstElement(); + assertTrue("Test error: No Customers found","Manotick".equals(returned.getCity()) ); + + }catch(Exception e){ + em = createEntityManager(); + em.getTransaction().begin(); + c = (Customer)em.find(Customer.class, c.getCustomerId()); + em.remove(c); + try{ + em.getTransaction().commit(); + }catch (Throwable t){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + }finally{ + em.close(); + throw e; + } + } + } + + /* + * trim(string) feature test + * tests that trim(trim_char) works. + */ + public void testTrimWithTrimChar() throws Exception { + Platform dbPlatform = getDbPlatform(); + if (dbPlatform.isDerby() || dbPlatform.isDB2()) { + getServerSession().logMessage("Test testTrimWithTrimChar skipped for this platform"); + return; + } + Item i = new Item(); + i.setName("itemi"); + i.setDescription("itemi description"); + EntityManager em = createEntityManager(); + try{ + em.getTransaction().begin(); + em.persist(i); + em.getTransaction().commit(); + }catch (Exception e){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + throw e; + } + em.close(); + try{ + ExpressionBuilder builder = new ExpressionBuilder(); + Expression expression = builder.get("name").trim("i").equal("tem"); + + ReadAllQuery r = new ReadAllQuery(); + r.setReferenceClass(Item.class); + r.setSelectionCriteria(expression); + Vector v = (Vector)getServerSession().executeQuery(r); + assertTrue("Test error: No Items found",v.size()!=0 ); + Item returned = (Item)v.firstElement(); + assertTrue("Test error: No Items found","itemi".equals(returned.getName()) ); + + }catch(Exception e){ + em = createEntityManager(); + try{ + em.getTransaction().begin(); + i = (Item)em.find(Item.class, i.getItemId()); + em.remove(i); + em.getTransaction().commit(); + }catch (Throwable t){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + }finally{ + em.close(); + throw e; + } + } + } + + /* + * trim(string) feature test + * tests that trim() works. + */ + public void testTrimWithoutTrimChar() throws Exception { + Platform dbPlatform = getDbPlatform(); + if (dbPlatform.isDerby() || dbPlatform.isDB2()) { + getServerSession().logMessage("Test testTrimWithTrimChar skipped for this platform"); + return; + } + Item i = new Item(); + i.setName(" tem "); + i.setDescription("itemi description"); + EntityManager em = createEntityManager(); + try{ + em.getTransaction().begin(); + em.persist(i); + em.getTransaction().commit(); + }catch (Exception e){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + throw e; + } + em.close(); + try{ + ExpressionBuilder builder = new ExpressionBuilder(); + Expression expression = builder.get("name").trim().equal("tem"); + + ReadAllQuery r = new ReadAllQuery(); + r.setReferenceClass(Item.class); + r.setSelectionCriteria(expression); + Vector v = (Vector)getServerSession().executeQuery(r); + assertTrue("Test error: No Items found",v.size()!=0 ); + Item returned = (Item)v.firstElement(); + assertTrue("Test error: No Items found"," tem ".equals(returned.getName()) ); + }catch(Exception e){ + em = createEntityManager(); + try{ + em.getTransaction().begin(); + i = (Item)em.find(Item.class, i.getItemId()); + em.remove(i); + em.getTransaction().commit(); + }catch (Throwable t){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + }finally{ + em.close(); + throw e; + } + } + } + + /* + * locate(string) feature test + * tests that locate(string) works. + */ + public void testLocateWithSingleArgument() throws Exception { + Item i = new Item(); + i.setName("itemi"); + i.setDescription("itemi description"); + EntityManager em = createEntityManager(); + try{ + em.getTransaction().begin(); + em.persist(i); + em.getTransaction().commit(); + }catch (Exception e){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + throw e; + } + em.close(); + try{ + ExpressionBuilder builder = new ExpressionBuilder(); + Expression expression = builder.get("name").locate("t").equal(new Integer(2)); + + ReadAllQuery r = new ReadAllQuery(); + r.setReferenceClass(Item.class); + r.setSelectionCriteria(expression); + Vector v = (Vector)getServerSession().executeQuery(r); + assertTrue("Test error: No Items found", v.size()!=0 ); + Item returned = (Item)v.firstElement(); + assertTrue("Test error: IncorrectItem found","itemi".equals(returned.getName()) ); + + }catch(Exception e){ + em = createEntityManager(); + try{ + em.getTransaction().begin(); + i = (Item)em.find(Item.class, i.getItemId()); + em.remove(i); + em.getTransaction().commit(); + }catch (Throwable t){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + }finally{ + em.close(); + throw e; + } + } + } + + /* + * locate(string, int) feature test + * tests that locate(string, int) works. + */ + public void testLocateWithDoubleArgument() throws Exception { + Item i = new Item(); + i.setName("itemi"); + i.setDescription("itemi description"); + EntityManager em = createEntityManager(); + try{ + em.getTransaction().begin(); + em.persist(i); + em.getTransaction().commit(); + }catch (Exception e){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + throw e; + } + em.close(); + try{ + ExpressionBuilder builder = new ExpressionBuilder(); + Expression expression = builder.get("name").locate("i", 2).equal(new Integer(5)); + + ReadAllQuery r = new ReadAllQuery(); + r.setReferenceClass(Item.class); + r.setSelectionCriteria(expression); + Vector v = (Vector)getServerSession().executeQuery(r); + assertTrue("Test error: No Items found", v.size()!=0 ); + Item returned = (Item)v.firstElement(); + assertTrue("Test error: IncorrectItem found","itemi".equals(returned.getName()) ); + + }catch(Exception e){ + em = createEntityManager(); + try{ + em.getTransaction().begin(); + i = (Item)em.find(Item.class, i.getItemId()); + em.remove(i); + em.getTransaction().commit(); + }catch (Throwable t){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + }finally{ + em.close(); + throw e; + } + } + } + + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/IsolatedCacheTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000028/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Dec 1 15:50:23 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000028/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:06:31 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/IsolatedCacheTestSuite.java Fri Dec 1 15:43:56 2006 *************** *** 0 **** --- 1,81 ---- + /* + * 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.fieldaccess.relationships; + + import junit.framework.Test; + import junit.framework.TestSuite; + + import javax.persistence.*; + + import oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl; + import oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork; + import oracle.toplink.essentials.testing.framework.junit.JUnitTestCase; + import oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships.IsolatedItem; + + import oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships.*; + + public class IsolatedCacheTestSuite extends JUnitTestCase { + public IsolatedCacheTestSuite() {} + + public IsolatedCacheTestSuite(String name) { + super(name); + } + + public void setUp () { + super.setUp(); + new RelationshipsTableManager().replaceTables(JUnitTestCase.getServerSession()); + } + + public static Test suite() { + return new TestSuite(IsolatedCacheTestSuite.class) { + protected void setUp(){} + protected void tearDown(){} + }; + } + + public void testCacheIsolationDBQueryHit() throws Exception { + EntityManager em = createEntityManager(); + + // Step 1 - get an isolated item in the cache. + em.getTransaction().begin(); + + IsolatedItem item = new IsolatedItem(); + item.setDescription("A phoney item"); + item.setName("Phoney name"); + em.persist(item); + + em.getTransaction().commit(); + + // Step 2 - clear the entity manager and see if the item still exists + // in the uow cache. + em.getTransaction().begin(); + + em.clear(); + RepeatableWriteUnitOfWork uow = (RepeatableWriteUnitOfWork) ((EntityManagerImpl) em.getDelegate()).getActivePersistenceContext(em.getTransaction()); + + assertFalse("The isolated item was not cleared from the shared cache", uow.getIdentityMapAccessor().containsObjectInIdentityMap(item)); + assertFalse("The isolated item was not cleared from the uow cache", uow.getParent().getIdentityMapAccessor().containsObjectInIdentityMap(item)); + + em.getTransaction().commit(); + em.close(); + } + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/UniAndBiDirectionalMappingTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000029/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Dec 1 15:50:23 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000029/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:06:34 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/UniAndBiDirectionalMappingTestSuite.java Fri Dec 1 15:44:00 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.fieldaccess.relationships; + + import junit.framework.*; + import junit.extensions.TestSetup; + + import javax.persistence.*; + + import oracle.toplink.essentials.sessions.DatabaseSession; + import oracle.toplink.essentials.testing.models.cmp3.fieldaccess.relationships.*; + import oracle.toplink.essentials.testing.framework.junit.JUnitTestCase; + import oracle.toplink.essentials.testing.models.cmp3.fieldaccess.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/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/VirtualAttributeTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000030/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Fri Dec 1 15:50:23 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000030/AB0952363AC40CBFE034080020E8C54E.0 Thu Nov 30 17:06:38 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/fieldaccess/relationships/VirtualAttributeTestSuite.java Fri Dec 1 15:44:03 2006 *************** *** 0 **** --- 1,152 ---- + /* + * 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.fieldaccess.relationships; + + import javax.persistence.EntityManager; + + import oracle.toplink.essentials.testing.framework.junit.JUnitTestCase; + import oracle.toplink.essentials.testing.models.cmp3.virtualattribute.*; + + import oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl; + + import junit.extensions.TestSetup; + import junit.framework.*; + + public class VirtualAttributeTestSuite extends JUnitTestCase { + + protected static int id; + + public VirtualAttributeTestSuite() { + super(); + } + + public VirtualAttributeTestSuite(String name) { + super(name); + } + + public static Test suite() { + TestSuite suite = new TestSuite(); + suite.addTest(new VirtualAttributeTestSuite("testInsertVirtualAttribute")); + suite.addTest(new VirtualAttributeTestSuite("testReadVirtualAttribute")); + suite.addTest(new VirtualAttributeTestSuite("testUpdateVirtualAttribute")); + suite.addTest(new VirtualAttributeTestSuite("testDeleteVirtualAttribute")); + + return new TestSetup(suite) { + protected void setUp(){ + new VirtualAttributeTableCreator().replaceTables(JUnitTestCase.getServerSession()); + } + + protected void tearDown() { + clearCache(); + } + }; + } + + public void setUp () { + super.setUp(); + clearCache(); + } + + public void testInsertVirtualAttribute(){ + EntityManager em = createEntityManager(); + em.getTransaction().begin(); + try{ + OneToOneVirtualAttributeHolder holder = new OneToOneVirtualAttributeHolder(); + VirtualAttribute attribute = new VirtualAttribute(); + attribute.setDescription("virtualAttribute"); + holder.setVirtualAttribute(attribute); + em.persist(holder); + em.flush(); + id = holder.getId(); + em.getTransaction().commit(); + }catch (RuntimeException ex){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + em.close(); + throw ex; + } + } + + public void testReadVirtualAttribute(){ + OneToOneVirtualAttributeHolder holder = createEntityManager().find(OneToOneVirtualAttributeHolder.class, id); + assertNotNull("Object with virtual attributes could not be read.", holder); + assertNotNull("Object held as a virtual attribute was not read with it's owner", holder.getVirtualAttribute()); + } + + public void testUpdateVirtualAttribute(){ + OneToOneVirtualAttributeHolder holder = null; + EntityManager em = createEntityManager(); + em.getTransaction().begin(); + try{ + holder = em.find(OneToOneVirtualAttributeHolder.class, id); + VirtualAttribute attribute = new VirtualAttribute(); + attribute.setDescription("virtualAttribute2"); + holder.setVirtualAttribute(attribute); + em.getTransaction().commit(); + }catch (RuntimeException ex){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + em.close(); + throw ex; + } + clearCache(); + holder = em.find(OneToOneVirtualAttributeHolder.class, id); + em.close(); + assertNotNull("Updated object with virtual attributes could not be read.", holder); + assertNotNull("Updated object held as a virtual attribute was not read with it's owner", holder.getVirtualAttribute()); + assertTrue("Virtual Attribute Object was not updated.", holder.getVirtualAttribute().getDescription().equals("virtualAttribute2")); + } + + public void testDeleteVirtualAttribute(){ + OneToOneVirtualAttributeHolder holder = null; + VirtualAttribute attribute = null; + int attributeId = 0; + EntityManager em = createEntityManager(); + em.getTransaction().begin(); + try{ + holder = em.find(OneToOneVirtualAttributeHolder.class, id); + + attribute = holder.getVirtualAttribute(); + attributeId = attribute.getId(); + holder.setVirtualAttribute(null); + em.remove(attribute); + em.remove(holder); + em.getTransaction().commit(); + }catch (RuntimeException ex){ + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + em.close(); + throw ex; + } + holder = em.find(OneToOneVirtualAttributeHolder.class, id); + assertNull("Object holding virtual attribute was not properly deleted", holder); + attribute =em.find(VirtualAttribute.class, attributeId); + assertNull("Virtual Attribute Object was not properly removed.", attribute); + } + + + } ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/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/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000031/AB0952363AC40CBFE034080020E8C54E.27 Report generated at Fri Dec 1 15:50:23 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000031/AB0952363AC40CBFE034080020E8C54E.27 Thu Nov 30 15:43:18 2006 --- /ade/cdelahun_toplinkmain/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/FullRegressionTestSuite.java Fri Dec 1 15:50:23 2006 *************** *** 114,119 **** --- 114,124 ---- fullSuite.addTest(ValidationTestSuite.suite()); fullSuite.addTest(QueryParameterValidationTestSuite.suite()); fullSuite.addTest(UniAndBiDirectionalMappingTestSuite.suite()); + + // FieldAccess relationship model + fullSuite.addTest(oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships.UniAndBiDirectionalMappingTestSuite.suite()); + fullSuite.addTestSuite(oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships.ExpressionJUnitTestSuite.class); + fullSuite.addTest(oracle.toplink.essentials.testing.tests.cmp3.fieldaccess.relationships.VirtualAttributeTestSuite.suite()); // EJBQL testing model fullSuite.addTest(JUnitEJBQLUnitTestSuite.suite()); ================================================================================ Merge Diffs: /ade/cdelahun_toplinkmain/tltest/resource/essentials/ejb30-testing/META-INF/persistence.xml vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000032/AB0952363AC40CBFE034080020E8C54E.53 Report generated at Fri Dec 1 15:50:23 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/cdelahun/cdelahun_main_gfbug1442_061130/ade_storage/000032/AB0952363AC40CBFE034080020E8C54E.53 Thu Nov 30 16:01:25 2006 --- /ade/cdelahun_toplinkmain/tltest/resource/essentials/ejb30-testing/META-INF/persistence.xml Fri Dec 1 15:50:23 2006 *************** *** 49,54 **** --- 49,55 ---- +