// add a new entry for this object and use this object as the view
oid = new OID( engine, molder, depended, identity );
entry = getObjectEntry( engine, oid );
if ( identity != null && entry != null ) {
if ( ! entry.deleted || entry.object != object )
throw new DuplicateIdentityException( Messages.format( "persist.duplicateIdentity", object.getClass().getName(), identity ) );
else {
// If the object was already deleted in this transaction,
// just undelete it.
// Remove the entry from a FIFO linked list of deleted entries.
if ( _deletedList != null ) {
ObjectEntry deleted;
if ( _deletedList == entry )
_deletedList = entry.nextDeleted;
else {
deleted = _deletedList;
while ( deleted.nextDeleted != null && deleted.nextDeleted != entry )
deleted = deleted.nextDeleted;
if ( deleted.nextDeleted == entry )
deleted.nextDeleted = entry.nextDeleted;
else
throw new PersistenceException( Messages.format("persist.deletedNotFound", identity) );
}
}
}
}
try {
entry = addObjectEntry( oid, object );
entry.creating = true;
if ( _callback != null ) {
_callback.creating( entry.object, _db );
} else if ( entry.molder.getCallback() != null ) {
entry.molder.getCallback().creating( entry.object, _db );
}
engine.markCreate( this, oid, object );
} catch ( LockNotGrantedException lneg ) {
// yip: do we need LockNotGrantedException, or should we
// removed them?
removeObjectEntry( object );
throw new DuplicateIdentityException("");
} catch ( PersistenceException pe ) {
removeObjectEntry( object );
throw pe;
} catch ( Exception e ) {
removeObjectEntry( object );