keyClassName = SimpleCatalog.keyClassName(keyClassName);
DatabaseConfig dbConfig = getPrimaryConfig(meta);
PrimaryIndex<Object, Object> index = getPrimaryIndex
(Object.class, keyClassName, entityClass, entityClassName);
Database db = index.getDatabase();
EntityBinding binding = index.getEntityBinding();
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry data = new DatabaseEntry();
CursorConfig cursorConfig = null;
Transaction txn = null;
if (dbConfig.getTransactional()) {
txn = env.beginTransaction(null, autoCommitTxnConfig);
cursorConfig = CursorConfig.READ_COMMITTED;
}
Cursor cursor = null;
int nWritten = 0;
try {
cursor = db.openCursor(txn, cursorConfig);
OperationStatus status = cursor.getFirst(key, data, null);
while (status == OperationStatus.SUCCESS) {
boolean oneWritten = false;
if (evolveNeeded(key, data, binding)) {
cursor.putCurrent(data);
oneWritten = true;
nWritten += 1;
}
/* Update event stats, even if no listener. [#17024] */
EvolveInternal.updateEvent
(event, entityClassName, 1, oneWritten ? 1 : 0);
if (listener != null) {
if (!listener.evolveProgress(event)) {
break;
}
}
if (txn != null && nWritten >= WRITES_PER_TXN) {
cursor.close();
cursor = null;
txn.commit();
txn = null;
txn = env.beginTransaction(null, autoCommitTxnConfig);
cursor = db.openCursor(txn, cursorConfig);
DatabaseEntry saveKey = KeyRange.copy(key);
status = cursor.getSearchKeyRange(key, data, null);
if (status == OperationStatus.SUCCESS &&
KeyRange.equalBytes(key, saveKey)) {
status = cursor.getNext(key, data, null);