final Map<OIdentifiable, Change> newChangedValues = new HashMap<OIdentifiable, Change>();
for (Map.Entry<OIdentifiable, Change> entry : changes.entrySet()) {
OIdentifiable identifiable = entry.getKey();
if (identifiable instanceof ORecord) {
ORID identity = identifiable.getIdentity();
ORecord record = (ORecord) identifiable;
if (identity.isNew() || record.isDirty()) {
record.save();
identity = record.getIdentity();
}
newChangedValues.put(identity, entry.getValue());
} else
newChangedValues.put(entry.getKey().getIdentity(), entry.getValue());
}
for (Map.Entry<OIdentifiable, Change> entry : newChangedValues.entrySet()) {
if (entry.getKey() instanceof ORecord) {
ORecord record = (ORecord) entry.getKey();
record.save();
newChangedValues.put(record, entry.getValue());
} else
return false;
}