Package org.hibernate

Examples of org.hibernate.OptimisticLockException


    Object latestVersion = persister.getCurrentVersion(
      entry.getId(), session
    );
     if(!entry.getVersion().equals(latestVersion))
      throw new OptimisticLockException(
        "Newer version ("+ latestVersion+
        ") of entity ("+entry.getEntityName()+") found in database.  id=" +  entry.getId());
  }
View Full Code Here


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

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

    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

  }

  @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() + "]" );
    }
    EntityEntry entry = session.getPersistenceContext().getEntry(object);
    EventSource source = (EventSource)session;
    EntityVerifyVersionProcess verifyVersion = new EntityVerifyVersionProcess(object, entry);
    // Register the EntityVerifyVersionProcess action to run just prior to transaction commit.
View Full Code Here

TOP

Related Classes of org.hibernate.OptimisticLockException

Copyright © 2018 www.massapicom. 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.