Examples of OptimisticLockException


Examples of javax.persistence.OptimisticLockException

    entityControl.verify();
    txControl.verify();
  }

  public void testTranslateException() {
    OptimisticLockException ex = new OptimisticLockException();
    assertEquals(
        EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(ex).getCause(),
        dialect.translateExceptionIfPossible(ex).getCause());
  }
View Full Code Here

Examples of javax.persistence.OptimisticLockException

    mockTx.isActive();
    tmMc.setReturnValue(false);
    mockTx.begin();
    tmMc.setVoidCallable();
    mockTx.commit();
    tmMc.setThrowable(new OptimisticLockException());
    tmMc.replay();

    // This one's for the tx (shared)
    MockControl sharedEmMc = MockControl.createControl(EntityManager.class);
    EntityManager sharedEm = (EntityManager) sharedEmMc.getMock();
View Full Code Here

Examples of javax.persistence.OptimisticLockException

    NonUniqueResultException nonUniqueResult = new NonUniqueResultException();
    assertSame(IncorrectResultSizeDataAccessException.class,
        EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(nonUniqueResult).getClass());

    OptimisticLockException optimisticLock = new OptimisticLockException();
    assertSame(JpaOptimisticLockingFailureException.class,
        EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(optimisticLock).getClass());

    EntityExistsException entityExists = new EntityExistsException("foo");
    assertSame(DataIntegrityViolationException.class,
View Full Code Here

Examples of nexj.core.persistence.OptimisticLockException

            {
               if (updateCounts[i] != 1 && (m_lockingColumn != null || m_bInsert || updateCounts[i] != PreparedStatement.SUCCESS_NO_INFO))
               {
                  if (isPrimary())
                  {
                     throw new OptimisticLockException(workArray[nStart + i].getInstance());
                  }
                  else if (m_bInsert)
                  {
                     if (!bInsert)
                     {
                        stmt = stmt.getConnection().prepareStatement(getInsertSQL());
                        bInsert = true;
                     }

                     ((SQLUpdate)workArray[nStart + i]).bindInsert(stmt, 0);
                     stmt.addBatch();                    
                  }
               }

               if (m_bKeyChanged)
               {
                  ((SQLUpdate)workArray[nStart + i]).updateOID();
               }
            }

            if (bInsert)
            {
               m_adapter.executeBatch(stmt);
            }
         }
         else
         {
            if (m_adapter.executeUpdate(stmt) != 1)
            {
               if (isPrimary())
               {
                  throw new OptimisticLockException(m_instance);
               }
               else if (m_bInsert)
               {
                  stmt = stmt.getConnection().prepareStatement(getInsertSQL());
                  bInsert = true;
View Full Code Here

Examples of org.apache.cayenne.access.OptimisticLockException

                    }
                    else if (query instanceof DeleteBatchQuery) {
                        snapshot = ((DeleteBatchQuery) query).getCurrentQualifier();
                    }

                    throw new OptimisticLockException(
                            query.getDbEntity(),
                            queryStr,
                            snapshot);
                }
View Full Code Here

Examples of org.apache.cayenne.access.OptimisticLockException

                    }
                    else if (query instanceof DeleteBatchQuery) {
                        snapshot = ((DeleteBatchQuery) query).getCurrentQualifier();
                    }

                    throw new OptimisticLockException(
                            query.getDbEntity(),
                            queryStr,
                            snapshot);
                }
View Full Code Here

Examples of org.apache.cayenne.access.OptimisticLockException

                    }
                    else if (query instanceof DeleteBatchQuery) {
                        snapshot = ((DeleteBatchQuery) query).getCurrentQualifier();
                    }

                    throw new OptimisticLockException(
                            query.getDbEntity(),
                            queryStr,
                            snapshot);
                }
View Full Code Here

Examples of org.apache.ojb.broker.OptimisticLockException

            // thma: the following check is not secure. The object could be deleted *or* changed.
            // if it was deleted it makes no sense to throw an OL exception.
            // does is make sense to throw an OL exception if the object was changed?
            if (stmt.executeUpdate() == 0 && cld.isLocking()) //BRJ
            {
                throw new OptimisticLockException("Object has been modified or deleted by someone else", obj);
            }

            // Harvest any return values.
            harvestReturnValues(cld.getDeleteProcedure(), obj, stmt);
        }
View Full Code Here

Examples of org.hibernate.OptimisticLockException

  }

  @Override
  public void lock(Serializable id, Object version, Object object, int timeout, SessionImplementor session) {
    if ( !lockable.isVersioned() ) {
      throw new OptimisticLockException( object, "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
    }
    final EntityEntry entry = session.getPersistenceContext().getEntry( object );
    // Register the EntityVerifyVersionProcess action to run just prior to transaction commit.
    ( (EventSource) session ).getActionQueue().registerProcess( new EntityVerifyVersionProcess( object, entry ) );
  }
View Full Code Here

Examples of org.hibernate.OptimisticLockException

  public void doBeforeTransactionCompletion(SessionImplementor session) {
    final EntityPersister persister = entry.getPersister();

    final Object latestVersion = persister.getCurrentVersion( entry.getId(), session );
    if ( !entry.getVersion().equals( latestVersion ) ) {
      throw new OptimisticLockException(
          object,
          "Newer version [" + latestVersion +
              "] of entity [" + MessageHelper.infoString( entry.getEntityName(), entry.getId() ) +
              "] found in database"
      );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.