public class DefaultFlushEntityEventListener implements FlushEntityEventListener {
private void checkVersion(EntityPersister persister, EntityEntry entry){
if(entry.getVersion() == null){
throw new HibernateException(
String.format("null version number in entity [%s] with identifier %s",
persister.getEntityName(), entry.getId()));
}
}
private Object getNextVersion(FlushEntityEvent event) throws HibernateException {
if(isVersionIncrementRequired && entry.getVersion() == null){
checkVersion(persister, entry);
}
final Object nextVersion = isVersionIncrementRequired ?
Versioning.increment( entry.getVersion(), persister.getVersionType(), event.getSession() ) :
entry.getVersion(); }
}