Java 类org.hibernate.id.enhanced.AccessCallback 实例源码

项目:lams    文件:SequenceHiLoGenerator.java   
public synchronized Serializable generate(final SessionImplementor session, Object obj) {
    // maxLo < 1 indicates a hilo generator with no hilo :?
    if ( maxLo < 1 ) {
        //keep the behavior consistent even for boundary usages
        IntegralDataTypeHolder value = null;
        while ( value == null || value.lt( 0 ) ) {
            value = super.generateHolder( session );
        }
        return value.makeValue();
    }

    return hiloOptimizer.generate(
            new AccessCallback() {
                public IntegralDataTypeHolder getNextValue() {
                    return generateHolder( session );
                }

                @Override
                public String getTenantIdentifier() {
                    return session.getTenantIdentifier();
                }
            }
    );
}
项目:lams    文件:TableHiLoGenerator.java   
@Override
public synchronized Serializable generate(final SessionImplementor session, Object obj) {
    // maxLo < 1 indicates a hilo generator with no hilo :?
    if ( maxLo < 1 ) {
        //keep the behavior consistent even for boundary usages
        IntegralDataTypeHolder value = null;
        while ( value == null || value.lt( 0 ) ) {
            value = generateHolder( session );
        }
        return value.makeValue();
    }

    return hiloOptimizer.generate(
            new AccessCallback() {
                public IntegralDataTypeHolder getNextValue() {
                    return generateHolder( session );
                }

                @Override
                public String getTenantIdentifier() {
                    return session.getTenantIdentifier();
                }
            }
    );
}
项目:lightmare    文件:TableGeneratorExt.java   
/**
    * Updates (or inserts) table column value with existing id
    * 
    * @param session
    * @param currentValue
    * @return {@link Serializable}
    */
   public Serializable generateIncrementally(final SessionImplementor session,
    final long currentValue) {

final SqlStatementLogger statementLogger = session.getFactory()
    .getServiceRegistry().getService(JdbcServices.class)
    .getSqlStatementLogger();
final AccessCallback callback = new AccessCallbackImpl(session,
    currentValue, statementLogger);

return optimizer.generate(callback);
   }