================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/base/EJBQueryImpl.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.45 Report generated at Thu Nov 30 16:13:51 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.45 Thu Nov 30 15:38:24 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/base/EJBQueryImpl.java Thu Nov 30 16:13:50 2006 *************** *** 356,375 **** * @return the number of entities updated or deleted */ public int executeUpdate() { ! //bug51411440: need to throw IllegalStateException if query executed on closed em ! entityManager.verifyOpen(); ! setAsSQLModifyQuery(); ! //bug:4294241, only allow modify queries - UpdateAllQuery prefered ! if ( !(getDatabaseQuery() instanceof ModifyQuery) ){ ! throw new IllegalStateException(ExceptionLocalization.buildMessage("incorrect_query_for_execute_update")); ! } ! //fix for bug:4288845, did not add the parameters to the query ! Vector parameterValues = processParameters(); ! if(isFlushModeAUTO()) { ! performPreQueryFlush(); } - Integer changedRows = (Integer)((Session)getActiveSession()).executeQuery(databaseQuery, parameterValues); - return changedRows.intValue(); } /** --- 356,380 ---- * @return the number of entities updated or deleted */ public int executeUpdate() { ! try { ! //bug51411440: need to throw IllegalStateException if query executed on closed em ! entityManager.verifyOpen(); ! setAsSQLModifyQuery(); ! //bug:4294241, only allow modify queries - UpdateAllQuery prefered ! if ( !(getDatabaseQuery() instanceof ModifyQuery) ){ ! throw new IllegalStateException(ExceptionLocalization.buildMessage("incorrect_query_for_execute_update")); ! } ! //fix for bug:4288845, did not add the parameters to the query ! Vector parameterValues = processParameters(); ! if(isFlushModeAUTO()) { ! performPreQueryFlush(); ! } ! Integer changedRows = (Integer)((Session)getActiveSession()).executeQuery(databaseQuery, parameterValues); ! return changedRows.intValue(); ! } catch (RuntimeException e) { ! setRollbackOnly(); ! throw e; } } /** *************** *** 428,451 **** * @return a list of the results */ public List getResultList() { ! //bug51411440: need to throw IllegalStateException if query executed on closed em ! entityManager.verifyOpen(); ! setAsSQLReadQuery(); ! propagateResultProperties(); ! //bug:4297903, check container policy class and throw exception if its not the right type ! if (getDatabaseQuery() instanceof ReadAllQuery){ ! Class containerClass = ((ReadAllQuery)getDatabaseQuery()).getContainerPolicy().getContainerClass(); ! if (! Helper.classImplementsInterface(containerClass, ClassConstants.List_Class)){ ! throw QueryException.invalidContainerClass( containerClass, ClassConstants.List_Class ); ! } ! } else if (getDatabaseQuery() instanceof ReadObjectQuery){ ! //bug:4300879, handle ReadObjectQuery returning null ! throw QueryException.incorrectQueryObjectFound( getDatabaseQuery(), ReadAllQuery.class ); ! } else if (!(getDatabaseQuery() instanceof ReadQuery)){ ! throw new IllegalStateException(ExceptionLocalization.buildMessage("incorrect_query_for_get_result_list")); } - Object result = executeReadQuery(); - return (List)result; } /** --- 433,461 ---- * @return a list of the results */ public List getResultList() { ! try { ! //bug51411440: need to throw IllegalStateException if query executed on closed em ! entityManager.verifyOpen(); ! setAsSQLReadQuery(); ! propagateResultProperties(); ! //bug:4297903, check container policy class and throw exception if its not the right type ! if (getDatabaseQuery() instanceof ReadAllQuery){ ! Class containerClass = ((ReadAllQuery)getDatabaseQuery()).getContainerPolicy().getContainerClass(); ! if (! Helper.classImplementsInterface(containerClass, ClassConstants.List_Class)){ ! throw QueryException.invalidContainerClass( containerClass, ClassConstants.List_Class ); ! } ! } else if (getDatabaseQuery() instanceof ReadObjectQuery){ ! //bug:4300879, handle ReadObjectQuery returning null ! throw QueryException.incorrectQueryObjectFound( getDatabaseQuery(), ReadAllQuery.class ); ! } else if (!(getDatabaseQuery() instanceof ReadQuery)){ ! throw new IllegalStateException(ExceptionLocalization.buildMessage("incorrect_query_for_get_result_list")); ! } ! Object result = executeReadQuery(); ! return (List)result; ! } catch (RuntimeException e) { ! setRollbackOnly(); ! throw e; } } /** *************** *** 455,487 **** * @throws NonUniqueResultException if more than one result */ public Object getSingleResult() { ! //bug51411440: need to throw IllegalStateException if query executed on closed em ! entityManager.verifyOpen(); ! setAsSQLReadQuery(); ! propagateResultProperties(); ! //bug:4301674, requires lists to be returned from ReadAllQuery objects ! if (getDatabaseQuery() instanceof ReadAllQuery){ ! Class containerClass = ((ReadAllQuery)getDatabaseQuery()).getContainerPolicy().getContainerClass(); ! if (! Helper.classImplementsInterface(containerClass, ClassConstants.List_Class)){ ! throw QueryException.invalidContainerClass( containerClass, ClassConstants.List_Class ); ! } ! } else if (!(getDatabaseQuery() instanceof ReadQuery)){ ! throw new IllegalStateException(ExceptionLocalization.buildMessage("incorrect_query_for_get_single_result")); ! } ! Object result = executeReadQuery(); ! if (result instanceof List){ ! List results = (List)result; ! if (results.isEmpty()) { ! throwNoResultException(ExceptionLocalization.buildMessage("no_entities_retrieved_for_get_single_result", (Object[])null)); ! } else if (results.size() > 1) { ! throwNonUniqueResultException(ExceptionLocalization.buildMessage("too_many_results_for_get_single_result", (Object[])null)); ! } ! return results.get(0); ! }else{ ! if (result == null) { ! throwNoResultException(ExceptionLocalization.buildMessage("no_entities_retrieved_for_get_single_result", (Object[])null)); } ! return result; } } --- 465,508 ---- * @throws NonUniqueResultException if more than one result */ public Object getSingleResult() { ! boolean rollbackOnException = true; ! try { ! //bug51411440: need to throw IllegalStateException if query executed on closed em ! entityManager.verifyOpen(); ! setAsSQLReadQuery(); ! propagateResultProperties(); ! //bug:4301674, requires lists to be returned from ReadAllQuery objects ! if (getDatabaseQuery() instanceof ReadAllQuery){ ! Class containerClass = ((ReadAllQuery)getDatabaseQuery()).getContainerPolicy().getContainerClass(); ! if (! Helper.classImplementsInterface(containerClass, ClassConstants.List_Class)){ ! throw QueryException.invalidContainerClass( containerClass, ClassConstants.List_Class ); ! } ! } else if (!(getDatabaseQuery() instanceof ReadQuery)){ ! throw new IllegalStateException(ExceptionLocalization.buildMessage("incorrect_query_for_get_single_result")); ! } ! Object result = executeReadQuery(); ! if (result instanceof List){ ! List results = (List)result; ! if (results.isEmpty()) { ! rollbackOnException = false; ! throwNoResultException(ExceptionLocalization.buildMessage("no_entities_retrieved_for_get_single_result", (Object[])null)); ! } else if (results.size() > 1) { ! rollbackOnException = false; ! throwNonUniqueResultException(ExceptionLocalization.buildMessage("too_many_results_for_get_single_result", (Object[])null)); ! } ! return results.get(0); ! }else{ ! if (result == null) { ! rollbackOnException = false; ! throwNoResultException(ExceptionLocalization.buildMessage("no_entities_retrieved_for_get_single_result", (Object[])null)); ! } ! return result; ! } ! } catch (RuntimeException e) { ! if(rollbackOnException) { ! setRollbackOnly(); } ! throw e; } } *************** *** 656,660 **** this.entityManager.flush(); } } ! } --- 677,684 ---- this.entityManager.flush(); } } ! ! protected void setRollbackOnly() { ! entityManager.setRollbackOnly(); ! } } ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/base/EntityManagerImpl.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.43 Report generated at Thu Nov 30 16:13:51 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.43 Thu Nov 30 15:39:00 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/base/EntityManagerImpl.java Thu Nov 30 16:13:50 2006 *************** *** 143,148 **** --- 143,164 ---- * persisted. */ public void clear(){ + try { + verifyOpen(); + clearInternal(); + } catch (RuntimeException e) { + this.setRollbackOnly(); + throw e; + } + } + + /** + * Clear the persistence context, causing all managed + * entities to become detached. Changes made to entities that + * have not been flushed to the database will not be + * persisted. + */ + public void clearInternal(){ if (this.isExtended()){ if (this.extendedPersistenceContext != null) { if (checkForTransaction(false) != null){ *************** *** 167,185 **** * @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) { ! this.transaction.setRollbackOnlyInternal(); ! if (ValidationException.class.isAssignableFrom(e.getClass())){ ! throw new EntityExistsException(e.getLocalizedMessage() , e); } throw e; ! } } /** --- 183,205 ---- * @throws IllegalArgumentException if the given Object is not an entity */ public void persist(Object entity){ try { ! 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) { + if (ValidationException.class.isAssignableFrom(e.getClass())){ + throw new EntityExistsException(e.getLocalizedMessage() , e); + } + throw e; + } + } catch (RuntimeException e) { + this.setRollbackOnly(); throw e; ! } } /** *************** *** 191,197 **** * @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})); } --- 211,216 ---- *************** *** 212,217 **** --- 231,237 ---- * @throws IllegalArgumentException if Object passed in is not an entity */ public void remove(Object entity){ + try { verifyOpen(); if (entity == null){ //gf732 - check for null throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[] {entity})); *************** *** 219,227 **** try{ getActivePersistenceContext(checkForTransaction(!isExtended())).performRemove(entity, new IdentityHashtable()); }catch (RuntimeException e){ - this.transaction.setRollbackOnlyInternal(); throw e; } } /** --- 239,250 ---- try{ getActivePersistenceContext(checkForTransaction(!isExtended())).performRemove(entity, new IdentityHashtable()); }catch (RuntimeException e){ throw e; } + } catch (RuntimeException e) { + this.setRollbackOnly(); + throw e; + } } /** *************** *** 233,256 **** * second argument is not a valid type for that entity's primaryKey */ public Object find(String entityName, Object primaryKey){ verifyOpen(); ! try{ ! Session session = getActiveSession(); ! ClassDescriptor descriptor = session.getDescriptorForAlias(entityName); ! if (descriptor == null || descriptor.isAggregateDescriptor() || descriptor.isAggregateCollectionDescriptor()){ ! throw new IllegalArgumentException(ExceptionLocalization.buildMessage("unknown_entitybean_name", new Object[] {entityName})); ! } ! if (primaryKey == null){ //gf721 - check for null PK ! throw new IllegalArgumentException(ExceptionLocalization.buildMessage("null_pk")); ! } ! if ( ((CMP3Policy)descriptor.getCMPPolicy()).getPKClass() != null && !((CMP3Policy)descriptor.getCMPPolicy()).getPKClass().isAssignableFrom(primaryKey.getClass())){ ! throw new IllegalArgumentException(ExceptionLocalization.buildMessage("invalid_pk_class", new Object[] {((CMP3Policy)descriptor.getCMPPolicy()).getPKClass(), primaryKey.getClass()})); ! } ! return findInternal(descriptor, session, primaryKey); ! }catch (RuntimeException e){ ! this.transaction.setRollbackOnlyInternal(); ! throw e; } } /** --- 256,279 ---- * second argument is not a valid type for that entity's primaryKey */ public Object find(String entityName, Object primaryKey){ + try { verifyOpen(); ! Session session = getActiveSession(); ! ClassDescriptor descriptor = session.getDescriptorForAlias(entityName); ! if (descriptor == null || descriptor.isAggregateDescriptor() || descriptor.isAggregateCollectionDescriptor()){ ! throw new IllegalArgumentException(ExceptionLocalization.buildMessage("unknown_entitybean_name", new Object[] {entityName})); } + if (primaryKey == null){ //gf721 - check for null PK + throw new IllegalArgumentException(ExceptionLocalization.buildMessage("null_pk")); + } + if ( ((CMP3Policy)descriptor.getCMPPolicy()).getPKClass() != null && !((CMP3Policy)descriptor.getCMPPolicy()).getPKClass().isAssignableFrom(primaryKey.getClass())){ + throw new IllegalArgumentException(ExceptionLocalization.buildMessage("invalid_pk_class", new Object[] {((CMP3Policy)descriptor.getCMPPolicy()).getPKClass(), primaryKey.getClass()})); + } + return findInternal(descriptor, session, primaryKey); + } catch (RuntimeException e) { + this.setRollbackOnly(); + throw e; + } } /** *************** *** 264,270 **** * entity's primary key */ protected Object findInternal(Class entityClass, Object primaryKey) { - verifyOpen(); Session session = getActiveSession(); ClassDescriptor descriptor = session.getDescriptor(entityClass); if (descriptor == null || descriptor.isAggregateDescriptor() || descriptor.isAggregateCollectionDescriptor()){ --- 287,292 ---- *************** *** 308,324 **** * underlying database. */ public void flush(){ verifyOpen(); try { getActivePersistenceContext(checkForTransaction(true)).writeChanges(); }catch (RuntimeException e) { - this.transaction.setRollbackOnlyInternal(); if (TopLinkException.class.isAssignableFrom(e.getClass())){ throw new PersistenceException(e); } throw e; } } protected void detectTransactionWrapper(){ --- 330,350 ---- * underlying database. */ public void flush(){ + try { verifyOpen(); try { getActivePersistenceContext(checkForTransaction(true)).writeChanges(); }catch (RuntimeException e) { if (TopLinkException.class.isAssignableFrom(e.getClass())){ throw new PersistenceException(e); } throw e; } + } catch (RuntimeException e) { + this.setRollbackOnly(); + throw e; + } } protected void detectTransactionWrapper(){ *************** *** 335,361 **** * @param entity */ public void refresh(Object entity){ ! verifyOpen(); ! UnitOfWork uow = getActivePersistenceContext(checkForTransaction(!isExtended())); ! if(!contains(entity, uow)) { ! this.transaction.setRollbackOnlyInternal(); ! throw new IllegalArgumentException(ExceptionLocalization.buildMessage("cant_refresh_not_managed_object", new Object[]{entity})); ! } ! ReadObjectQuery query = new ReadObjectQuery(); ! query.setSelectionObject(entity); ! query.refreshIdentityMapResult(); ! query.cascadeByMapping(); ! query.setLockMode(ObjectBuildingQuery.NO_LOCK); ! Object refreshedEntity = null; ! try{ ! refreshedEntity = uow.executeQuery(query); ! }catch (RuntimeException e){ ! this.transaction.setRollbackOnlyInternal(); throw e; } - if(refreshedEntity == null) { - throw new EntityNotFoundException(ExceptionLocalization.buildMessage("entity_no_longer_exists_in_db", new Object[]{entity})); - } } /** --- 361,386 ---- * @param entity */ public void refresh(Object entity){ ! try { ! verifyOpen(); ! UnitOfWork uow = getActivePersistenceContext(checkForTransaction(!isExtended())); ! if(!contains(entity, uow)) { ! throw new IllegalArgumentException(ExceptionLocalization.buildMessage("cant_refresh_not_managed_object", new Object[]{entity})); ! } ! ReadObjectQuery query = new ReadObjectQuery(); ! query.setSelectionObject(entity); ! query.refreshIdentityMapResult(); ! query.cascadeByMapping(); ! query.setLockMode(ObjectBuildingQuery.NO_LOCK); ! Object refreshedEntity = null; ! refreshedEntity = uow.executeQuery(query); ! if(refreshedEntity == null) { ! throw new EntityNotFoundException(ExceptionLocalization.buildMessage("entity_no_longer_exists_in_db", new Object[]{entity})); ! } ! } catch (RuntimeException e) { ! this.setRollbackOnly(); throw e; } } /** *************** *** 366,385 **** * @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})); ! } ! ! if( (!hasActivePersistenceContext())) { ! return false; } - - return contains(entity,getActivePersistenceContext(checkForTransaction(false))); } /** --- 391,415 ---- * @throws IllegalArgumentException if given Object is not an entity */ public boolean contains(Object entity){ ! try { ! 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})); ! } ! ! if( (!hasActivePersistenceContext())) { ! return false; ! } ! ! return contains(entity,getActivePersistenceContext(checkForTransaction(false))); ! } catch (RuntimeException e) { ! this.setRollbackOnly(); ! throw e; } } /** *************** *** 417,423 **** * specific. */ public Object getDelegate(){ ! return this; } /** --- 447,459 ---- * specific. */ public Object getDelegate(){ ! try { ! verifyOpen(); ! return this; ! } catch (RuntimeException e) { ! this.setRollbackOnly(); ! throw e; ! } } /** *************** *** 448,454 **** * return type. */ protected DatabaseQuery createNativeQueryInternal(String sqlString, Class resultType){ - verifyOpen(); ReadAllQuery query = new ReadAllQuery(resultType); query.setSQLString(sqlString); query.setIsUserDefined(true); --- 484,489 ---- *************** *** 478,492 **** * transactions.

*/ public void close(){ - verifyOpen(); - isOpen = false; try { ! if (!transaction.shouldClose()){ ! this.transaction.markLastTransaction(); ! } ! } finally { factory = null; serverSession = null; } } --- 513,526 ---- * transactions.

*/ public void close(){ try { ! verifyOpen(); ! isOpen = false; factory = null; serverSession = null; + } catch (RuntimeException e) { + this.setRollbackOnly(); + throw e; } } *************** *** 515,528 **** * @throws TransactionRequiredException if there is no transaction */ public void lock(Object entity, LockModeType lockMode){ ! RepeatableWriteUnitOfWork context = getActivePersistenceContext(checkForTransaction(!isExtended())); ! ClassDescriptor descriptor = context.getDescriptor(entity); ! OptimisticLockingPolicy lockingPolicy = descriptor.getOptimisticLockingPolicy(); ! if ((lockingPolicy == null) || !(lockingPolicy instanceof VersionLockingPolicy)){ ! this.transaction.setRollbackOnlyInternal(); ! throw new PersistenceException(ExceptionLocalization.buildMessage("ejb30-wrong-lock_called_without_version_locking-index", null)); } - context.forceUpdateToVersionField(entity, (lockMode == LockModeType.WRITE)); } public void verifyOpen(){ --- 549,567 ---- * @throws TransactionRequiredException if there is no transaction */ public void lock(Object entity, LockModeType lockMode){ ! try { ! verifyOpen(); ! RepeatableWriteUnitOfWork context = getActivePersistenceContext(checkForTransaction(!isExtended())); ! ClassDescriptor descriptor = context.getDescriptor(entity); ! OptimisticLockingPolicy lockingPolicy = descriptor.getOptimisticLockingPolicy(); ! if ((lockingPolicy == null) || !(lockingPolicy instanceof VersionLockingPolicy)){ ! throw new PersistenceException(ExceptionLocalization.buildMessage("ejb30-wrong-lock_called_without_version_locking-index", null)); ! } ! context.forceUpdateToVersionField(entity, (lockMode == LockModeType.WRITE)); ! } catch (RuntimeException e) { ! this.setRollbackOnly(); ! throw e; } } public void verifyOpen(){ *************** *** 594,599 **** * no transaction. */ public void joinTransaction(){ ! transaction.registerUnitOfWorkWithTxn(getActivePersistenceContext(checkForTransaction(true))); } } --- 633,651 ---- * no transaction. */ public void joinTransaction(){ ! try { ! verifyOpen(); ! transaction.registerUnitOfWorkWithTxn(getActivePersistenceContext(checkForTransaction(true))); ! } catch (RuntimeException e) { ! this.setRollbackOnly(); ! throw e; ! } ! } ! ! /** ! * Internal method. Sets transaction to rollback only. ! */ ! protected void setRollbackOnly() { ! this.transaction.setRollbackOnlyInternal(); } } ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/EJBQueryImpl.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.12 Report generated at Thu Nov 30 16:13:51 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.12 Thu Nov 30 15:42:42 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/EJBQueryImpl.java Thu Nov 30 16:13:50 2006 *************** *** 110,117 **** * @return the same query instance */ public Query setFirstResult(int startPosition) { ! setFirstResultInternal(startPosition); ! return this; } /** --- 110,123 ---- * @return the same query instance */ public Query setFirstResult(int startPosition) { ! try { ! entityManager.verifyOpen(); ! setFirstResultInternal(startPosition); ! return this; ! } catch (RuntimeException e) { ! setRollbackOnly(); ! throw e; ! } } /** *************** *** 119,130 **** * @param flushMode */ public Query setFlushMode(FlushModeType flushMode) { ! if (flushMode == null) { ! getDatabaseQuery().setFlushOnExecute(null); ! } else { ! getDatabaseQuery().setFlushOnExecute(flushMode == FlushModeType.AUTO); } - return this; } /** --- 125,142 ---- * @param flushMode */ public Query setFlushMode(FlushModeType flushMode) { ! try { ! entityManager.verifyOpen(); ! if (flushMode == null) { ! getDatabaseQuery().setFlushOnExecute(null); ! } else { ! getDatabaseQuery().setFlushOnExecute(flushMode == FlushModeType.AUTO); ! } ! return this; ! } catch (RuntimeException e) { ! setRollbackOnly(); ! throw e; } } /** *************** *** 137,144 **** * valid for the implementation */ public Query setHint(String hintName, Object value) { ! setHintInternal(hintName, value); ! return this; } /** --- 149,162 ---- * valid for the implementation */ public Query setHint(String hintName, Object value) { ! try { ! entityManager.verifyOpen(); ! setHintInternal(hintName, value); ! return this; ! } catch (RuntimeException e) { ! setRollbackOnly(); ! throw e; ! } } /** *************** *** 147,154 **** * @return the same query instance */ public Query setMaxResults(int maxResult) { ! setMaxResultsInternal(maxResult); ! return this; } /** --- 165,178 ---- * @return the same query instance */ public Query setMaxResults(int maxResult) { ! try { ! entityManager.verifyOpen(); ! setMaxResultsInternal(maxResult); ! return this; ! } catch (RuntimeException e) { ! setRollbackOnly(); ! throw e; ! } } /** *************** *** 158,165 **** * @return the same query instance */ public Query setParameter(String name, Object value) { ! setParameterInternal(name, value); ! return this; } /** --- 182,195 ---- * @return the same query instance */ public Query setParameter(String name, Object value) { ! try { ! entityManager.verifyOpen(); ! setParameterInternal(name, value); ! return this; ! } catch (RuntimeException e) { ! setRollbackOnly(); ! throw e; ! } } /** *************** *** 191,198 **** * @return the same query instance */ public Query setParameter(int position, Object value) { ! setParameterInternal(position, value); ! return this; } /** --- 221,234 ---- * @return the same query instance */ public Query setParameter(int position, Object value) { ! try { ! entityManager.verifyOpen(); ! setParameterInternal(position, value); ! return this; ! } catch (RuntimeException e) { ! setRollbackOnly(); ! throw e; ! } } /** ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/EntityManagerImpl.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.16 Report generated at Thu Nov 30 16:13:51 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.16 Thu Nov 30 15:42:59 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/EntityManagerImpl.java Thu Nov 30 16:13:50 2006 *************** *** 108,119 **** * @return the instance that the state was merged to */ public T merge(T entity){ ! try{ ! return (T) mergeInternal(entity); ! }catch (RuntimeException e){ ! this.transaction.setRollbackOnlyInternal(); ! throw e; ! } } /** --- 108,120 ---- * @return the instance that the state was merged to */ public T merge(T entity){ ! try{ ! verifyOpen(); ! return (T) mergeInternal(entity); ! }catch (RuntimeException e){ ! this.transaction.setRollbackOnlyInternal(); ! throw e; ! } } /** *************** *** 127,133 **** * entity's primary key */ public T find(Class entityClass, Object primaryKey){ ! return (T) findInternal(entityClass, primaryKey); } /** --- 128,140 ---- * entity's primary key */ public T find(Class entityClass, Object primaryKey){ ! try { ! verifyOpen(); ! return (T) findInternal(entityClass, primaryKey); ! } catch (RuntimeException e) { ! this.transaction.setRollbackOnlyInternal(); ! throw e; ! } } /** *************** *** 149,161 **** * cannot be accessed */ public T getReference(Class entityClass, Object primaryKey) { ! Object returnValue = findInternal(entityClass, primaryKey); ! if (returnValue ==null){ ! Object[] o = {primaryKey}; ! String message = ExceptionLocalization.buildMessage("no_entities_retrieved_for_get_reference", o); ! throw new javax.persistence.EntityNotFoundException(message); } - return (T)returnValue; } /** --- 156,174 ---- * cannot be accessed */ public T getReference(Class entityClass, Object primaryKey) { ! try { ! verifyOpen(); ! Object returnValue = findInternal(entityClass, primaryKey); ! if (returnValue ==null){ ! Object[] o = {primaryKey}; ! String message = ExceptionLocalization.buildMessage("no_entities_retrieved_for_get_reference", o); ! throw new javax.persistence.EntityNotFoundException(message); ! } ! return (T)returnValue; ! } catch (RuntimeException e) { ! this.transaction.setRollbackOnlyInternal(); ! throw e; } } /** *************** *** 166,186 **** */ public Query createQuery(String ejbqlString){ ! verifyOpen(); ! ! EJBQueryImpl ejbqImpl; ! ! try ! { ! ejbqImpl = new EJBQueryImpl(ejbqlString, this); ! } ! ! catch(EJBQLException ex) ! { ! throw new IllegalArgumentException(ExceptionLocalization.buildMessage("wrap_ejbql_exception"), ex); } - - return ejbqImpl; } /** * Create an instance of Query for executing a --- 179,204 ---- */ public Query createQuery(String ejbqlString){ ! try { ! verifyOpen(); ! ! EJBQueryImpl ejbqImpl; ! ! try ! { ! ejbqImpl = new EJBQueryImpl(ejbqlString, this); ! } ! ! catch(EJBQLException ex) ! { ! throw new IllegalArgumentException(ExceptionLocalization.buildMessage("wrap_ejbql_exception"), ex); ! } ! ! return ejbqImpl; ! } catch (RuntimeException e) { ! this.transaction.setRollbackOnlyInternal(); ! throw e; } } /** * Create an instance of Query for executing a *************** *** 189,196 **** * @return the new query instance */ public Query createNamedQuery(String name){ ! verifyOpen(); ! return new EJBQueryImpl(name, this, true); } /** * Create an instance of Query for executing --- 207,219 ---- * @return the new query instance */ public Query createNamedQuery(String name){ ! try { ! verifyOpen(); ! return new EJBQueryImpl(name, this, true); ! } catch (RuntimeException e) { ! this.transaction.setRollbackOnlyInternal(); ! throw e; ! } } /** * Create an instance of Query for executing *************** *** 199,215 **** * @return the new query instance */ public Query createNativeQuery(String sqlString){ ! verifyOpen(); ! return new EJBQueryImpl( EJBQueryImpl.buildSQLDatabaseQuery( sqlString, false), this ); } /** * This method is used to create a query using SQL. The class, must be the expected * return type. */ ! public javax.persistence.Query createNativeQuery(String sqlString, Class resultType){ ! DatabaseQuery query = createNativeQueryInternal(sqlString, resultType); ! return new EJBQueryImpl(query, this); } /** --- 222,249 ---- * @return the new query instance */ public Query createNativeQuery(String sqlString){ ! try { ! verifyOpen(); ! return new EJBQueryImpl( EJBQueryImpl.buildSQLDatabaseQuery( sqlString, false), this ); ! } catch (RuntimeException e) { ! this.transaction.setRollbackOnlyInternal(); ! throw e; ! } } /** * This method is used to create a query using SQL. The class, must be the expected * return type. */ ! public Query createNativeQuery(String sqlString, Class resultType){ ! try { ! verifyOpen(); ! DatabaseQuery query = createNativeQueryInternal(sqlString, resultType); ! return new EJBQueryImpl(query, this); ! } catch (RuntimeException e) { ! this.transaction.setRollbackOnlyInternal(); ! throw e; ! } } /** *************** *** 221,232 **** * @throws IllegalArgumentException if query string is not valid */ public Query createNativeQuery(String sqlString, String resultSetMapping){ ! verifyOpen(); ! ResultSetMappingQuery query = new ResultSetMappingQuery(); ! query.setSQLResultSetMappingName(resultSetMapping); ! query.setSQLString(sqlString); ! query.setIsUserDefined(true); ! return new EJBQueryImpl(query, this); } /** --- 255,271 ---- * @throws IllegalArgumentException if query string is not valid */ public Query createNativeQuery(String sqlString, String resultSetMapping){ ! try { ! verifyOpen(); ! ResultSetMappingQuery query = new ResultSetMappingQuery(); ! query.setSQLResultSetMappingName(resultSetMapping); ! query.setSQLString(sqlString); ! query.setIsUserDefined(true); ! return new EJBQueryImpl(query, this); ! } catch (RuntimeException e) { ! this.transaction.setRollbackOnlyInternal(); ! throw e; ! } } /** *************** *** 235,241 **** * @return flushMode */ public FlushModeType getFlushMode() { ! return flushMode; } /** --- 274,286 ---- * @return flushMode */ public FlushModeType getFlushMode() { ! try { ! verifyOpen(); ! return flushMode; ! } catch (RuntimeException e) { ! this.transaction.setRollbackOnlyInternal(); ! throw e; ! } } /** *************** *** 244,258 **** * @param flushMode */ public void setFlushMode(FlushModeType flushMode) { ! this.flushMode = flushMode; } /** * This method is used to create a query using a Toplink Expression and the return type. */ public javax.persistence.Query createQuery(Expression expression, Class resultType){ ! DatabaseQuery query = createQueryInternal(expression, resultType); ! return new EJBQueryImpl(query, this); } /** --- 289,315 ---- * @param flushMode */ public void setFlushMode(FlushModeType flushMode) { ! try { ! verifyOpen(); ! this.flushMode = flushMode; ! } catch (RuntimeException e) { ! this.transaction.setRollbackOnlyInternal(); ! throw e; ! } } /** * This method is used to create a query using a Toplink Expression and the return type. */ public javax.persistence.Query createQuery(Expression expression, Class resultType){ ! try { ! verifyOpen(); ! DatabaseQuery query = createQueryInternal(expression, resultType); ! return new EJBQueryImpl(query, this); ! } catch (RuntimeException e) { ! this.transaction.setRollbackOnlyInternal(); ! throw e; ! } } /** *************** *** 261,270 **** * begin and commit multiple transactions. * @return EntityTransaction instance * @throws IllegalStateException if invoked on a JTA ! * EntityManager or an EntityManager that has been closed. */ public javax.persistence.EntityTransaction getTransaction(){ ! return ((TransactionWrapper)transaction).getTransaction(); } /** --- 318,332 ---- * begin and commit multiple transactions. * @return EntityTransaction instance * @throws IllegalStateException if invoked on a JTA ! * EntityManager. */ public javax.persistence.EntityTransaction getTransaction(){ ! try { ! return ((TransactionWrapper)transaction).getTransaction(); ! } catch (RuntimeException e) { ! this.transaction.setRollbackOnlyInternal(); ! throw e; ! } } /** ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/transaction/base/EntityTransactionImpl.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000005/AB0952363AC40CBFE034080020E8C54E.16 Report generated at Thu Nov 30 16:13:51 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000005/AB0952363AC40CBFE034080020E8C54E.16 Thu Nov 30 15:44:56 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/transaction/base/EntityTransactionImpl.java Thu Nov 30 16:13:50 2006 *************** *** 44,51 **** protected boolean active = false; - protected Boolean hasLastTransactionCompleted; - protected boolean rollbackOnly = false; public EntityTransactionImpl(EntityTransactionWrapper wrapper) { --- 44,49 ---- *************** *** 82,88 **** throw new IllegalStateException(TransactionException.transactionNotActive().getMessage()); } try { - transactionCompleted(); if (this.wrapper.localUOW != null){ this.wrapper.localUOW.setShouldTerminateTransaction(true); if (! this.rollbackOnly){ --- 80,85 ---- *************** *** 96,108 **** wrapper.getLocalUnitOfWork().release(); wrapper.getLocalUnitOfWork().getParent().release(); if (this.rollbackOnly){ ! wrapper.getEntityManager().clear(); throw new RollbackException(ExceptionLocalization.buildMessage("rollback_because_of_rollback_only")); } } }catch (RuntimeException ex){ if (this.wrapper.localUOW != null){ ! wrapper.getEntityManager().clear(); this.wrapper.localUOW.release(); this.wrapper.localUOW.getParent().release(); } --- 93,105 ---- wrapper.getLocalUnitOfWork().release(); wrapper.getLocalUnitOfWork().getParent().release(); if (this.rollbackOnly){ ! wrapper.getEntityManager().clearInternal(); throw new RollbackException(ExceptionLocalization.buildMessage("rollback_because_of_rollback_only")); } } }catch (RuntimeException ex){ if (this.wrapper.localUOW != null){ ! wrapper.getEntityManager().clearInternal(); this.wrapper.localUOW.release(); this.wrapper.localUOW.getParent().release(); } *************** *** 125,131 **** throw new IllegalStateException(TransactionException.transactionNotActive().getMessage()); } try{ - transactionCompleted(); if (wrapper.getLocalUnitOfWork() != null){ this.wrapper.localUOW.setShouldTerminateTransaction(true); this.wrapper.localUOW.release(); --- 122,127 ---- *************** *** 134,140 **** }finally{ this.active = false; this.rollbackOnly = false; ! wrapper.getEntityManager().clear(); wrapper.setLocalUnitOfWork(null); } } --- 130,136 ---- }finally{ this.active = false; this.rollbackOnly = false; ! wrapper.getEntityManager().clearInternal(); wrapper.setLocalUnitOfWork(null); } } *************** *** 182,206 **** */ public boolean isActive(){ return this.active; ! } ! ! /** ! * These two method used for closing of EntityManager in case there is a transaction in progress: ! * The first method is called by EntityManager.close method to mark the current transaction, ! * the second one is called by EntityManager.verifyOpen method. ! */ ! public void markLastTransaction() { ! if(hasLastTransactionCompleted == null) { ! hasLastTransactionCompleted = Boolean.FALSE; ! } ! } ! public boolean hasLastTransactionCompleted() { ! return hasLastTransactionCompleted != null && hasLastTransactionCompleted.booleanValue(); ! } ! protected void transactionCompleted() { ! if(hasLastTransactionCompleted != null) { ! hasLastTransactionCompleted = Boolean.TRUE; ! } ! } ! } --- 178,182 ---- */ public boolean isActive(){ return this.active; ! } } ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/transaction/base/EntityTransactionWrapper.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000006/AB0952363AC40CBFE034080020E8C54E.13 Report generated at Thu Nov 30 16:13:51 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000006/AB0952363AC40CBFE034080020E8C54E.13 Thu Nov 30 15:45:07 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/transaction/base/EntityTransactionWrapper.java Thu Nov 30 16:13:50 2006 *************** *** 89,98 **** throw new TransactionRequiredException(ExceptionLocalization.buildMessage("join_trans_called_on_entity_trans"));// no JTA transactions availab } ! public boolean shouldClose() { ! return (this.entityTransaction == null || ! this.entityTransaction.isActive()); } ! public boolean shouldFlushBeforeQuery(UnitOfWorkImpl uow){ return true; } --- 89,106 ---- throw new TransactionRequiredException(ExceptionLocalization.buildMessage("join_trans_called_on_entity_trans"));// no JTA transactions availab } ! /** ! * Mark the current transaction so that the only possible ! * outcome of the transaction is for the transaction to be ! * rolled back. ! * This is an internal method and if the txn is not active will do nothing ! */ ! public void setRollbackOnlyInternal(){ ! if (entityTransaction != null && entityTransaction.isActive()){ ! entityTransaction.setRollbackOnly(); ! } } ! public boolean shouldFlushBeforeQuery(UnitOfWorkImpl uow){ return true; } *************** *** 100,118 **** protected void throwCheckTransactionFailedException() { throw TransactionException.transactionNotActive(); } - - /** - * These two method used for closing of EntityManager in case there is a transaction in progress: - * The first method is called by EntityManager.close method to mark the current transaction, - * the second one is called by EntityManager.verifyOpen method. - */ - public void markLastTransaction() { - if(entityTransaction != null) { - entityTransaction.markLastTransaction(); - } - } - public boolean hasLastTransactionCompleted() { - return entityTransaction != null && entityTransaction.hasLastTransactionCompleted(); - } - } --- 108,111 ---- ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/transaction/base/JTATransactionWrapper.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.11 Report generated at Thu Nov 30 16:13:51 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.11 Thu Nov 30 15:45:19 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/transaction/base/JTATransactionWrapper.java Thu Nov 30 16:13:50 2006 *************** *** 42,49 **** //This is a quick reference for the external Transaction Controller protected AbstractTransactionController txnController; - protected Object lastTransaction; - public JTATransactionWrapper(EntityManagerImpl entityManager) { super(entityManager); this.txnController = (AbstractTransactionController)entityManager.getServerSession().getExternalTransactionController(); --- 42,47 ---- *************** *** 76,81 **** --- 74,92 ---- } /** + * INTERNAL: + * Mark the current transaction so that the only possible + * outcome of the transaction is for the transaction to be + * rolled back. + * This is an internal method and if the txn is not active will do nothing + */ + public void setRollbackOnlyInternal() { + if(txnController.getTransaction() != null) { + txnController.markTransactionForRollback(); + } + } + + /** * INTERNAL: * THis method is used to get the active UnitOfWork. It is special in that it will * return the required RepeatableWriteUnitOfWork required by the EntityManager. Once *************** *** 118,158 **** uow.registerWithTransactionIfRequired(); } - public boolean shouldClose() { - if (!txnController.noTransactionOrRolledBackOrCommited()) { - return false; - } - return true; - } - /** * We should only flush the entity manager before the query if the query is * joined to a transaction */ public boolean shouldFlushBeforeQuery(UnitOfWorkImpl uow){ return uow.isSynchronized(); ! } ! ! /** ! * These two method used for closing of EntityManager in case there is a transaction in progress: ! * The first method is called by EntityManager.close method to mark the current transaction, ! * the second one is called by EntityManager.verifyOpen method. ! */ ! public void markLastTransaction() { ! if(lastTransaction == null) { ! lastTransaction = txnController.getTransaction(); ! } ! } ! public boolean hasLastTransactionCompleted() { ! if(lastTransaction != null) { ! Object transaction = txnController.getTransaction(); ! if(transaction != null) { ! return !lastTransaction.equals(transaction); ! } else { ! return true; ! } ! } else { ! return false; ! } ! } } --- 129,139 ---- uow.registerWithTransactionIfRequired(); } /** * We should only flush the entity manager before the query if the query is * joined to a transaction */ public boolean shouldFlushBeforeQuery(UnitOfWorkImpl uow){ return uow.isSynchronized(); ! } } ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/transaction/base/TransactionWrapperImpl.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000008/AB0952363AC40CBFE034080020E8C54E.10 Report generated at Thu Nov 30 16:13:51 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000008/AB0952363AC40CBFE034080020E8C54E.10 Thu Nov 30 15:45:59 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/transaction/base/TransactionWrapperImpl.java Thu Nov 30 16:13:50 2006 *************** *** 83,100 **** * Mark the current transaction so that the only possible * outcome of the transaction is for the transaction to be * rolled back. ! * @throws IllegalStateException if isActive() is false. */ ! public void setRollbackOnlyInternal(){ ! //No -op for most wrappers as TopLink will mark for rollback in the case ! //of external transaction controller ! } ! ! /** ! * This method will be called when an entity manager attempts to close to verify its ! * transaction is in a closable state. ! */ ! public abstract boolean shouldClose(); /** * This method will be called when a query is executed. If changes in the entity manager --- 83,91 ---- * Mark the current transaction so that the only possible * outcome of the transaction is for the transaction to be * rolled back. ! * This is an internal method and if the txn is not active will do nothing */ ! public abstract void setRollbackOnlyInternal(); /** * This method will be called when a query is executed. If changes in the entity manager *************** *** 102,112 **** */ public abstract boolean shouldFlushBeforeQuery(UnitOfWorkImpl uow); - /** - * These two method used for closing of EntityManager in case there is a transaction in progress: - * The first method is called by EntityManager.close method to mark the current transaction, - * the second one is called by EntityManager.verifyOpen method. - */ - public abstract void markLastTransaction(); - public abstract boolean hasLastTransactionCompleted(); } --- 93,96 ---- ================================================================================ Merge Diffs: /ade/ailitche_toplink_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/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000009/AB0952363AC40CBFE034080020E8C54E.60 Report generated at Thu Nov 30 16:13:51 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000009/AB0952363AC40CBFE034080020E8C54E.60 Thu Nov 30 15:48:07 2006 --- /ade/ailitche_toplink_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/advanced/EntityManagerJUnitTestSuite.java Thu Nov 30 16:13:50 2006 *************** *** 156,162 **** em.refresh(emp); fail("entityManager.refresh(removedObject) didn't throw exception"); } catch (EntityNotFoundException entityNotFoundException) { ! em.getTransaction().commit(); // expected behaviour } catch (Exception exception ) { em.getTransaction().rollback(); --- 156,162 ---- em.refresh(emp); fail("entityManager.refresh(removedObject) didn't throw exception"); } catch (EntityNotFoundException entityNotFoundException) { ! em.getTransaction().rollback(); // expected behaviour } catch (Exception exception ) { em.getTransaction().rollback(); *************** *** 3145,3153 **** try { em.getTransaction().begin(); // make sure there are no pre-existing objects with this name em.createQuery("DELETE FROM Address a WHERE a.country = '"+firstName+"'").executeUpdate(); - em.createQuery("UPDATE Employee e set e.address = null where e.firstName = '" + firstName + "'").executeUpdate(); - em.createQuery("DELETE FROM Employee e WHERE e.firstName = '"+firstName+"'").executeUpdate(); // populate Employees for(int i=1; i<=n; i++) { Employee emp = new Employee(); --- 3145,3152 ---- try { em.getTransaction().begin(); // make sure there are no pre-existing objects with this name + em.createQuery("DELETE FROM Employee e WHERE e.firstName = '"+firstName+"'").executeUpdate(); em.createQuery("DELETE FROM Address a WHERE a.country = '"+firstName+"'").executeUpdate(); // populate Employees for(int i=1; i<=n; i++) { Employee emp = new Employee(); *************** *** 3221,3229 **** try { em.getTransaction().begin(); // make sure there are no objects left with this name em.createQuery("DELETE FROM Address a WHERE a.country = '"+firstName+"'").executeUpdate(); - em.createQuery("UPDATE Employee e set e.address = null where e.firstName = '" + firstName + "'").executeUpdate(); - em.createQuery("DELETE FROM Employee e WHERE e.firstName = '"+firstName+"'").executeUpdate(); em.getTransaction().commit(); } catch (RuntimeException ex){ if (em.getTransaction().isActive()){ --- 3220,3227 ---- try { em.getTransaction().begin(); // make sure there are no objects left with this name + em.createQuery("DELETE FROM Employee e WHERE e.firstName = '"+firstName+"'").executeUpdate(); em.createQuery("DELETE FROM Address a WHERE a.country = '"+firstName+"'").executeUpdate(); em.getTransaction().commit(); } catch (RuntimeException ex){ if (em.getTransaction().isActive()){ *************** *** 3590,3595 **** --- 3588,3674 ---- } } + public void testRollbackOnlyOnException() { + EntityManager em = createEntityManager(); + em.getTransaction().begin(); + try { + Employee emp = em.find(Employee.class, ""); + fail("IllegalArgumentException has not been thrown"); + } catch(IllegalArgumentException ex) { + assertTrue("Transaction is not roll back only", em.getTransaction().getRollbackOnly()); + } finally { + em.getTransaction().rollback(); + em.close(); + } + } + + public void testClosedEmShouldThrowException() { + EntityManager em = createEntityManager(); + em.close(); + String errorMsg = ""; + + try { + em.clear(); + errorMsg = errorMsg + "; em.clear() didn't throw exception"; + } catch(IllegalStateException ise) { + // expected + } catch(RuntimeException ex) { + errorMsg = errorMsg + "; em.clear() threw wrong exception: " + ex.getMessage(); + } + try { + em.close(); + errorMsg = errorMsg + "; em.close() didn't throw exception"; + } catch(IllegalStateException ise) { + // expected + } catch(RuntimeException ex) { + errorMsg = errorMsg + "; em.close() threw wrong exception: " + ex.getMessage(); + } + try { + em.contains(null); + errorMsg = errorMsg + "; em.contains() didn't throw exception"; + } catch(IllegalStateException ise) { + // expected + } catch(RuntimeException ex) { + errorMsg = errorMsg + "; em.contains threw() wrong exception: " + ex.getMessage(); + } + try { + em.getDelegate(); + errorMsg = errorMsg + "; em.getDelegate() didn't throw exception"; + } catch(IllegalStateException ise) { + // expected + } catch(RuntimeException ex) { + errorMsg = errorMsg + "; em.getDelegate() threw wrong exception: " + ex.getMessage(); + } + try { + em.getReference(Employee.class, new Integer(1)); + errorMsg = errorMsg + "; em.getReference() didn't throw exception"; + } catch(IllegalStateException ise) { + // expected + } catch(RuntimeException ex) { + errorMsg = errorMsg + "; em.getReference() threw wrong exception: " + ex.getMessage(); + } + try { + em.joinTransaction(); + errorMsg = errorMsg + "; em.joinTransaction() didn't throw exception"; + } catch(IllegalStateException ise) { + // expected + } catch(RuntimeException ex) { + errorMsg = errorMsg + "; em.joinTransaction() threw wrong exception: " + ex.getMessage(); + } + try { + em.lock(null, null); + errorMsg = errorMsg + "; em.lock() didn't throw exception"; + } catch(IllegalStateException ise) { + // expected + } catch(RuntimeException ex) { + errorMsg = errorMsg + "; em.lock() threw wrong exception: " + ex.getMessage(); + } + + if(errorMsg.length() > 0) { + fail(errorMsg); + } + } + public static void main(String[] args) { // Now run JUnit. junit.swingui.TestRunner.main(args); ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/relationships/ExecuteUpdateTest.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000010/AB0952363AC40CBFE034080020E8C54E.4 Report generated at Thu Nov 30 16:13:51 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000010/AB0952363AC40CBFE034080020E8C54E.4 Thu Nov 30 15:49:44 2006 --- /ade/ailitche_toplink_main/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/relationships/ExecuteUpdateTest.java Thu Nov 30 16:13:50 2006 *************** *** 8,13 **** --- 8,14 ---- import oracle.toplink.essentials.testing.models.cmp3.relationships.*; import oracle.toplink.essentials.testing.tests.cmp3.EntityContainerTestBase; import oracle.toplink.essentials.exceptions.QueryException; + import javax.persistence.RollbackException; /* * Tests for the executeUpdate method on the EJBQueryImpl class *************** *** 29,34 **** --- 30,36 ---- protected String nameChange3 = "New Name3"; protected String returnedName1,returnedName2,returnedName3 = null; protected Exception expectedException =null; + protected RollbackException expectedException2 = null; public ExecuteUpdateTest() { } *************** *** 111,123 **** expectedException=expected; } ! commitTransaction(); ! ! } catch (Exception ex) { ! try{ commitTransaction(); ! }catch(Exception comitEx){} throw new TestErrorException("Exception thrown while executing updates" + ex, ex); } } --- 113,129 ---- expectedException=expected; } ! try { commitTransaction(); ! expectedException2 = null; ! }catch(RollbackException ex){ ! expectedException2 = ex; ! } ! ! } catch (Exception ex) { throw new TestErrorException("Exception thrown while executing updates" + ex, ex); + } finally { + rollbackTransaction(); } } *************** *** 131,137 **** 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 findAllCustomers named ReadAllQuery"); } } --- 137,147 ---- 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 findAllCustomers named ReadAllQuery"); + } + if ( expectedException2==null ){ + throw new TestErrorException("commit did not throw expected RollbackException"); + } } } ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/relationships/GetResultListTest.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000011/AB0952363AC40CBFE034080020E8C54E.5 Report generated at Thu Nov 30 16:13:51 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000011/AB0952363AC40CBFE034080020E8C54E.5 Thu Nov 30 15:50:04 2006 --- /ade/ailitche_toplink_main/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/relationships/GetResultListTest.java Thu Nov 30 16:13:50 2006 *************** *** 11,16 **** --- 11,17 ---- import oracle.toplink.essentials.testing.framework.*; import oracle.toplink.essentials.testing.models.cmp3.relationships.*; import java.util.List; + import javax.persistence.RollbackException; /* * Tests using the 'getSingleResult' api on a Query object obtained from the EntityManager * Also tests bugs 4300879 - check non List container policy error *************** *** 26,31 **** --- 27,34 ---- public Integer[] cusIDs = new Integer[3]; + protected RollbackException expectedException3 = null; + public GetResultListTest() { } *************** *** 68,79 **** expectedException2 = exceptionExpected2; } ! commitTransaction(); ! }catch (Exception unexpectedException){ ! try{ commitTransaction(); ! }catch(Exception comitEx){} throw new TestErrorException("Problem in GetResultListTest: "+unexpectedException); } } --- 71,87 ---- expectedException2 = exceptionExpected2; } ! try { commitTransaction(); ! expectedException3 = null; ! }catch(RollbackException ex){ ! expectedException3 = ex; ! } ! ! }catch (Exception unexpectedException){ throw new TestErrorException("Problem in GetResultListTest: "+unexpectedException); + }finally{ + rollbackTransaction(); } } *************** *** 90,95 **** --- 98,106 ---- if ( expectedException2==null || (expectedException2.getErrorCode()!= QueryException.INCORRECT_QUERY_FOUND)){ throw new TestErrorException("getResultList on ReadObjectQuery did not throw expected INCORRECT_QUERY_FOUNDQueryException"); } + if ( expectedException3==null ){ + throw new TestErrorException("commit did not throw expected RollbackException"); + } } } ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/relationships/GetSingleResultTest.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000012/AB0952363AC40CBFE034080020E8C54E.7 Report generated at Thu Nov 30 16:13:51 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000012/AB0952363AC40CBFE034080020E8C54E.7 Thu Nov 30 15:50:12 2006 --- /ade/ailitche_toplink_main/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/relationships/GetSingleResultTest.java Thu Nov 30 16:13:50 2006 *************** *** 4,9 **** --- 4,11 ---- import javax.persistence.NoResultException; import javax.persistence.NonUniqueResultException; import javax.persistence.Query; + import javax.persistence.RollbackException; + import oracle.toplink.essentials.exceptions.QueryException; import oracle.toplink.essentials.internal.ejb.cmp3.EJBQueryImpl; import oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl; *************** *** 30,35 **** --- 32,38 ---- protected NonUniqueResultException expectedException1 = null; protected NoResultException expectedException2 = null; protected QueryException expectedException3 = null; + protected RollbackException expectedException4 = null; protected String searchString = "notAnItemName"; *************** *** 117,129 **** readObjectQuery.setEJBQLString("SELECT OBJECT(thecust) FROM Customer 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); } } --- 120,137 ---- readObjectQuery.setEJBQLString("SELECT OBJECT(thecust) FROM Customer thecust WHERE thecust.customerId = :id"); query4.setDatabaseQuery(readObjectQuery); returnedCustomer2 = (Customer)query4.getSingleResult(); + + try { + commitTransaction(); + expectedException4 = null; + }catch(RollbackException ex){ + expectedException4 = ex; + } }catch (Exception unexpectedException){ throw new TestErrorException("Problem in GetSingleResultTest: "+unexpectedException); + }finally{ + rollbackTransaction(); } } *************** *** 137,142 **** --- 145,153 ---- 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 ( expectedException4==null ){ + throw new TestErrorException("commit did not throw expected RollbackException"); + } if ( returnedCustomer1==null || (!returnedCustomer1.getCustomerId().equals(cusIDs[0])) ){ throw new TestErrorException("Incorrect Single Customer returned, found: "+returnedCustomer1); } ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/base/EJBQueryImpl.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.45 Report generated at Thu Nov 30 16:15:17 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.45 Thu Nov 30 15:38:24 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/base/EJBQueryImpl.java Thu Nov 30 16:13:50 2006 *************** *** 356,375 **** * @return the number of entities updated or deleted */ public int executeUpdate() { ! //bug51411440: need to throw IllegalStateException if query executed on closed em ! entityManager.verifyOpen(); ! setAsSQLModifyQuery(); ! //bug:4294241, only allow modify queries - UpdateAllQuery prefered ! if ( !(getDatabaseQuery() instanceof ModifyQuery) ){ ! throw new IllegalStateException(ExceptionLocalization.buildMessage("incorrect_query_for_execute_update")); ! } ! //fix for bug:4288845, did not add the parameters to the query ! Vector parameterValues = processParameters(); ! if(isFlushModeAUTO()) { ! performPreQueryFlush(); } - Integer changedRows = (Integer)((Session)getActiveSession()).executeQuery(databaseQuery, parameterValues); - return changedRows.intValue(); } /** --- 356,380 ---- * @return the number of entities updated or deleted */ public int executeUpdate() { ! try { ! //bug51411440: need to throw IllegalStateException if query executed on closed em ! entityManager.verifyOpen(); ! setAsSQLModifyQuery(); ! //bug:4294241, only allow modify queries - UpdateAllQuery prefered ! if ( !(getDatabaseQuery() instanceof ModifyQuery) ){ ! throw new IllegalStateException(ExceptionLocalization.buildMessage("incorrect_query_for_execute_update")); ! } ! //fix for bug:4288845, did not add the parameters to the query ! Vector parameterValues = processParameters(); ! if(isFlushModeAUTO()) { ! performPreQueryFlush(); ! } ! Integer changedRows = (Integer)((Session)getActiveSession()).executeQuery(databaseQuery, parameterValues); ! return changedRows.intValue(); ! } catch (RuntimeException e) { ! setRollbackOnly(); ! throw e; } } /** *************** *** 428,451 **** * @return a list of the results */ public List getResultList() { ! //bug51411440: need to throw IllegalStateException if query executed on closed em ! entityManager.verifyOpen(); ! setAsSQLReadQuery(); ! propagateResultProperties(); ! //bug:4297903, check container policy class and throw exception if its not the right type ! if (getDatabaseQuery() instanceof ReadAllQuery){ ! Class containerClass = ((ReadAllQuery)getDatabaseQuery()).getContainerPolicy().getContainerClass(); ! if (! Helper.classImplementsInterface(containerClass, ClassConstants.List_Class)){ ! throw QueryException.invalidContainerClass( containerClass, ClassConstants.List_Class ); ! } ! } else if (getDatabaseQuery() instanceof ReadObjectQuery){ ! //bug:4300879, handle ReadObjectQuery returning null ! throw QueryException.incorrectQueryObjectFound( getDatabaseQuery(), ReadAllQuery.class ); ! } else if (!(getDatabaseQuery() instanceof ReadQuery)){ ! throw new IllegalStateException(ExceptionLocalization.buildMessage("incorrect_query_for_get_result_list")); } - Object result = executeReadQuery(); - return (List)result; } /** --- 433,461 ---- * @return a list of the results */ public List getResultList() { ! try { ! //bug51411440: need to throw IllegalStateException if query executed on closed em ! entityManager.verifyOpen(); ! setAsSQLReadQuery(); ! propagateResultProperties(); ! //bug:4297903, check container policy class and throw exception if its not the right type ! if (getDatabaseQuery() instanceof ReadAllQuery){ ! Class containerClass = ((ReadAllQuery)getDatabaseQuery()).getContainerPolicy().getContainerClass(); ! if (! Helper.classImplementsInterface(containerClass, ClassConstants.List_Class)){ ! throw QueryException.invalidContainerClass( containerClass, ClassConstants.List_Class ); ! } ! } else if (getDatabaseQuery() instanceof ReadObjectQuery){ ! //bug:4300879, handle ReadObjectQuery returning null ! throw QueryException.incorrectQueryObjectFound( getDatabaseQuery(), ReadAllQuery.class ); ! } else if (!(getDatabaseQuery() instanceof ReadQuery)){ ! throw new IllegalStateException(ExceptionLocalization.buildMessage("incorrect_query_for_get_result_list")); ! } ! Object result = executeReadQuery(); ! return (List)result; ! } catch (RuntimeException e) { ! setRollbackOnly(); ! throw e; } } /** *************** *** 455,487 **** * @throws NonUniqueResultException if more than one result */ public Object getSingleResult() { ! //bug51411440: need to throw IllegalStateException if query executed on closed em ! entityManager.verifyOpen(); ! setAsSQLReadQuery(); ! propagateResultProperties(); ! //bug:4301674, requires lists to be returned from ReadAllQuery objects ! if (getDatabaseQuery() instanceof ReadAllQuery){ ! Class containerClass = ((ReadAllQuery)getDatabaseQuery()).getContainerPolicy().getContainerClass(); ! if (! Helper.classImplementsInterface(containerClass, ClassConstants.List_Class)){ ! throw QueryException.invalidContainerClass( containerClass, ClassConstants.List_Class ); ! } ! } else if (!(getDatabaseQuery() instanceof ReadQuery)){ ! throw new IllegalStateException(ExceptionLocalization.buildMessage("incorrect_query_for_get_single_result")); ! } ! Object result = executeReadQuery(); ! if (result instanceof List){ ! List results = (List)result; ! if (results.isEmpty()) { ! throwNoResultException(ExceptionLocalization.buildMessage("no_entities_retrieved_for_get_single_result", (Object[])null)); ! } else if (results.size() > 1) { ! throwNonUniqueResultException(ExceptionLocalization.buildMessage("too_many_results_for_get_single_result", (Object[])null)); ! } ! return results.get(0); ! }else{ ! if (result == null) { ! throwNoResultException(ExceptionLocalization.buildMessage("no_entities_retrieved_for_get_single_result", (Object[])null)); } ! return result; } } --- 465,508 ---- * @throws NonUniqueResultException if more than one result */ public Object getSingleResult() { ! boolean rollbackOnException = true; ! try { ! //bug51411440: need to throw IllegalStateException if query executed on closed em ! entityManager.verifyOpen(); ! setAsSQLReadQuery(); ! propagateResultProperties(); ! //bug:4301674, requires lists to be returned from ReadAllQuery objects ! if (getDatabaseQuery() instanceof ReadAllQuery){ ! Class containerClass = ((ReadAllQuery)getDatabaseQuery()).getContainerPolicy().getContainerClass(); ! if (! Helper.classImplementsInterface(containerClass, ClassConstants.List_Class)){ ! throw QueryException.invalidContainerClass( containerClass, ClassConstants.List_Class ); ! } ! } else if (!(getDatabaseQuery() instanceof ReadQuery)){ ! throw new IllegalStateException(ExceptionLocalization.buildMessage("incorrect_query_for_get_single_result")); ! } ! Object result = executeReadQuery(); ! if (result instanceof List){ ! List results = (List)result; ! if (results.isEmpty()) { ! rollbackOnException = false; ! throwNoResultException(ExceptionLocalization.buildMessage("no_entities_retrieved_for_get_single_result", (Object[])null)); ! } else if (results.size() > 1) { ! rollbackOnException = false; ! throwNonUniqueResultException(ExceptionLocalization.buildMessage("too_many_results_for_get_single_result", (Object[])null)); ! } ! return results.get(0); ! }else{ ! if (result == null) { ! rollbackOnException = false; ! throwNoResultException(ExceptionLocalization.buildMessage("no_entities_retrieved_for_get_single_result", (Object[])null)); ! } ! return result; ! } ! } catch (RuntimeException e) { ! if(rollbackOnException) { ! setRollbackOnly(); } ! throw e; } } *************** *** 656,660 **** this.entityManager.flush(); } } ! } --- 677,684 ---- this.entityManager.flush(); } } ! ! protected void setRollbackOnly() { ! entityManager.setRollbackOnly(); ! } } ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/base/EntityManagerImpl.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.43 Report generated at Thu Nov 30 16:15:17 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.43 Thu Nov 30 15:39:00 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/base/EntityManagerImpl.java Thu Nov 30 16:13:50 2006 *************** *** 143,148 **** --- 143,164 ---- * persisted. */ public void clear(){ + try { + verifyOpen(); + clearInternal(); + } catch (RuntimeException e) { + this.setRollbackOnly(); + throw e; + } + } + + /** + * Clear the persistence context, causing all managed + * entities to become detached. Changes made to entities that + * have not been flushed to the database will not be + * persisted. + */ + public void clearInternal(){ if (this.isExtended()){ if (this.extendedPersistenceContext != null) { if (checkForTransaction(false) != null){ *************** *** 167,185 **** * @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) { ! this.transaction.setRollbackOnlyInternal(); ! if (ValidationException.class.isAssignableFrom(e.getClass())){ ! throw new EntityExistsException(e.getLocalizedMessage() , e); } throw e; ! } } /** --- 183,205 ---- * @throws IllegalArgumentException if the given Object is not an entity */ public void persist(Object entity){ try { ! 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) { + if (ValidationException.class.isAssignableFrom(e.getClass())){ + throw new EntityExistsException(e.getLocalizedMessage() , e); + } + throw e; + } + } catch (RuntimeException e) { + this.setRollbackOnly(); throw e; ! } } /** *************** *** 191,197 **** * @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})); } --- 211,216 ---- *************** *** 212,217 **** --- 231,237 ---- * @throws IllegalArgumentException if Object passed in is not an entity */ public void remove(Object entity){ + try { verifyOpen(); if (entity == null){ //gf732 - check for null throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[] {entity})); *************** *** 219,227 **** try{ getActivePersistenceContext(checkForTransaction(!isExtended())).performRemove(entity, new IdentityHashtable()); }catch (RuntimeException e){ - this.transaction.setRollbackOnlyInternal(); throw e; } } /** --- 239,250 ---- try{ getActivePersistenceContext(checkForTransaction(!isExtended())).performRemove(entity, new IdentityHashtable()); }catch (RuntimeException e){ throw e; } + } catch (RuntimeException e) { + this.setRollbackOnly(); + throw e; + } } /** *************** *** 233,256 **** * second argument is not a valid type for that entity's primaryKey */ public Object find(String entityName, Object primaryKey){ verifyOpen(); ! try{ ! Session session = getActiveSession(); ! ClassDescriptor descriptor = session.getDescriptorForAlias(entityName); ! if (descriptor == null || descriptor.isAggregateDescriptor() || descriptor.isAggregateCollectionDescriptor()){ ! throw new IllegalArgumentException(ExceptionLocalization.buildMessage("unknown_entitybean_name", new Object[] {entityName})); ! } ! if (primaryKey == null){ //gf721 - check for null PK ! throw new IllegalArgumentException(ExceptionLocalization.buildMessage("null_pk")); ! } ! if ( ((CMP3Policy)descriptor.getCMPPolicy()).getPKClass() != null && !((CMP3Policy)descriptor.getCMPPolicy()).getPKClass().isAssignableFrom(primaryKey.getClass())){ ! throw new IllegalArgumentException(ExceptionLocalization.buildMessage("invalid_pk_class", new Object[] {((CMP3Policy)descriptor.getCMPPolicy()).getPKClass(), primaryKey.getClass()})); ! } ! return findInternal(descriptor, session, primaryKey); ! }catch (RuntimeException e){ ! this.transaction.setRollbackOnlyInternal(); ! throw e; } } /** --- 256,279 ---- * second argument is not a valid type for that entity's primaryKey */ public Object find(String entityName, Object primaryKey){ + try { verifyOpen(); ! Session session = getActiveSession(); ! ClassDescriptor descriptor = session.getDescriptorForAlias(entityName); ! if (descriptor == null || descriptor.isAggregateDescriptor() || descriptor.isAggregateCollectionDescriptor()){ ! throw new IllegalArgumentException(ExceptionLocalization.buildMessage("unknown_entitybean_name", new Object[] {entityName})); } + if (primaryKey == null){ //gf721 - check for null PK + throw new IllegalArgumentException(ExceptionLocalization.buildMessage("null_pk")); + } + if ( ((CMP3Policy)descriptor.getCMPPolicy()).getPKClass() != null && !((CMP3Policy)descriptor.getCMPPolicy()).getPKClass().isAssignableFrom(primaryKey.getClass())){ + throw new IllegalArgumentException(ExceptionLocalization.buildMessage("invalid_pk_class", new Object[] {((CMP3Policy)descriptor.getCMPPolicy()).getPKClass(), primaryKey.getClass()})); + } + return findInternal(descriptor, session, primaryKey); + } catch (RuntimeException e) { + this.setRollbackOnly(); + throw e; + } } /** *************** *** 264,270 **** * entity's primary key */ protected Object findInternal(Class entityClass, Object primaryKey) { - verifyOpen(); Session session = getActiveSession(); ClassDescriptor descriptor = session.getDescriptor(entityClass); if (descriptor == null || descriptor.isAggregateDescriptor() || descriptor.isAggregateCollectionDescriptor()){ --- 287,292 ---- *************** *** 308,324 **** * underlying database. */ public void flush(){ verifyOpen(); try { getActivePersistenceContext(checkForTransaction(true)).writeChanges(); }catch (RuntimeException e) { - this.transaction.setRollbackOnlyInternal(); if (TopLinkException.class.isAssignableFrom(e.getClass())){ throw new PersistenceException(e); } throw e; } } protected void detectTransactionWrapper(){ --- 330,350 ---- * underlying database. */ public void flush(){ + try { verifyOpen(); try { getActivePersistenceContext(checkForTransaction(true)).writeChanges(); }catch (RuntimeException e) { if (TopLinkException.class.isAssignableFrom(e.getClass())){ throw new PersistenceException(e); } throw e; } + } catch (RuntimeException e) { + this.setRollbackOnly(); + throw e; + } } protected void detectTransactionWrapper(){ *************** *** 335,361 **** * @param entity */ public void refresh(Object entity){ ! verifyOpen(); ! UnitOfWork uow = getActivePersistenceContext(checkForTransaction(!isExtended())); ! if(!contains(entity, uow)) { ! this.transaction.setRollbackOnlyInternal(); ! throw new IllegalArgumentException(ExceptionLocalization.buildMessage("cant_refresh_not_managed_object", new Object[]{entity})); ! } ! ReadObjectQuery query = new ReadObjectQuery(); ! query.setSelectionObject(entity); ! query.refreshIdentityMapResult(); ! query.cascadeByMapping(); ! query.setLockMode(ObjectBuildingQuery.NO_LOCK); ! Object refreshedEntity = null; ! try{ ! refreshedEntity = uow.executeQuery(query); ! }catch (RuntimeException e){ ! this.transaction.setRollbackOnlyInternal(); throw e; } - if(refreshedEntity == null) { - throw new EntityNotFoundException(ExceptionLocalization.buildMessage("entity_no_longer_exists_in_db", new Object[]{entity})); - } } /** --- 361,386 ---- * @param entity */ public void refresh(Object entity){ ! try { ! verifyOpen(); ! UnitOfWork uow = getActivePersistenceContext(checkForTransaction(!isExtended())); ! if(!contains(entity, uow)) { ! throw new IllegalArgumentException(ExceptionLocalization.buildMessage("cant_refresh_not_managed_object", new Object[]{entity})); ! } ! ReadObjectQuery query = new ReadObjectQuery(); ! query.setSelectionObject(entity); ! query.refreshIdentityMapResult(); ! query.cascadeByMapping(); ! query.setLockMode(ObjectBuildingQuery.NO_LOCK); ! Object refreshedEntity = null; ! refreshedEntity = uow.executeQuery(query); ! if(refreshedEntity == null) { ! throw new EntityNotFoundException(ExceptionLocalization.buildMessage("entity_no_longer_exists_in_db", new Object[]{entity})); ! } ! } catch (RuntimeException e) { ! this.setRollbackOnly(); throw e; } } /** *************** *** 366,385 **** * @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})); ! } ! ! if( (!hasActivePersistenceContext())) { ! return false; } - - return contains(entity,getActivePersistenceContext(checkForTransaction(false))); } /** --- 391,415 ---- * @throws IllegalArgumentException if given Object is not an entity */ public boolean contains(Object entity){ ! try { ! 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})); ! } ! ! if( (!hasActivePersistenceContext())) { ! return false; ! } ! ! return contains(entity,getActivePersistenceContext(checkForTransaction(false))); ! } catch (RuntimeException e) { ! this.setRollbackOnly(); ! throw e; } } /** *************** *** 417,423 **** * specific. */ public Object getDelegate(){ ! return this; } /** --- 447,459 ---- * specific. */ public Object getDelegate(){ ! try { ! verifyOpen(); ! return this; ! } catch (RuntimeException e) { ! this.setRollbackOnly(); ! throw e; ! } } /** *************** *** 448,454 **** * return type. */ protected DatabaseQuery createNativeQueryInternal(String sqlString, Class resultType){ - verifyOpen(); ReadAllQuery query = new ReadAllQuery(resultType); query.setSQLString(sqlString); query.setIsUserDefined(true); --- 484,489 ---- *************** *** 478,492 **** * transactions.

*/ public void close(){ - verifyOpen(); - isOpen = false; try { ! if (!transaction.shouldClose()){ ! this.transaction.markLastTransaction(); ! } ! } finally { factory = null; serverSession = null; } } --- 513,526 ---- * transactions.

*/ public void close(){ try { ! verifyOpen(); ! isOpen = false; factory = null; serverSession = null; + } catch (RuntimeException e) { + this.setRollbackOnly(); + throw e; } } *************** *** 515,528 **** * @throws TransactionRequiredException if there is no transaction */ public void lock(Object entity, LockModeType lockMode){ ! RepeatableWriteUnitOfWork context = getActivePersistenceContext(checkForTransaction(!isExtended())); ! ClassDescriptor descriptor = context.getDescriptor(entity); ! OptimisticLockingPolicy lockingPolicy = descriptor.getOptimisticLockingPolicy(); ! if ((lockingPolicy == null) || !(lockingPolicy instanceof VersionLockingPolicy)){ ! this.transaction.setRollbackOnlyInternal(); ! throw new PersistenceException(ExceptionLocalization.buildMessage("ejb30-wrong-lock_called_without_version_locking-index", null)); } - context.forceUpdateToVersionField(entity, (lockMode == LockModeType.WRITE)); } public void verifyOpen(){ --- 549,567 ---- * @throws TransactionRequiredException if there is no transaction */ public void lock(Object entity, LockModeType lockMode){ ! try { ! verifyOpen(); ! RepeatableWriteUnitOfWork context = getActivePersistenceContext(checkForTransaction(!isExtended())); ! ClassDescriptor descriptor = context.getDescriptor(entity); ! OptimisticLockingPolicy lockingPolicy = descriptor.getOptimisticLockingPolicy(); ! if ((lockingPolicy == null) || !(lockingPolicy instanceof VersionLockingPolicy)){ ! throw new PersistenceException(ExceptionLocalization.buildMessage("ejb30-wrong-lock_called_without_version_locking-index", null)); ! } ! context.forceUpdateToVersionField(entity, (lockMode == LockModeType.WRITE)); ! } catch (RuntimeException e) { ! this.setRollbackOnly(); ! throw e; } } public void verifyOpen(){ *************** *** 594,599 **** * no transaction. */ public void joinTransaction(){ ! transaction.registerUnitOfWorkWithTxn(getActivePersistenceContext(checkForTransaction(true))); } } --- 633,651 ---- * no transaction. */ public void joinTransaction(){ ! try { ! verifyOpen(); ! transaction.registerUnitOfWorkWithTxn(getActivePersistenceContext(checkForTransaction(true))); ! } catch (RuntimeException e) { ! this.setRollbackOnly(); ! throw e; ! } ! } ! ! /** ! * Internal method. Sets transaction to rollback only. ! */ ! protected void setRollbackOnly() { ! this.transaction.setRollbackOnlyInternal(); } } ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/EJBQueryImpl.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.12 Report generated at Thu Nov 30 16:15:17 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.12 Thu Nov 30 15:42:42 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/EJBQueryImpl.java Thu Nov 30 16:13:50 2006 *************** *** 110,117 **** * @return the same query instance */ public Query setFirstResult(int startPosition) { ! setFirstResultInternal(startPosition); ! return this; } /** --- 110,123 ---- * @return the same query instance */ public Query setFirstResult(int startPosition) { ! try { ! entityManager.verifyOpen(); ! setFirstResultInternal(startPosition); ! return this; ! } catch (RuntimeException e) { ! setRollbackOnly(); ! throw e; ! } } /** *************** *** 119,130 **** * @param flushMode */ public Query setFlushMode(FlushModeType flushMode) { ! if (flushMode == null) { ! getDatabaseQuery().setFlushOnExecute(null); ! } else { ! getDatabaseQuery().setFlushOnExecute(flushMode == FlushModeType.AUTO); } - return this; } /** --- 125,142 ---- * @param flushMode */ public Query setFlushMode(FlushModeType flushMode) { ! try { ! entityManager.verifyOpen(); ! if (flushMode == null) { ! getDatabaseQuery().setFlushOnExecute(null); ! } else { ! getDatabaseQuery().setFlushOnExecute(flushMode == FlushModeType.AUTO); ! } ! return this; ! } catch (RuntimeException e) { ! setRollbackOnly(); ! throw e; } } /** *************** *** 137,144 **** * valid for the implementation */ public Query setHint(String hintName, Object value) { ! setHintInternal(hintName, value); ! return this; } /** --- 149,162 ---- * valid for the implementation */ public Query setHint(String hintName, Object value) { ! try { ! entityManager.verifyOpen(); ! setHintInternal(hintName, value); ! return this; ! } catch (RuntimeException e) { ! setRollbackOnly(); ! throw e; ! } } /** *************** *** 147,154 **** * @return the same query instance */ public Query setMaxResults(int maxResult) { ! setMaxResultsInternal(maxResult); ! return this; } /** --- 165,178 ---- * @return the same query instance */ public Query setMaxResults(int maxResult) { ! try { ! entityManager.verifyOpen(); ! setMaxResultsInternal(maxResult); ! return this; ! } catch (RuntimeException e) { ! setRollbackOnly(); ! throw e; ! } } /** *************** *** 158,165 **** * @return the same query instance */ public Query setParameter(String name, Object value) { ! setParameterInternal(name, value); ! return this; } /** --- 182,195 ---- * @return the same query instance */ public Query setParameter(String name, Object value) { ! try { ! entityManager.verifyOpen(); ! setParameterInternal(name, value); ! return this; ! } catch (RuntimeException e) { ! setRollbackOnly(); ! throw e; ! } } /** *************** *** 191,198 **** * @return the same query instance */ public Query setParameter(int position, Object value) { ! setParameterInternal(position, value); ! return this; } /** --- 221,234 ---- * @return the same query instance */ public Query setParameter(int position, Object value) { ! try { ! entityManager.verifyOpen(); ! setParameterInternal(position, value); ! return this; ! } catch (RuntimeException e) { ! setRollbackOnly(); ! throw e; ! } } /** ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/EntityManagerImpl.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.16 Report generated at Thu Nov 30 16:15:17 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.16 Thu Nov 30 15:42:59 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/EntityManagerImpl.java Thu Nov 30 16:13:50 2006 *************** *** 108,119 **** * @return the instance that the state was merged to */ public T merge(T entity){ ! try{ ! return (T) mergeInternal(entity); ! }catch (RuntimeException e){ ! this.transaction.setRollbackOnlyInternal(); ! throw e; ! } } /** --- 108,120 ---- * @return the instance that the state was merged to */ public T merge(T entity){ ! try{ ! verifyOpen(); ! return (T) mergeInternal(entity); ! }catch (RuntimeException e){ ! this.transaction.setRollbackOnlyInternal(); ! throw e; ! } } /** *************** *** 127,133 **** * entity's primary key */ public T find(Class entityClass, Object primaryKey){ ! return (T) findInternal(entityClass, primaryKey); } /** --- 128,140 ---- * entity's primary key */ public T find(Class entityClass, Object primaryKey){ ! try { ! verifyOpen(); ! return (T) findInternal(entityClass, primaryKey); ! } catch (RuntimeException e) { ! this.transaction.setRollbackOnlyInternal(); ! throw e; ! } } /** *************** *** 149,161 **** * cannot be accessed */ public T getReference(Class entityClass, Object primaryKey) { ! Object returnValue = findInternal(entityClass, primaryKey); ! if (returnValue ==null){ ! Object[] o = {primaryKey}; ! String message = ExceptionLocalization.buildMessage("no_entities_retrieved_for_get_reference", o); ! throw new javax.persistence.EntityNotFoundException(message); } - return (T)returnValue; } /** --- 156,174 ---- * cannot be accessed */ public T getReference(Class entityClass, Object primaryKey) { ! try { ! verifyOpen(); ! Object returnValue = findInternal(entityClass, primaryKey); ! if (returnValue ==null){ ! Object[] o = {primaryKey}; ! String message = ExceptionLocalization.buildMessage("no_entities_retrieved_for_get_reference", o); ! throw new javax.persistence.EntityNotFoundException(message); ! } ! return (T)returnValue; ! } catch (RuntimeException e) { ! this.transaction.setRollbackOnlyInternal(); ! throw e; } } /** *************** *** 166,186 **** */ public Query createQuery(String ejbqlString){ ! verifyOpen(); ! ! EJBQueryImpl ejbqImpl; ! ! try ! { ! ejbqImpl = new EJBQueryImpl(ejbqlString, this); ! } ! ! catch(EJBQLException ex) ! { ! throw new IllegalArgumentException(ExceptionLocalization.buildMessage("wrap_ejbql_exception"), ex); } - - return ejbqImpl; } /** * Create an instance of Query for executing a --- 179,204 ---- */ public Query createQuery(String ejbqlString){ ! try { ! verifyOpen(); ! ! EJBQueryImpl ejbqImpl; ! ! try ! { ! ejbqImpl = new EJBQueryImpl(ejbqlString, this); ! } ! ! catch(EJBQLException ex) ! { ! throw new IllegalArgumentException(ExceptionLocalization.buildMessage("wrap_ejbql_exception"), ex); ! } ! ! return ejbqImpl; ! } catch (RuntimeException e) { ! this.transaction.setRollbackOnlyInternal(); ! throw e; } } /** * Create an instance of Query for executing a *************** *** 189,196 **** * @return the new query instance */ public Query createNamedQuery(String name){ ! verifyOpen(); ! return new EJBQueryImpl(name, this, true); } /** * Create an instance of Query for executing --- 207,219 ---- * @return the new query instance */ public Query createNamedQuery(String name){ ! try { ! verifyOpen(); ! return new EJBQueryImpl(name, this, true); ! } catch (RuntimeException e) { ! this.transaction.setRollbackOnlyInternal(); ! throw e; ! } } /** * Create an instance of Query for executing *************** *** 199,215 **** * @return the new query instance */ public Query createNativeQuery(String sqlString){ ! verifyOpen(); ! return new EJBQueryImpl( EJBQueryImpl.buildSQLDatabaseQuery( sqlString, false), this ); } /** * This method is used to create a query using SQL. The class, must be the expected * return type. */ ! public javax.persistence.Query createNativeQuery(String sqlString, Class resultType){ ! DatabaseQuery query = createNativeQueryInternal(sqlString, resultType); ! return new EJBQueryImpl(query, this); } /** --- 222,249 ---- * @return the new query instance */ public Query createNativeQuery(String sqlString){ ! try { ! verifyOpen(); ! return new EJBQueryImpl( EJBQueryImpl.buildSQLDatabaseQuery( sqlString, false), this ); ! } catch (RuntimeException e) { ! this.transaction.setRollbackOnlyInternal(); ! throw e; ! } } /** * This method is used to create a query using SQL. The class, must be the expected * return type. */ ! public Query createNativeQuery(String sqlString, Class resultType){ ! try { ! verifyOpen(); ! DatabaseQuery query = createNativeQueryInternal(sqlString, resultType); ! return new EJBQueryImpl(query, this); ! } catch (RuntimeException e) { ! this.transaction.setRollbackOnlyInternal(); ! throw e; ! } } /** *************** *** 221,232 **** * @throws IllegalArgumentException if query string is not valid */ public Query createNativeQuery(String sqlString, String resultSetMapping){ ! verifyOpen(); ! ResultSetMappingQuery query = new ResultSetMappingQuery(); ! query.setSQLResultSetMappingName(resultSetMapping); ! query.setSQLString(sqlString); ! query.setIsUserDefined(true); ! return new EJBQueryImpl(query, this); } /** --- 255,271 ---- * @throws IllegalArgumentException if query string is not valid */ public Query createNativeQuery(String sqlString, String resultSetMapping){ ! try { ! verifyOpen(); ! ResultSetMappingQuery query = new ResultSetMappingQuery(); ! query.setSQLResultSetMappingName(resultSetMapping); ! query.setSQLString(sqlString); ! query.setIsUserDefined(true); ! return new EJBQueryImpl(query, this); ! } catch (RuntimeException e) { ! this.transaction.setRollbackOnlyInternal(); ! throw e; ! } } /** *************** *** 235,241 **** * @return flushMode */ public FlushModeType getFlushMode() { ! return flushMode; } /** --- 274,286 ---- * @return flushMode */ public FlushModeType getFlushMode() { ! try { ! verifyOpen(); ! return flushMode; ! } catch (RuntimeException e) { ! this.transaction.setRollbackOnlyInternal(); ! throw e; ! } } /** *************** *** 244,258 **** * @param flushMode */ public void setFlushMode(FlushModeType flushMode) { ! this.flushMode = flushMode; } /** * This method is used to create a query using a Toplink Expression and the return type. */ public javax.persistence.Query createQuery(Expression expression, Class resultType){ ! DatabaseQuery query = createQueryInternal(expression, resultType); ! return new EJBQueryImpl(query, this); } /** --- 289,315 ---- * @param flushMode */ public void setFlushMode(FlushModeType flushMode) { ! try { ! verifyOpen(); ! this.flushMode = flushMode; ! } catch (RuntimeException e) { ! this.transaction.setRollbackOnlyInternal(); ! throw e; ! } } /** * This method is used to create a query using a Toplink Expression and the return type. */ public javax.persistence.Query createQuery(Expression expression, Class resultType){ ! try { ! verifyOpen(); ! DatabaseQuery query = createQueryInternal(expression, resultType); ! return new EJBQueryImpl(query, this); ! } catch (RuntimeException e) { ! this.transaction.setRollbackOnlyInternal(); ! throw e; ! } } /** *************** *** 261,270 **** * begin and commit multiple transactions. * @return EntityTransaction instance * @throws IllegalStateException if invoked on a JTA ! * EntityManager or an EntityManager that has been closed. */ public javax.persistence.EntityTransaction getTransaction(){ ! return ((TransactionWrapper)transaction).getTransaction(); } /** --- 318,332 ---- * begin and commit multiple transactions. * @return EntityTransaction instance * @throws IllegalStateException if invoked on a JTA ! * EntityManager. */ public javax.persistence.EntityTransaction getTransaction(){ ! try { ! return ((TransactionWrapper)transaction).getTransaction(); ! } catch (RuntimeException e) { ! this.transaction.setRollbackOnlyInternal(); ! throw e; ! } } /** ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/transaction/base/EntityTransactionImpl.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000005/AB0952363AC40CBFE034080020E8C54E.16 Report generated at Thu Nov 30 16:15:17 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000005/AB0952363AC40CBFE034080020E8C54E.16 Thu Nov 30 15:44:56 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/transaction/base/EntityTransactionImpl.java Thu Nov 30 16:13:50 2006 *************** *** 44,51 **** protected boolean active = false; - protected Boolean hasLastTransactionCompleted; - protected boolean rollbackOnly = false; public EntityTransactionImpl(EntityTransactionWrapper wrapper) { --- 44,49 ---- *************** *** 82,88 **** throw new IllegalStateException(TransactionException.transactionNotActive().getMessage()); } try { - transactionCompleted(); if (this.wrapper.localUOW != null){ this.wrapper.localUOW.setShouldTerminateTransaction(true); if (! this.rollbackOnly){ --- 80,85 ---- *************** *** 96,108 **** wrapper.getLocalUnitOfWork().release(); wrapper.getLocalUnitOfWork().getParent().release(); if (this.rollbackOnly){ ! wrapper.getEntityManager().clear(); throw new RollbackException(ExceptionLocalization.buildMessage("rollback_because_of_rollback_only")); } } }catch (RuntimeException ex){ if (this.wrapper.localUOW != null){ ! wrapper.getEntityManager().clear(); this.wrapper.localUOW.release(); this.wrapper.localUOW.getParent().release(); } --- 93,105 ---- wrapper.getLocalUnitOfWork().release(); wrapper.getLocalUnitOfWork().getParent().release(); if (this.rollbackOnly){ ! wrapper.getEntityManager().clearInternal(); throw new RollbackException(ExceptionLocalization.buildMessage("rollback_because_of_rollback_only")); } } }catch (RuntimeException ex){ if (this.wrapper.localUOW != null){ ! wrapper.getEntityManager().clearInternal(); this.wrapper.localUOW.release(); this.wrapper.localUOW.getParent().release(); } *************** *** 125,131 **** throw new IllegalStateException(TransactionException.transactionNotActive().getMessage()); } try{ - transactionCompleted(); if (wrapper.getLocalUnitOfWork() != null){ this.wrapper.localUOW.setShouldTerminateTransaction(true); this.wrapper.localUOW.release(); --- 122,127 ---- *************** *** 134,140 **** }finally{ this.active = false; this.rollbackOnly = false; ! wrapper.getEntityManager().clear(); wrapper.setLocalUnitOfWork(null); } } --- 130,136 ---- }finally{ this.active = false; this.rollbackOnly = false; ! wrapper.getEntityManager().clearInternal(); wrapper.setLocalUnitOfWork(null); } } *************** *** 182,206 **** */ public boolean isActive(){ return this.active; ! } ! ! /** ! * These two method used for closing of EntityManager in case there is a transaction in progress: ! * The first method is called by EntityManager.close method to mark the current transaction, ! * the second one is called by EntityManager.verifyOpen method. ! */ ! public void markLastTransaction() { ! if(hasLastTransactionCompleted == null) { ! hasLastTransactionCompleted = Boolean.FALSE; ! } ! } ! public boolean hasLastTransactionCompleted() { ! return hasLastTransactionCompleted != null && hasLastTransactionCompleted.booleanValue(); ! } ! protected void transactionCompleted() { ! if(hasLastTransactionCompleted != null) { ! hasLastTransactionCompleted = Boolean.TRUE; ! } ! } ! } --- 178,182 ---- */ public boolean isActive(){ return this.active; ! } } ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/transaction/base/EntityTransactionWrapper.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000006/AB0952363AC40CBFE034080020E8C54E.13 Report generated at Thu Nov 30 16:15:17 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000006/AB0952363AC40CBFE034080020E8C54E.13 Thu Nov 30 15:45:07 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/transaction/base/EntityTransactionWrapper.java Thu Nov 30 16:13:50 2006 *************** *** 89,98 **** throw new TransactionRequiredException(ExceptionLocalization.buildMessage("join_trans_called_on_entity_trans"));// no JTA transactions availab } ! public boolean shouldClose() { ! return (this.entityTransaction == null || ! this.entityTransaction.isActive()); } ! public boolean shouldFlushBeforeQuery(UnitOfWorkImpl uow){ return true; } --- 89,106 ---- throw new TransactionRequiredException(ExceptionLocalization.buildMessage("join_trans_called_on_entity_trans"));// no JTA transactions availab } ! /** ! * Mark the current transaction so that the only possible ! * outcome of the transaction is for the transaction to be ! * rolled back. ! * This is an internal method and if the txn is not active will do nothing ! */ ! public void setRollbackOnlyInternal(){ ! if (entityTransaction != null && entityTransaction.isActive()){ ! entityTransaction.setRollbackOnly(); ! } } ! public boolean shouldFlushBeforeQuery(UnitOfWorkImpl uow){ return true; } *************** *** 100,118 **** protected void throwCheckTransactionFailedException() { throw TransactionException.transactionNotActive(); } - - /** - * These two method used for closing of EntityManager in case there is a transaction in progress: - * The first method is called by EntityManager.close method to mark the current transaction, - * the second one is called by EntityManager.verifyOpen method. - */ - public void markLastTransaction() { - if(entityTransaction != null) { - entityTransaction.markLastTransaction(); - } - } - public boolean hasLastTransactionCompleted() { - return entityTransaction != null && entityTransaction.hasLastTransactionCompleted(); - } - } --- 108,111 ---- ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/transaction/base/JTATransactionWrapper.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.11 Report generated at Thu Nov 30 16:15:17 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.11 Thu Nov 30 15:45:19 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/transaction/base/JTATransactionWrapper.java Thu Nov 30 16:13:50 2006 *************** *** 42,49 **** //This is a quick reference for the external Transaction Controller protected AbstractTransactionController txnController; - protected Object lastTransaction; - public JTATransactionWrapper(EntityManagerImpl entityManager) { super(entityManager); this.txnController = (AbstractTransactionController)entityManager.getServerSession().getExternalTransactionController(); --- 42,47 ---- *************** *** 76,81 **** --- 74,92 ---- } /** + * INTERNAL: + * Mark the current transaction so that the only possible + * outcome of the transaction is for the transaction to be + * rolled back. + * This is an internal method and if the txn is not active will do nothing + */ + public void setRollbackOnlyInternal() { + if(txnController.getTransaction() != null) { + txnController.markTransactionForRollback(); + } + } + + /** * INTERNAL: * THis method is used to get the active UnitOfWork. It is special in that it will * return the required RepeatableWriteUnitOfWork required by the EntityManager. Once *************** *** 118,158 **** uow.registerWithTransactionIfRequired(); } - public boolean shouldClose() { - if (!txnController.noTransactionOrRolledBackOrCommited()) { - return false; - } - return true; - } - /** * We should only flush the entity manager before the query if the query is * joined to a transaction */ public boolean shouldFlushBeforeQuery(UnitOfWorkImpl uow){ return uow.isSynchronized(); ! } ! ! /** ! * These two method used for closing of EntityManager in case there is a transaction in progress: ! * The first method is called by EntityManager.close method to mark the current transaction, ! * the second one is called by EntityManager.verifyOpen method. ! */ ! public void markLastTransaction() { ! if(lastTransaction == null) { ! lastTransaction = txnController.getTransaction(); ! } ! } ! public boolean hasLastTransactionCompleted() { ! if(lastTransaction != null) { ! Object transaction = txnController.getTransaction(); ! if(transaction != null) { ! return !lastTransaction.equals(transaction); ! } else { ! return true; ! } ! } else { ! return false; ! } ! } } --- 129,139 ---- uow.registerWithTransactionIfRequired(); } /** * We should only flush the entity manager before the query if the query is * joined to a transaction */ public boolean shouldFlushBeforeQuery(UnitOfWorkImpl uow){ return uow.isSynchronized(); ! } } ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/transaction/base/TransactionWrapperImpl.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000008/AB0952363AC40CBFE034080020E8C54E.10 Report generated at Thu Nov 30 16:15:17 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000008/AB0952363AC40CBFE034080020E8C54E.10 Thu Nov 30 15:45:59 2006 --- /ade/ailitche_toplink_main/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/transaction/base/TransactionWrapperImpl.java Thu Nov 30 16:13:50 2006 *************** *** 83,100 **** * Mark the current transaction so that the only possible * outcome of the transaction is for the transaction to be * rolled back. ! * @throws IllegalStateException if isActive() is false. */ ! public void setRollbackOnlyInternal(){ ! //No -op for most wrappers as TopLink will mark for rollback in the case ! //of external transaction controller ! } ! ! /** ! * This method will be called when an entity manager attempts to close to verify its ! * transaction is in a closable state. ! */ ! public abstract boolean shouldClose(); /** * This method will be called when a query is executed. If changes in the entity manager --- 83,91 ---- * Mark the current transaction so that the only possible * outcome of the transaction is for the transaction to be * rolled back. ! * This is an internal method and if the txn is not active will do nothing */ ! public abstract void setRollbackOnlyInternal(); /** * This method will be called when a query is executed. If changes in the entity manager *************** *** 102,112 **** */ public abstract boolean shouldFlushBeforeQuery(UnitOfWorkImpl uow); - /** - * These two method used for closing of EntityManager in case there is a transaction in progress: - * The first method is called by EntityManager.close method to mark the current transaction, - * the second one is called by EntityManager.verifyOpen method. - */ - public abstract void markLastTransaction(); - public abstract boolean hasLastTransactionCompleted(); } --- 93,96 ---- ================================================================================ Merge Diffs: /ade/ailitche_toplink_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/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000009/AB0952363AC40CBFE034080020E8C54E.60 Report generated at Thu Nov 30 16:15:17 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000009/AB0952363AC40CBFE034080020E8C54E.60 Thu Nov 30 15:48:07 2006 --- /ade/ailitche_toplink_main/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/advanced/EntityManagerJUnitTestSuite.java Thu Nov 30 16:13:50 2006 *************** *** 156,162 **** em.refresh(emp); fail("entityManager.refresh(removedObject) didn't throw exception"); } catch (EntityNotFoundException entityNotFoundException) { ! em.getTransaction().commit(); // expected behaviour } catch (Exception exception ) { em.getTransaction().rollback(); --- 156,162 ---- em.refresh(emp); fail("entityManager.refresh(removedObject) didn't throw exception"); } catch (EntityNotFoundException entityNotFoundException) { ! em.getTransaction().rollback(); // expected behaviour } catch (Exception exception ) { em.getTransaction().rollback(); *************** *** 3145,3153 **** try { em.getTransaction().begin(); // make sure there are no pre-existing objects with this name em.createQuery("DELETE FROM Address a WHERE a.country = '"+firstName+"'").executeUpdate(); - em.createQuery("UPDATE Employee e set e.address = null where e.firstName = '" + firstName + "'").executeUpdate(); - em.createQuery("DELETE FROM Employee e WHERE e.firstName = '"+firstName+"'").executeUpdate(); // populate Employees for(int i=1; i<=n; i++) { Employee emp = new Employee(); --- 3145,3152 ---- try { em.getTransaction().begin(); // make sure there are no pre-existing objects with this name + em.createQuery("DELETE FROM Employee e WHERE e.firstName = '"+firstName+"'").executeUpdate(); em.createQuery("DELETE FROM Address a WHERE a.country = '"+firstName+"'").executeUpdate(); // populate Employees for(int i=1; i<=n; i++) { Employee emp = new Employee(); *************** *** 3221,3229 **** try { em.getTransaction().begin(); // make sure there are no objects left with this name em.createQuery("DELETE FROM Address a WHERE a.country = '"+firstName+"'").executeUpdate(); - em.createQuery("UPDATE Employee e set e.address = null where e.firstName = '" + firstName + "'").executeUpdate(); - em.createQuery("DELETE FROM Employee e WHERE e.firstName = '"+firstName+"'").executeUpdate(); em.getTransaction().commit(); } catch (RuntimeException ex){ if (em.getTransaction().isActive()){ --- 3220,3227 ---- try { em.getTransaction().begin(); // make sure there are no objects left with this name + em.createQuery("DELETE FROM Employee e WHERE e.firstName = '"+firstName+"'").executeUpdate(); em.createQuery("DELETE FROM Address a WHERE a.country = '"+firstName+"'").executeUpdate(); em.getTransaction().commit(); } catch (RuntimeException ex){ if (em.getTransaction().isActive()){ *************** *** 3590,3595 **** --- 3588,3674 ---- } } + public void testRollbackOnlyOnException() { + EntityManager em = createEntityManager(); + em.getTransaction().begin(); + try { + Employee emp = em.find(Employee.class, ""); + fail("IllegalArgumentException has not been thrown"); + } catch(IllegalArgumentException ex) { + assertTrue("Transaction is not roll back only", em.getTransaction().getRollbackOnly()); + } finally { + em.getTransaction().rollback(); + em.close(); + } + } + + public void testClosedEmShouldThrowException() { + EntityManager em = createEntityManager(); + em.close(); + String errorMsg = ""; + + try { + em.clear(); + errorMsg = errorMsg + "; em.clear() didn't throw exception"; + } catch(IllegalStateException ise) { + // expected + } catch(RuntimeException ex) { + errorMsg = errorMsg + "; em.clear() threw wrong exception: " + ex.getMessage(); + } + try { + em.close(); + errorMsg = errorMsg + "; em.close() didn't throw exception"; + } catch(IllegalStateException ise) { + // expected + } catch(RuntimeException ex) { + errorMsg = errorMsg + "; em.close() threw wrong exception: " + ex.getMessage(); + } + try { + em.contains(null); + errorMsg = errorMsg + "; em.contains() didn't throw exception"; + } catch(IllegalStateException ise) { + // expected + } catch(RuntimeException ex) { + errorMsg = errorMsg + "; em.contains threw() wrong exception: " + ex.getMessage(); + } + try { + em.getDelegate(); + errorMsg = errorMsg + "; em.getDelegate() didn't throw exception"; + } catch(IllegalStateException ise) { + // expected + } catch(RuntimeException ex) { + errorMsg = errorMsg + "; em.getDelegate() threw wrong exception: " + ex.getMessage(); + } + try { + em.getReference(Employee.class, new Integer(1)); + errorMsg = errorMsg + "; em.getReference() didn't throw exception"; + } catch(IllegalStateException ise) { + // expected + } catch(RuntimeException ex) { + errorMsg = errorMsg + "; em.getReference() threw wrong exception: " + ex.getMessage(); + } + try { + em.joinTransaction(); + errorMsg = errorMsg + "; em.joinTransaction() didn't throw exception"; + } catch(IllegalStateException ise) { + // expected + } catch(RuntimeException ex) { + errorMsg = errorMsg + "; em.joinTransaction() threw wrong exception: " + ex.getMessage(); + } + try { + em.lock(null, null); + errorMsg = errorMsg + "; em.lock() didn't throw exception"; + } catch(IllegalStateException ise) { + // expected + } catch(RuntimeException ex) { + errorMsg = errorMsg + "; em.lock() threw wrong exception: " + ex.getMessage(); + } + + if(errorMsg.length() > 0) { + fail(errorMsg); + } + } + public static void main(String[] args) { // Now run JUnit. junit.swingui.TestRunner.main(args); ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/relationships/ExecuteUpdateTest.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000010/AB0952363AC40CBFE034080020E8C54E.4 Report generated at Thu Nov 30 16:15:17 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000010/AB0952363AC40CBFE034080020E8C54E.4 Thu Nov 30 15:49:44 2006 --- /ade/ailitche_toplink_main/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/relationships/ExecuteUpdateTest.java Thu Nov 30 16:13:50 2006 *************** *** 8,13 **** --- 8,14 ---- import oracle.toplink.essentials.testing.models.cmp3.relationships.*; import oracle.toplink.essentials.testing.tests.cmp3.EntityContainerTestBase; import oracle.toplink.essentials.exceptions.QueryException; + import javax.persistence.RollbackException; /* * Tests for the executeUpdate method on the EJBQueryImpl class *************** *** 29,34 **** --- 30,36 ---- protected String nameChange3 = "New Name3"; protected String returnedName1,returnedName2,returnedName3 = null; protected Exception expectedException =null; + protected RollbackException expectedException2 = null; public ExecuteUpdateTest() { } *************** *** 111,123 **** expectedException=expected; } ! commitTransaction(); ! ! } catch (Exception ex) { ! try{ commitTransaction(); ! }catch(Exception comitEx){} throw new TestErrorException("Exception thrown while executing updates" + ex, ex); } } --- 113,129 ---- expectedException=expected; } ! try { commitTransaction(); ! expectedException2 = null; ! }catch(RollbackException ex){ ! expectedException2 = ex; ! } ! ! } catch (Exception ex) { throw new TestErrorException("Exception thrown while executing updates" + ex, ex); + } finally { + rollbackTransaction(); } } *************** *** 131,137 **** 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 findAllCustomers named ReadAllQuery"); } } --- 137,147 ---- 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 findAllCustomers named ReadAllQuery"); + } + if ( expectedException2==null ){ + throw new TestErrorException("commit did not throw expected RollbackException"); + } } } ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/relationships/GetResultListTest.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000011/AB0952363AC40CBFE034080020E8C54E.5 Report generated at Thu Nov 30 16:15:17 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000011/AB0952363AC40CBFE034080020E8C54E.5 Thu Nov 30 15:50:04 2006 --- /ade/ailitche_toplink_main/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/relationships/GetResultListTest.java Thu Nov 30 16:13:50 2006 *************** *** 11,16 **** --- 11,17 ---- import oracle.toplink.essentials.testing.framework.*; import oracle.toplink.essentials.testing.models.cmp3.relationships.*; import java.util.List; + import javax.persistence.RollbackException; /* * Tests using the 'getSingleResult' api on a Query object obtained from the EntityManager * Also tests bugs 4300879 - check non List container policy error *************** *** 26,31 **** --- 27,34 ---- public Integer[] cusIDs = new Integer[3]; + protected RollbackException expectedException3 = null; + public GetResultListTest() { } *************** *** 68,79 **** expectedException2 = exceptionExpected2; } ! commitTransaction(); ! }catch (Exception unexpectedException){ ! try{ commitTransaction(); ! }catch(Exception comitEx){} throw new TestErrorException("Problem in GetResultListTest: "+unexpectedException); } } --- 71,87 ---- expectedException2 = exceptionExpected2; } ! try { commitTransaction(); ! expectedException3 = null; ! }catch(RollbackException ex){ ! expectedException3 = ex; ! } ! ! }catch (Exception unexpectedException){ throw new TestErrorException("Problem in GetResultListTest: "+unexpectedException); + }finally{ + rollbackTransaction(); } } *************** *** 90,95 **** --- 98,106 ---- if ( expectedException2==null || (expectedException2.getErrorCode()!= QueryException.INCORRECT_QUERY_FOUND)){ throw new TestErrorException("getResultList on ReadObjectQuery did not throw expected INCORRECT_QUERY_FOUNDQueryException"); } + if ( expectedException3==null ){ + throw new TestErrorException("commit did not throw expected RollbackException"); + } } } ================================================================================ Merge Diffs: /ade/ailitche_toplink_main/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/relationships/GetSingleResultTest.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000012/AB0952363AC40CBFE034080020E8C54E.7 Report generated at Thu Nov 30 16:15:17 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/ailitche/ailitche_ri_gf1925_gf1616_061130/ade_storage/000012/AB0952363AC40CBFE034080020E8C54E.7 Thu Nov 30 15:50:12 2006 --- /ade/ailitche_toplink_main/tltest/source/essentials/oracle/toplink/essentials/testing/tests/cmp3/relationships/GetSingleResultTest.java Thu Nov 30 16:13:50 2006 *************** *** 4,9 **** --- 4,11 ---- import javax.persistence.NoResultException; import javax.persistence.NonUniqueResultException; import javax.persistence.Query; + import javax.persistence.RollbackException; + import oracle.toplink.essentials.exceptions.QueryException; import oracle.toplink.essentials.internal.ejb.cmp3.EJBQueryImpl; import oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl; *************** *** 30,35 **** --- 32,38 ---- protected NonUniqueResultException expectedException1 = null; protected NoResultException expectedException2 = null; protected QueryException expectedException3 = null; + protected RollbackException expectedException4 = null; protected String searchString = "notAnItemName"; *************** *** 117,129 **** readObjectQuery.setEJBQLString("SELECT OBJECT(thecust) FROM Customer 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); } } --- 120,137 ---- readObjectQuery.setEJBQLString("SELECT OBJECT(thecust) FROM Customer thecust WHERE thecust.customerId = :id"); query4.setDatabaseQuery(readObjectQuery); returnedCustomer2 = (Customer)query4.getSingleResult(); + + try { + commitTransaction(); + expectedException4 = null; + }catch(RollbackException ex){ + expectedException4 = ex; + } }catch (Exception unexpectedException){ throw new TestErrorException("Problem in GetSingleResultTest: "+unexpectedException); + }finally{ + rollbackTransaction(); } } *************** *** 137,142 **** --- 145,153 ---- 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 ( expectedException4==null ){ + throw new TestErrorException("commit did not throw expected RollbackException"); + } if ( returnedCustomer1==null || (!returnedCustomer1.getCustomerId().equals(cusIDs[0])) ){ throw new TestErrorException("Incorrect Single Customer returned, found: "+returnedCustomer1); }