当前位置: 首页>>代码示例>>Java>>正文


Java EntityPersister.isVersionPropertyGenerated方法代码示例

本文整理汇总了Java中org.hibernate.persister.entity.EntityPersister.isVersionPropertyGenerated方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPersister.isVersionPropertyGenerated方法的具体用法?Java EntityPersister.isVersionPropertyGenerated怎么用?Java EntityPersister.isVersionPropertyGenerated使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.persister.entity.EntityPersister的用法示例。


在下文中一共展示了EntityPersister.isVersionPropertyGenerated方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
@Override
public void execute() throws HibernateException {
	final Serializable id = getId();
	final EntityPersister persister = getPersister();
	final SessionImplementor session = getSession();
	final Object instance = getInstance();

	final boolean veto = preDelete();

	Object version = this.version;
	if ( persister.isVersionPropertyGenerated() ) {
		// we need to grab the version value from the entity, otherwise
		// we have issues with generated-version entities that may have
		// multiple actions queued during the same flush
		version = persister.getVersion( instance );
	}

	final CacheKey ck;
	if ( persister.hasCache() ) {
		ck = session.generateCacheKey( id, persister.getIdentifierType(), persister.getRootEntityName() );
		lock = persister.getCacheAccessStrategy().lockItem( ck, version );
	}
	else {
		ck = null;
	}

	if ( !isCascadeDeleteEnabled && !veto ) {
		persister.delete( id, version, instance, session );
	}
	
	//postDelete:
	// After actually deleting a row, record the fact that the instance no longer 
	// exists on the database (needed for identity-column key generation), and
	// remove it from the session cache
	final PersistenceContext persistenceContext = session.getPersistenceContext();
	final EntityEntry entry = persistenceContext.removeEntry( instance );
	if ( entry == null ) {
		throw new AssertionFailure( "possible nonthreadsafe access to session" );
	}
	entry.postDelete();

	persistenceContext.removeEntity( entry.getEntityKey() );
	persistenceContext.removeProxy( entry.getEntityKey() );
	
	if ( persister.hasCache() ) {
		persister.getCacheAccessStrategy().remove( ck );
	}

	persistenceContext.getNaturalIdHelper().removeSharedNaturalIdCrossReference( persister, id, naturalIdValues );

	postDelete();

	if ( getSession().getFactory().getStatistics().isStatisticsEnabled() && !veto ) {
		getSession().getFactory().getStatisticsImplementor().deleteEntity( getPersister().getEntityName() );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:57,代码来源:EntityDeleteAction.java

示例2: execute

import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
@Override
public void execute() throws HibernateException {
	nullifyTransientReferencesIfNotAlready();

	final EntityPersister persister = getPersister();
	final SessionImplementor session = getSession();
	final Object instance = getInstance();
	final Serializable id = getId();

	final 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, getState(), instance, session );

		final EntityEntry entry = session.getPersistenceContext().getEntry( instance );
		if ( entry == null ) {
			throw new AssertionFailure( "possible non-threadsafe access to session" );
		}
		
		entry.postInsert( getState() );

		if ( persister.hasInsertGeneratedProperties() ) {
			persister.processInsertGeneratedProperties( id, instance, getState(), session );
			if ( persister.isVersionPropertyGenerated() ) {
				version = Versioning.getVersion( getState(), persister );
			}
			entry.postUpdate( instance, getState(), version );
		}

		getSession().getPersistenceContext().registerInsertedKey( getPersister(), getId() );
	}

	final SessionFactoryImplementor factory = getSession().getFactory();

	if ( isCachePutEnabled( persister, session ) ) {
		final CacheEntry ce = persister.buildCacheEntry(
				instance,
				getState(),
				version,
				session
		);
		cacheEntry = persister.getCacheEntryStructure().structure( ce );
		final CacheKey ck = session.generateCacheKey( id, persister.getIdentifierType(), persister.getRootEntityName() );

		final boolean put = cacheInsert( persister, ck );

		if ( put && factory.getStatistics().isStatisticsEnabled() ) {
			factory.getStatisticsImplementor().secondLevelCachePut( getPersister().getCacheAccessStrategy().getRegion().getName() );
		}
	}

	handleNaturalIdPostSaveNotifications( id );

	postInsert();

	if ( factory.getStatistics().isStatisticsEnabled() && !veto ) {
		factory.getStatisticsImplementor().insertEntity( getPersister().getEntityName() );
	}

	markExecuted();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:66,代码来源:EntityInsertAction.java


注:本文中的org.hibernate.persister.entity.EntityPersister.isVersionPropertyGenerated方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。