================================================================================ Merge Diffs: /ade/lhillis_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/advanced/EntityManagerJUnitTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/lhillis/lhillis_essentials_gf830_060721/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.45 Report generated at Fri Jul 21 14:04:42 2006 -------------------------------------------------------------------------------- *** /ade/lhillis_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/advanced/EntityManagerJUnitTestSuite.java Fri Jul 21 14:04:42 2006 --- /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/lhillis/lhillis_essentials_gf830_060721/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.45 Fri Jul 21 10:09:58 2006 *************** *** 71,77 **** import oracle.toplink.essentials.threetier.ServerSession; import oracle.toplink.essentials.exceptions.ValidationException; import oracle.toplink.essentials.tools.schemaframework.OracleSequenceDefinition; - public class EntityManagerJUnitTestSuite extends JUnitTestCase { public EntityManagerJUnitTestSuite() { --- 71,76 ---- *************** *** 2290,2386 **** em.close(); } - - //bug gf830 - attempting to merge a removed entity should throw an IllegalArgumentException - public void testMergeRemovedObject() { - //create an Employee - Employee emp = new Employee(); - emp.setFirstName("testMergeRemovedObjectEmployee"); - - //persist the Employee - EntityManager em = createEntityManager(); - try{ - em.getTransaction().begin(); - em.persist(emp); - em.getTransaction().commit(); - }catch (RuntimeException re){ - em.getTransaction().rollback(); - throw re; - } - - em.getTransaction().begin(); - em.remove(emp); //attempt to remove the Employee - try{ - em.merge(emp); //then attempt to merge the Employee - fail("No exception thrown when merging a removed entity is attempted."); - }catch (IllegalArgumentException iae){ - //expected - }catch (Exception e) { - fail("Wrong exception type thrown: " + e.getClass()); - }finally { - em.getTransaction().rollback(); - - //clean up - ensure removal of employee - em.getTransaction().begin(); - em.remove(em.find(Employee.class, emp.getId())); - em.getTransaction().commit(); - em.close(); - } - } - - //merge(null) should throw IllegalArgumentException - public void testMergeNull(){ - EntityManager em = createEntityManager(); - em.getTransaction().begin(); - try { - em.merge(null); - }catch (IllegalArgumentException iae){ - return; - }catch (Exception e) { - fail("Wrong exception type thrown: " + e.getClass()); - }finally { - em.getTransaction().rollback(); - em.close(); - } - fail("No exception thrown when entityManager.merge(null) attempted."); - } - - //persist(null) should throw IllegalArgumentException - public void testPersistNull(){ - EntityManager em = createEntityManager(); - em.getTransaction().begin(); - try { - em.persist(null); - }catch (IllegalArgumentException iae){ - return; - }catch (Exception e) { - fail("Wrong exception type thrown: " + e.getClass()); - }finally { - em.getTransaction().rollback(); - em.close(); - } - fail("No exception thrown when entityManager.persist(null) attempted."); - } - - //contains(null) should throw IllegalArgumentException - public void testContainsNull(){ - EntityManager em = createEntityManager(); - em.getTransaction().begin(); - try { - em.contains(null); - }catch (IllegalArgumentException iae){ - return; - }catch (Exception e) { - fail("Wrong exception type thrown: " + e.getClass()); - }finally { - em.getTransaction().rollback(); - em.close(); - } - fail("No exception thrown when entityManager.contains(null) attempted."); - } ! //bug gf732 - removing null entity should throw an IllegalArgumentException ! public void testRemoveNull(){ EntityManager em = createEntityManager(); em.getTransaction().begin(); try { --- 2289,2297 ---- em.close(); } ! //bug gf732 - removing a null entity should throw an IllegalArgumentException ! public void testEMRemoveNull(){ EntityManager em = createEntityManager(); em.getTransaction().begin(); try { ================================================================================ Merge Diffs: /ade/lhillis_main/tldev/source/essentials/oracle/toplink/essentials/internal/localization/i18n/ExceptionLocalizationResource.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/lhillis/lhillis_essentials_gf830_060721/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.21 Report generated at Fri Jul 21 14:04:42 2006 -------------------------------------------------------------------------------- *** /ade/lhillis_main/tldev/source/essentials/oracle/toplink/essentials/internal/localization/i18n/ExceptionLocalizationResource.java Fri Jul 21 14:04:42 2006 --- /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/lhillis/lhillis_essentials_gf830_060721/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.21 Fri Jul 21 10:38:14 2006 *************** *** 80,86 **** { "new_object_found_during_commit", "During synchronization a new object was found through a relationship that was not marked cascade PERSIST." }, { "cannot_remove_removed_entity", "Entity is already removed: {0}"}, { "cannot_remove_detatched_entity", "Entity must be managed to call remove: {0}, try merging the detached and try the remove again."}, - { "cannot_merge_removed_entity", "Cannot merge an entity that has been removed: {0}"}, { "not_an_entity", "Object: {0} is not a known entity type."}, { "unable_to_find_named_query", "NamedQuery of name: {0} not found."}, { "null_values_for_field_result", "Both Attribute Name and Column Name must be provided for a FieldResult"}, --- 80,85 ---- ================================================================================ Merge Diffs: /ade/lhillis_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/base/EntityManagerImpl.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/lhillis/lhillis_essentials_gf830_060721/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.38 Report generated at Fri Jul 21 14:04:42 2006 -------------------------------------------------------------------------------- *** /ade/lhillis_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/base/EntityManagerImpl.java Fri Jul 21 14:04:42 2006 --- /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/lhillis/lhillis_essentials_gf830_060721/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.38 Fri Jul 21 10:41:46 2006 *************** *** 159,171 **** * If in a transaction this method will check for existence and register the object if * it is new. The instance of the entity provided will become managed. * @param entity - * @throws IllegalArgumentException if the given Object is not an entity */ public void persist(Object entity){ verifyOpen(); - if (entity == null){ - throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[] {entity})); - } try { getActivePersistenceContext(checkForTransaction(!isExtended())).registerNewObjectForPersist(entity, new IdentityHashtable()); } catch (RuntimeException e) { --- 159,167 ---- *************** *** 183,204 **** * class name as the entity name. * @param entity * @return the instance that the state was merged to - * @throws IllegalArgumentException if given Object is not an entity or is a removed entity */ protected Object mergeInternal(Object entity){ ! verifyOpen(); ! if (entity == null){ ! throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[] {entity})); ! } ! //gf830 - merging a removed entity should throw exception ! if (getActivePersistenceContext(checkForTransaction(!isExtended())).getDeletedObjects().contains(entity)){ ! throw new IllegalArgumentException(ExceptionLocalization.buildMessage("cannot_merge_removed_entity", new Object[]{entity})); ! } ! try { ! return getActivePersistenceContext(checkForTransaction(!isExtended())).mergeCloneWithReferences(entity, MergeManager.CASCADE_BY_MAPPING); ! } catch (oracle.toplink.essentials.exceptions.OptimisticLockException ole) { ! throw new javax.persistence.OptimisticLockException(ole); ! } } /** --- 179,192 ---- * class name as the entity name. * @param entity * @return the instance that the state was merged to */ protected Object mergeInternal(Object entity){ ! verifyOpen(); ! try { ! return getActivePersistenceContext(checkForTransaction(!isExtended())).mergeCloneWithReferences(entity, MergeManager.CASCADE_BY_MAPPING); ! } catch (oracle.toplink.essentials.exceptions.OptimisticLockException ole) { ! throw new javax.persistence.OptimisticLockException(ole); ! } } /** *************** *** 224,231 **** * @param entityName * @param primaryKey * @return the found entity instance - * @throws IllegalArgumentException if the first argument does not indicate an entity or if the - * second argument is not a valid type for that entity's primaryKey */ public Object find(String entityName, Object primaryKey){ verifyOpen(); --- 212,217 ---- *************** *** 358,371 **** * context. * @param entity * @return - * @throws IllegalArgumentException if given Object is not an entity */ public boolean contains(Object entity){ verifyOpen(); - if (entity == null){ - throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[] {entity})); - } ClassDescriptor descriptor = (ClassDescriptor)getServerSession().getDescriptors().get(entity.getClass()); if (descriptor == null || descriptor.isAggregateDescriptor() || descriptor.isAggregateCollectionDescriptor()){ throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[]{entity})); } --- 344,355 ---- * context. * @param entity * @return */ public boolean contains(Object entity){ + verifyOpen(); ClassDescriptor descriptor = (ClassDescriptor)getServerSession().getDescriptors().get(entity.getClass()); + if (descriptor == null || descriptor.isAggregateDescriptor() || descriptor.isAggregateCollectionDescriptor()){ throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[]{entity})); } ================================================================================ Merge Diffs: /ade/lhillis_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/advanced/EntityManagerJUnitTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/lhillis/lhillis_essentials_gf830_060721/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.45 Report generated at Fri Jul 21 14:09:27 2006 -------------------------------------------------------------------------------- *** /ade/lhillis_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/advanced/EntityManagerJUnitTestSuite.java Fri Jul 21 14:04:42 2006 --- /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/lhillis/lhillis_essentials_gf830_060721/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.45 Fri Jul 21 10:09:58 2006 *************** *** 71,77 **** import oracle.toplink.essentials.threetier.ServerSession; import oracle.toplink.essentials.exceptions.ValidationException; import oracle.toplink.essentials.tools.schemaframework.OracleSequenceDefinition; - public class EntityManagerJUnitTestSuite extends JUnitTestCase { public EntityManagerJUnitTestSuite() { --- 71,76 ---- *************** *** 2290,2386 **** em.close(); } - - //bug gf830 - attempting to merge a removed entity should throw an IllegalArgumentException - public void testMergeRemovedObject() { - //create an Employee - Employee emp = new Employee(); - emp.setFirstName("testMergeRemovedObjectEmployee"); - - //persist the Employee - EntityManager em = createEntityManager(); - try{ - em.getTransaction().begin(); - em.persist(emp); - em.getTransaction().commit(); - }catch (RuntimeException re){ - em.getTransaction().rollback(); - throw re; - } - - em.getTransaction().begin(); - em.remove(emp); //attempt to remove the Employee - try{ - em.merge(emp); //then attempt to merge the Employee - fail("No exception thrown when merging a removed entity is attempted."); - }catch (IllegalArgumentException iae){ - //expected - }catch (Exception e) { - fail("Wrong exception type thrown: " + e.getClass()); - }finally { - em.getTransaction().rollback(); - - //clean up - ensure removal of employee - em.getTransaction().begin(); - em.remove(em.find(Employee.class, emp.getId())); - em.getTransaction().commit(); - em.close(); - } - } - - //merge(null) should throw IllegalArgumentException - public void testMergeNull(){ - EntityManager em = createEntityManager(); - em.getTransaction().begin(); - try { - em.merge(null); - }catch (IllegalArgumentException iae){ - return; - }catch (Exception e) { - fail("Wrong exception type thrown: " + e.getClass()); - }finally { - em.getTransaction().rollback(); - em.close(); - } - fail("No exception thrown when entityManager.merge(null) attempted."); - } - - //persist(null) should throw IllegalArgumentException - public void testPersistNull(){ - EntityManager em = createEntityManager(); - em.getTransaction().begin(); - try { - em.persist(null); - }catch (IllegalArgumentException iae){ - return; - }catch (Exception e) { - fail("Wrong exception type thrown: " + e.getClass()); - }finally { - em.getTransaction().rollback(); - em.close(); - } - fail("No exception thrown when entityManager.persist(null) attempted."); - } - - //contains(null) should throw IllegalArgumentException - public void testContainsNull(){ - EntityManager em = createEntityManager(); - em.getTransaction().begin(); - try { - em.contains(null); - }catch (IllegalArgumentException iae){ - return; - }catch (Exception e) { - fail("Wrong exception type thrown: " + e.getClass()); - }finally { - em.getTransaction().rollback(); - em.close(); - } - fail("No exception thrown when entityManager.contains(null) attempted."); - } ! //bug gf732 - removing null entity should throw an IllegalArgumentException ! public void testRemoveNull(){ EntityManager em = createEntityManager(); em.getTransaction().begin(); try { --- 2289,2297 ---- em.close(); } ! //bug gf732 - removing a null entity should throw an IllegalArgumentException ! public void testEMRemoveNull(){ EntityManager em = createEntityManager(); em.getTransaction().begin(); try { ================================================================================ Merge Diffs: /ade/lhillis_main/tldev/source/essentials/oracle/toplink/essentials/internal/localization/i18n/ExceptionLocalizationResource.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/lhillis/lhillis_essentials_gf830_060721/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.21 Report generated at Fri Jul 21 14:09:27 2006 -------------------------------------------------------------------------------- *** /ade/lhillis_main/tldev/source/essentials/oracle/toplink/essentials/internal/localization/i18n/ExceptionLocalizationResource.java Fri Jul 21 14:04:42 2006 --- /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/lhillis/lhillis_essentials_gf830_060721/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.21 Fri Jul 21 10:38:14 2006 *************** *** 80,86 **** { "new_object_found_during_commit", "During synchronization a new object was found through a relationship that was not marked cascade PERSIST." }, { "cannot_remove_removed_entity", "Entity is already removed: {0}"}, { "cannot_remove_detatched_entity", "Entity must be managed to call remove: {0}, try merging the detached and try the remove again."}, - { "cannot_merge_removed_entity", "Cannot merge an entity that has been removed: {0}"}, { "not_an_entity", "Object: {0} is not a known entity type."}, { "unable_to_find_named_query", "NamedQuery of name: {0} not found."}, { "null_values_for_field_result", "Both Attribute Name and Column Name must be provided for a FieldResult"}, --- 80,85 ---- ================================================================================ Merge Diffs: /ade/lhillis_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/base/EntityManagerImpl.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/lhillis/lhillis_essentials_gf830_060721/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.38 Report generated at Fri Jul 21 14:09:27 2006 -------------------------------------------------------------------------------- *** /ade/lhillis_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/base/EntityManagerImpl.java Fri Jul 21 14:04:42 2006 --- /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/lhillis/lhillis_essentials_gf830_060721/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.38 Fri Jul 21 10:41:46 2006 *************** *** 159,171 **** * If in a transaction this method will check for existence and register the object if * it is new. The instance of the entity provided will become managed. * @param entity - * @throws IllegalArgumentException if the given Object is not an entity */ public void persist(Object entity){ verifyOpen(); - if (entity == null){ - throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[] {entity})); - } try { getActivePersistenceContext(checkForTransaction(!isExtended())).registerNewObjectForPersist(entity, new IdentityHashtable()); } catch (RuntimeException e) { --- 159,167 ---- *************** *** 183,204 **** * class name as the entity name. * @param entity * @return the instance that the state was merged to - * @throws IllegalArgumentException if given Object is not an entity or is a removed entity */ protected Object mergeInternal(Object entity){ ! verifyOpen(); ! if (entity == null){ ! throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[] {entity})); ! } ! //gf830 - merging a removed entity should throw exception ! if (getActivePersistenceContext(checkForTransaction(!isExtended())).getDeletedObjects().contains(entity)){ ! throw new IllegalArgumentException(ExceptionLocalization.buildMessage("cannot_merge_removed_entity", new Object[]{entity})); ! } ! try { ! return getActivePersistenceContext(checkForTransaction(!isExtended())).mergeCloneWithReferences(entity, MergeManager.CASCADE_BY_MAPPING); ! } catch (oracle.toplink.essentials.exceptions.OptimisticLockException ole) { ! throw new javax.persistence.OptimisticLockException(ole); ! } } /** --- 179,192 ---- * class name as the entity name. * @param entity * @return the instance that the state was merged to */ protected Object mergeInternal(Object entity){ ! verifyOpen(); ! try { ! return getActivePersistenceContext(checkForTransaction(!isExtended())).mergeCloneWithReferences(entity, MergeManager.CASCADE_BY_MAPPING); ! } catch (oracle.toplink.essentials.exceptions.OptimisticLockException ole) { ! throw new javax.persistence.OptimisticLockException(ole); ! } } /** *************** *** 224,231 **** * @param entityName * @param primaryKey * @return the found entity instance - * @throws IllegalArgumentException if the first argument does not indicate an entity or if the - * second argument is not a valid type for that entity's primaryKey */ public Object find(String entityName, Object primaryKey){ verifyOpen(); --- 212,217 ---- *************** *** 358,371 **** * context. * @param entity * @return - * @throws IllegalArgumentException if given Object is not an entity */ public boolean contains(Object entity){ verifyOpen(); - if (entity == null){ - throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[] {entity})); - } ClassDescriptor descriptor = (ClassDescriptor)getServerSession().getDescriptors().get(entity.getClass()); if (descriptor == null || descriptor.isAggregateDescriptor() || descriptor.isAggregateCollectionDescriptor()){ throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[]{entity})); } --- 344,355 ---- * context. * @param entity * @return */ public boolean contains(Object entity){ + verifyOpen(); ClassDescriptor descriptor = (ClassDescriptor)getServerSession().getDescriptors().get(entity.getClass()); + if (descriptor == null || descriptor.isAggregateDescriptor() || descriptor.isAggregateCollectionDescriptor()){ throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[]{entity})); }