The "old" object is the one used in the following code from Hibernate source 2.0.3.
I mean it is an "already-existing-object-in-the-hibernate-local-repository (not cache)".
Code:
private Serializable doSave(Object object, Serializable id) throws HibernateException {
ClassPersister persister = getPersister(object);
Key key = null;
final boolean identityCol;
if (id==null) {
if ( persister.isIdentifierAssignedByInsert() ) {
identityCol=true;
}
else {
throw new AssertionFailure("null id");
}
}
else {
identityCol=false;
}
if ( log.isTraceEnabled() ) log.trace( "saving " + MessageHelper.infoString(persister, id) );
if (!identityCol) { // if the id is generated by the database, we assign the key later
key = new Key(id, persister);
Object old = getEntity(key);
if (old!= null) {
if ( getEntry(old).status==DELETED ) {
flush();
}
else {
throw new HibernateException(
"The generated identifier is already in use: " +
MessageHelper.infoString(persister, id)
);
}
}
persister.setIdentifier(object, id);
}