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 ); } }
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 ); } } }
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 ); } }
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 ); } }
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 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 ); } } }
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 ); } } } }
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 ); } } }
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 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"); } }
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 ); } } }
@Override protected void respond(AjaxRequestTarget target) { IRequestParameters params = RequestCycle.get().getRequest().getPostParameters(); int taskPosition = params.getParameterValue(SourcePositionTrackExtension.DATA_START_ATTRIBUTE).toInt(); boolean taskChecked = params.getParameterValue(TASK_CHECKED).toBoolean(); String markdown = getComponent().getDefaultModelObjectAsString(); String beforeTask = markdown.substring(0, taskPosition); String fromTask = markdown.substring(taskPosition); String beforeBracket = StringUtils.substringBefore(fromTask, "["); String afterBracket = StringUtils.substringAfter(fromTask, "]"); String taskStatus = taskChecked?"x":" "; markdown = beforeTask + beforeBracket + "[" + taskStatus + "]" + afterBracket; try { if (contentVersionSupport.getVersion() != lastContentVersion) throw new StaleStateException(""); setDefaultModelObject(markdown); } catch (StaleStateException e) { warn("Some one changed the content you are editing. The content has now been reloaded, " + "please try again."); } target.add(MarkdownViewer.this); lastContentVersion = contentVersionSupport.getVersion(); }