本文整理汇总了Java中com.sleepycat.je.SequenceNotFoundException类的典型用法代码示例。如果您正苦于以下问题:Java SequenceNotFoundException类的具体用法?Java SequenceNotFoundException怎么用?Java SequenceNotFoundException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SequenceNotFoundException类属于com.sleepycat.je包,在下文中一共展示了SequenceNotFoundException类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openSequence
import com.sleepycat.je.SequenceNotFoundException; //导入依赖的package包/类
/**
* Opens or creates a sequence.
*
* This method tries to open an existing sequence or create a new sequence with starting value
* of the next available id number in the specified index.
*
* @param entityStore The store that contains the sequence.
* @param index The index which is used to initialize the starting value.
* @param sequenceName The name of the sequence.
* @return The opened or created sequence.
*/
public static Sequence openSequence(EntityStore entityStore, EntityIndex<Long, ?> index,
String sequenceName) {
Sequence seq = null;
try {
seq = entityStore.getSequence(sequenceName);
} catch (SequenceNotFoundException ex) {
// Establish current value
long initialValue = DatabaseUtils.getMaxId(index) + 1;
entityStore.setSequenceConfig(sequenceName,
SequenceConfig.DEFAULT.setAllowCreate(true).setInitialValue(initialValue));
seq = entityStore.getSequence(sequenceName);
} finally {
if (seq == null) {
throw new RuntimeException("Could not open sequence localIdSequence.");
}
return seq;
}
}
示例2: openSequence
import com.sleepycat.je.SequenceNotFoundException; //导入依赖的package包/类
/**
* @see SecondaryDatabase#openSequence(Transaction, DatabaseEntry, SequenceConfig)
*/
public Sequence openSequence(final Transaction txn, final DatabaseEntry key,
final SequenceConfig config) throws SequenceNotFoundException,
SequenceExistsException {
return delegate().openSequence(txn, key, config);
}