本文整理汇总了Java中org.hibernate.ogm.dialect.spi.NextValueRequest类的典型用法代码示例。如果您正苦于以下问题:Java NextValueRequest类的具体用法?Java NextValueRequest怎么用?Java NextValueRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NextValueRequest类属于org.hibernate.ogm.dialect.spi包,在下文中一共展示了NextValueRequest类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: nextValue
import org.hibernate.ogm.dialect.spi.NextValueRequest; //导入依赖的package包/类
@Override
public Number nextValue(NextValueRequest request) {
Long result = null;
switch ( request.getKey().getMetadata().getType() ) {
case TABLE:
IgniteCache<String, Long> cache = provider.getIdSourceCache( request.getKey().getMetadata() );
String idSourceKey = request.getKey().getColumnValue();
Long previousValue = cache.get( idSourceKey );
if ( previousValue == null ) {
result = (long) request.getInitialValue();
if ( !cache.putIfAbsent( idSourceKey, result ) ) {
previousValue = (long) request.getInitialValue();
}
}
if ( previousValue != null ) {
while ( true ) {
result = previousValue + request.getIncrement();
if ( cache.replace( idSourceKey, previousValue, result ) ) {
break;
}
else {
previousValue = cache.get( idSourceKey );
}
}
}
break;
case SEQUENCE:
IgniteAtomicSequence seq = provider.atomicSequence( request.getKey().getMetadata().getName(), request.getInitialValue(), false );
result = seq.getAndAdd( request.getIncrement() );
break;
}
return result;
}
示例2: nextValue
import org.hibernate.ogm.dialect.spi.NextValueRequest; //导入依赖的package包/类
@Override
public Number nextValue(NextValueRequest request) {
throw new UnsupportedOperationException("not yet supported");
}