#1842 - Refactor persisting to delay the setting of generated Id value (sequences and deferred imported ids)

This commit is contained in:
rob bygrave
2019-10-11 20:50:47 +13:00
parent 4807070147
commit 4cfab3a2de
3 changed files with 17 additions and 31 deletions
@@ -3107,6 +3107,18 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
return idType;
}
/**
* Set the generated Id value if appropriate.
*/
public void setGeneratedId(EntityBean entityBean, Transaction transaction) {
if (idGenerator == null || idProperty == null || idProperty.isEmbedded()) {
return;
}
if (isNullOrZero(idProperty.getValue(entityBean))) {
convertSetId(nextId(transaction), entityBean);
}
}
/**
* Return true if the Id value is marked as a <code>@GeneratedValue</code>.
*/