本文整理匯總了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);
}