// set id, in case of auto generation and still not set.
if (ObjectGraphUtils.onAutoGenerateId((Field) entityMetadata.getIdAttribute().getJavaMember(), id))
{
id = new IdGenerator().generateAndSetId(entity, entityMetadata, delegator, delegator.getKunderaMetadata());
}
// check if id is set or not.
new PrimaryKeyNullCheck<Object>().validate(id);