private Tuple createNewResultSetIfNull( EntityKey key, Tuple resultset, Serializable id, SessionImplementor session) { if (resultset == null) { resultset = gridDialect.createTuple(key, getTupleContext()); gridIdentifierType.nullSafeSet(resultset, id, getIdentifierColumnNames(), session); } return resultset; }
@Override public Object forceVersionIncrement( Serializable id, Object currentVersion, SessionImplementor session) { if (!isVersioned()) { throw new AssertionFailure("cannot force version increment on non-versioned entity"); } if (isVersionPropertyGenerated()) { // the difficulty here is exactly what do we update in order to // force the version to be incremented in the db... throw new HibernateException( "LockMode.FORCE is currently not supported for generated version properties"); } Object nextVersion = getVersionType().next(currentVersion, session); if (log.isTraceEnabled()) { log.trace( "Forcing version increment [" + MessageHelper.infoString(this, id, getFactory()) + "; " + getVersionType().toLoggableString(currentVersion, getFactory()) + " -> " + getVersionType().toLoggableString(nextVersion, getFactory()) + "]"); } /* * We get the value from the grid and compare the version values before putting the next version in * Contrary to the database version, there is * TODO should we use cache.replace() it seems more expensive to pass the resultset around "just" the atomicity of the operation */ final EntityKey key = EntityKeyBuilder.fromPersister(this, id, session); final Tuple resultset = gridDialect.getTuple(key, getTupleContext()); checkVersionAndRaiseSOSE(id, currentVersion, session, resultset); gridVersionType.nullSafeSet( resultset, nextVersion, new String[] {getVersionColumnName()}, session); gridDialect.updateTuple(resultset, key, getTupleContext()); return nextVersion; }