public HibernateOptimisticLockingFailureException(StaleStateException ex) { super(ex.getMessage(), ex); }
private void checkNonBatched(int rowCount, PreparedStatement statement) { if ( expectedRowCount > rowCount ) { throw new StaleStateException( "Unexpected row count: " + rowCount + "; expected: " + expectedRowCount + "; statement executed: " + statement ); } if ( expectedRowCount < rowCount ) { String msg = "Unexpected row count: " + rowCount + "; expected: " + expectedRowCount; throw new TooManyRowsAffectedException( msg, expectedRowCount, rowCount ); } }
public HibernateOptimisticLockingFailureException(StaleStateException ex) { super(ex.getMessage(), ex); }
private void checkBatched(int rowCount, int batchPosition, PreparedStatement statement) { if ( rowCount == -2 ) { LOG.debugf( "Success of batch update unknown: %s", batchPosition ); } else if ( rowCount == -3 ) { throw new BatchFailedException( "Batch update failed: " + batchPosition ); } else { if ( expectedRowCount > rowCount ) { throw new StaleStateException( "Batch update returned unexpected row count from update [" + batchPosition + "]; actual row count: " + rowCount + "; expected: " + expectedRowCount + "; statement executed: " + statement ); } if ( expectedRowCount < rowCount ) { String msg = "Batch update returned unexpected row count from update [" + batchPosition + "]; actual row count: " + rowCount + "; expected: " + expectedRowCount; throw new BatchedTooManyRowsAffectedException( msg, expectedRowCount, rowCount, batchPosition ); } } }
public String getMessage() { return super.getMessage() + " : " + MessageHelper.infoString( entityName, identifier ); }
private void checkNonBatched(int rowCount) { if ( expectedRowCount > rowCount ) { throw new StaleStateException( "Unexpected row count: " + rowCount + "; expected: " + expectedRowCount ); } if ( expectedRowCount < rowCount ) { String msg = "Unexpected row count: " + rowCount + "; expected: " + expectedRowCount; throw new TooManyRowsAffectedException( msg, expectedRowCount, rowCount ); } }
protected PersistenceException wrapStaleStateException(StaleStateException e) { PersistenceException pe; if ( e instanceof StaleObjectStateException ) { final StaleObjectStateException sose = (StaleObjectStateException) e; final Serializable identifier = sose.getIdentifier(); if ( identifier != null ) { try { final Object entity = sharedSessionContract.internalLoad( sose.getEntityName(), identifier, false, true); if ( entity instanceof Serializable ) { //avoid some user errors regarding boundary crossing pe = new OptimisticLockException( e.getMessage(), e, entity ); } else { pe = new OptimisticLockException( e.getMessage(), e ); } } catch (EntityNotFoundException enfe) { pe = new OptimisticLockException( e.getMessage(), e ); } } else { pe = new OptimisticLockException( e.getMessage(), e ); } } else { pe = new OptimisticLockException( e.getMessage(), e ); } return pe; }
private void checkNonBatched(int rowCount) { if ( expectedRowCount > rowCount ) { throw new StaleStateException( "Unexpected row count: " + rowCount + "; expected: " + expectedRowCount ); } if ( expectedRowCount < rowCount ) { String msg = "Unexpected row count: " + rowCount + "; expected: " + expectedRowCount; throw new TooManyRowsAffectedException( msg, expectedRowCount, rowCount ); } }
public HibernateOptimisticLockingFailureException(StaleStateException ex) { super(ex.getMessage(), ex); }
private void checkNonBatched(int rowCount) { if ( expectedRowCount > rowCount ) { throw new StaleStateException( "Unexpected row count: " + rowCount + "; expected: " + expectedRowCount ); } if ( expectedRowCount < rowCount ) { String msg = "Unexpected row count: " + rowCount + "; expected: " + expectedRowCount; throw new TooManyRowsAffectedException( msg, expectedRowCount, rowCount ); } }
public HibernateOptimisticLockingFailureException(StaleStateException ex) { super(ex.getMessage(), ex); }
public void addToBatch(int expectedRowCount) throws SQLException, HibernateException { final int rowCount = getStatement().executeUpdate(); //negative expected row count means we don't know how many rows to expect if ( expectedRowCount>0 ) { if ( expectedRowCount<rowCount ) { throw new StaleStateException( "Unexpected row count: " + rowCount + " expected: " + expectedRowCount ); } if ( expectedRowCount>rowCount ) { throw new HibernateException( "Unexpected row count: " + rowCount + " expected: " + expectedRowCount ); } } }
public HibernateOptimisticLockingFailureException(StaleStateException ex) { super(ex.getMessage(), ex); }
private void checkRowCount(int rowCount, int expectedRowCount, int i) { if ( rowCount==-2 ) { if ( log.isDebugEnabled() ) log.debug("success of batch update unknown: " + i); } else if ( rowCount==-3 ) { throw new HibernateException("Batch update failed: " + i); } else { if ( expectedRowCount>=0 ) { if ( rowCount<expectedRowCount ) { throw new StaleStateException( "Batch update returned unexpected row count from update: " + i + " actual row count: " + rowCount + " expected: " + expectedRowCount ); } if ( rowCount>expectedRowCount ) { throw new HibernateException( "Batch update returned unexpected row count from update: " + i + " actual row count: " + rowCount + " expected: " + expectedRowCount ); } } } }
public String getMessage() { return super.getMessage() + ": " + MessageHelper.infoString(entityName, identifier); }
private void checkBatched(int rowCount, int batchPosition) { if (rowCount == -2) LOG.debugf("Success of batch update unknown: %s", batchPosition); else if (rowCount == -3) throw new BatchFailedException("Batch update failed: " + batchPosition); else { if (expectedRowCount > rowCount) throw new StaleStateException( "Batch update returned unexpected row count from update [" + batchPosition + "]; actual row count: " + rowCount + "; expected: " + expectedRowCount); if ( expectedRowCount < rowCount ) { String msg = "Batch update returned unexpected row count from update [" + batchPosition + "]; actual row count: " + rowCount + "; expected: " + expectedRowCount; throw new BatchedTooManyRowsAffectedException( msg, expectedRowCount, rowCount, batchPosition ); } } }
public String getMessage() { return super.getMessage() + ": " + MessageHelper.infoString(entityName, identifier); }
private void checkBatched(int rowCount, int batchPosition) { if (rowCount == -2) LOG.debugf("Success of batch update unknown: %s", batchPosition); else if (rowCount == -3) throw new BatchFailedException("Batch update failed: " + batchPosition); else { if (expectedRowCount > rowCount) throw new StaleStateException( "Batch update returned unexpected row count from update [" + batchPosition + "]; actual row count: " + rowCount + "; expected: " + expectedRowCount); if ( expectedRowCount < rowCount ) { String msg = "Batch update returned unexpected row count from update [" + batchPosition + "]; actual row count: " + rowCount + "; expected: " + expectedRowCount; throw new BatchedTooManyRowsAffectedException( msg, expectedRowCount, rowCount, batchPosition ); } } }
public String getMessage() { return super.getMessage() + ": " + MessageHelper.infoString(entityName, identifier); }
public static void checkVersion(Object value, Session session, Object oldVersion, Object version) { ClassMetadata classMetadata = getClassMetadata(value, session); VersionType versionType = (VersionType) classMetadata.getPropertyTypes()[ classMetadata.getVersionProperty() ]; if ( !versionType.isEqual(oldVersion, version) ) { throw new StaleStateException("current database version number does not match passivated version number"); } }