Methods Summary |
---|
public static java.lang.Object | getVersion(java.lang.Object[] fields, org.hibernate.persister.entity.EntityPersister persister)Extract the optimisitc locking value out of the entity state snapshot.
if ( !persister.isVersioned() ) {
return null;
}
return fields[ persister.getVersionProperty() ];
|
public static java.lang.Object | increment(java.lang.Object version, org.hibernate.type.VersionType versionType, SessionImplementor session)Generate the next increment in the optimisitc locking value according
the {@link VersionType} contract for the version property.
Object next = versionType.next( version, session );
if ( log.isTraceEnabled() ) {
log.trace(
"Incrementing: " +
versionType.toLoggableString( version, session.getFactory() ) +
" to " +
versionType.toLoggableString( next, session.getFactory() )
);
}
return next;
|
public static boolean | isVersionIncrementRequired(int[] dirtyProperties, boolean hasDirtyCollections, boolean[] propertyVersionability)Do we need to increment the version number, given the dirty properties?
if ( hasDirtyCollections ) {
return true;
}
for ( int i = 0; i < dirtyProperties.length; i++ ) {
if ( propertyVersionability[ dirtyProperties[i] ] ) {
return true;
}
}
return false;
|
private static java.lang.Object | seed(org.hibernate.type.VersionType versionType, SessionImplementor session)Create an initial optimisitc locking value according the {@link VersionType}
contract for the version property.
Object seed = versionType.seed( session );
if ( log.isTraceEnabled() ) log.trace("Seeding: " + seed);
return seed;
|
public static boolean | seedVersion(java.lang.Object[] fields, int versionProperty, org.hibernate.type.VersionType versionType, SessionImplementor session)Create an initial optimisitc locking value according the {@link VersionType}
contract for the version property if required and inject it into
the snapshot state.
Object initialVersion = fields[versionProperty];
if (
initialVersion==null ||
// This next bit is to allow for both unsaved-value="negative"
// and for "older" behavior where version number did not get
// seeded if it was already set in the object
// TODO: shift it into unsaved-value strategy
( (initialVersion instanceof Number) && ( (Number) initialVersion ).longValue()<0 )
) {
fields[versionProperty] = seed( versionType, session );
return true;
}
else {
if ( log.isTraceEnabled() ) {
log.trace( "using initial version: " + initialVersion );
}
return false;
}
|
public static void | setVersion(java.lang.Object[] fields, java.lang.Object version, org.hibernate.persister.entity.EntityPersister persister)Inject the optimisitc locking value into the entity state snapshot.
if ( !persister.isVersioned() ) {
return;
}
fields[ persister.getVersionProperty() ] = version;
|