* This allows for an object's id to be assigned before commit.
* It can be used if the application requires to use the object id before the object exists on the database.
* Normally all ids are assigned during the commit automatically.
*/
protected void assignSequenceNumbers(Map objects) throws DatabaseException {
Sequencing sequencing = getSequencing();
if (sequencing == null) {
return;
}
int whenShouldAcquireValueForAll = sequencing.whenShouldAcquireValueForAll();
if (whenShouldAcquireValueForAll == Sequencing.AFTER_INSERT) {
return;
}
boolean shouldAcquireValueBeforeInsertForAll = whenShouldAcquireValueForAll == Sequencing.BEFORE_INSERT;
startOperationProfile(SessionProfiler.AssignSequence);
Iterator newObjects = objects.keySet().iterator();
while (newObjects.hasNext()) {
Object object = newObjects.next();
ClassDescriptor descriptor = getDescriptor(object);
if (descriptor.usesSequenceNumbers() && ((!isObjectRegistered(object)) || isCloneNewObject(object)) && (shouldAcquireValueBeforeInsertForAll || !sequencing.shouldAcquireValueAfterInsert(object.getClass()))) {
descriptor.getObjectBuilder().assignSequenceNumber(object, this);
}
}
endOperationProfile(SessionProfiler.AssignSequence);
}