本文整理汇总了Java中org.hibernate.id.IntegralDataTypeHolder.initialize方法的典型用法代码示例。如果您正苦于以下问题:Java IntegralDataTypeHolder.initialize方法的具体用法?Java IntegralDataTypeHolder.initialize怎么用?Java IntegralDataTypeHolder.initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.id.IntegralDataTypeHolder
的用法示例。
在下文中一共展示了IntegralDataTypeHolder.initialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSelect
import org.hibernate.id.IntegralDataTypeHolder; //导入方法依赖的package包/类
private void onSelect(Connection connection,
IntegralDataTypeHolder value) throws SQLException {
PreparedStatement selectPS = connection
.prepareStatement(selectQuery);
try {
selectPS.setString(FIRST_COLUMN, segmentValue);
ResultSet selectRS = selectPS.executeQuery();
if (selectRS.next()) {
value.initialize(selectRS, FIRST_COLUMN);
} else {
value.initialize(currentValue);
insert(connection, value);
}
selectRS.close();
} catch (SQLException ex) {
LOG.unableToReadOrInitHiValue(ex);
throw ex;
} finally {
selectPS.close();
}
}
示例2: buildCallback
import org.hibernate.id.IntegralDataTypeHolder; //导入方法依赖的package包/类
@Override
public AccessCallback buildCallback(final SessionImplementor session) {
return new AccessCallback() {
@Override
public IntegralDataTypeHolder getNextValue() {
accessCounter++;
try {
final PreparedStatement st = session.getTransactionCoordinator().getJdbcCoordinator().getStatementPreparer().prepareStatement( sql );
try {
final ResultSet rs = session.getTransactionCoordinator().getJdbcCoordinator().getResultSetReturn().extract( st );
try {
rs.next();
final IntegralDataTypeHolder value = IdentifierGeneratorHelper.getIntegralDataTypeHolder( numberType );
value.initialize( rs, 1 );
if ( LOG.isDebugEnabled() ) {
LOG.debugf( "Sequence value obtained: %s", value.makeValue() );
}
return value;
}
finally {
try {
session.getTransactionCoordinator().getJdbcCoordinator().release( rs, st );
}
catch( Throwable ignore ) {
// intentionally empty
}
}
}
finally {
session.getTransactionCoordinator().getJdbcCoordinator().release( st );
}
}
catch ( SQLException sqle) {
throw session.getFactory().getSQLExceptionHelper().convert(
sqle,
"could not get next sequence value",
sql
);
}
}
@Override
public String getTenantIdentifier() {
return session.getTenantIdentifier();
}
};
}
示例3: onUpdate
import org.hibernate.id.IntegralDataTypeHolder; //导入方法依赖的package包/类
private int onUpdate(Connection connection, IntegralDataTypeHolder value)
throws SQLException {
int rows;
PreparedStatement updatePS = connection
.prepareStatement(updateQuery);
try {
final IntegralDataTypeHolder updateValue = value.copy()
.initialize(currentValue);
// TODO check for incrementSize
// increment options
updateValue.increment();
// gets existing value and
// incremented current values as
// long types to compare
Long existing = value.copy().makeValue().longValue();
Long current = updateValue.copy().makeValue().longValue();
// checks if incremented current
// value is less then value and
// puts incremented value
// instead of incremented
// current value for
// update
if (existing > current) {
updateValue.initialize(existing).increment();
}
updateValue.bind(updatePS, FIRST_COLUMN);
value.bind(updatePS, SECOND_COLUMN);
updatePS.setString(THIRD_COLUMN, segmentValue);
rows = updatePS.executeUpdate();
value.initialize(currentValue);
} catch (SQLException ex) {
LOG.unableToUpdateQueryHiValue(tableName, ex);
throw ex;
} finally {
updatePS.close();
}
return rows;
}