/* Close primary and secondary databases. */
closeClass(entityClass);
String clsName = entityClass.getName();
EntityMetadata entityMeta = checkEntityClass(clsName);
boolean autoCommit = false;
if (storeConfig.getTransactional() &&
txn == null &&
DbCompat.getThreadTransaction(env) == null) {
txn = env.beginTransaction(null, autoCommitTxnConfig);
autoCommit = true;
}
/*
* Truncate the primary first and let any exceptions propogate
* upwards. Then remove each secondary, only throwing the first
* exception.
*/
boolean success = false;
try {
boolean primaryExists =
truncateIfExists(txn, storePrefix + clsName);
if (primaryExists) {
DatabaseException firstException = null;
for (SecondaryKeyMetadata keyMeta :
entityMeta.getSecondaryKeys().values()) {
/* Ignore secondaries that do not exist. */
removeIfExists
(txn,
storePrefix +
makeSecName(clsName, keyMeta.getKeyName()));