return state;
}
public void execute() throws HibernateException {
EntityPersister persister = getPersister();
SessionImplementor session = getSession();
Object instance = getInstance();
Serializable id = getId();
boolean veto = preInsert();
// Don't need to lock the cache here, since if someone
// else inserted the same pk first, the insert would fail
if ( !veto ) {
persister.insert( id, state, instance, session );
EntityEntry entry = session.getPersistenceContext().getEntry( instance );
if ( entry == null ) {
throw new AssertionFailure( "possible nonthreadsafe access to session" );
}
entry.postInsert();
if ( persister.hasInsertGeneratedProperties() ) {
persister.processInsertGeneratedProperties( id, instance, state, session );
if ( persister.isVersionPropertyGenerated() ) {
version = Versioning.getVersion(state, persister);
}
entry.postUpdate(instance, state, version);
}
}
final SessionFactoryImplementor factory = getSession().getFactory();
if ( isCachePutEnabled( persister, session ) ) {
CacheEntry ce = new CacheEntry(
state,
persister,
persister.hasUninitializedLazyProperties( instance, session.getEntityMode() ),
version,
session,
instance
);
cacheEntry = persister.getCacheEntryStructure().structure(ce);
final CacheKey ck = new CacheKey(
id,
persister.getIdentifierType(),
persister.getRootEntityName(),
session.getEntityMode(),
session.getFactory()
);
// boolean put = persister.getCache().insert(ck, cacheEntry);
boolean put = persister.getCacheAccessStrategy().insert( ck, cacheEntry, version );
if ( put && factory.getStatistics().isStatisticsEnabled() ) {