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


Java EntityPersister.afterReassociate方法代码示例

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


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

示例1: performUpdate

import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
protected void performUpdate(
		SaveOrUpdateEvent event,
		Object entity,
		EntityPersister persister) throws HibernateException {

	final boolean traceEnabled = LOG.isTraceEnabled();
	if ( traceEnabled && !persister.isMutable() ) {
		LOG.trace( "Immutable instance passed to performUpdate()" );
	}

	if ( traceEnabled ) {
		LOG.tracev(
				"Updating {0}",
				MessageHelper.infoString( persister, event.getRequestedId(), event.getSession().getFactory() )
		);
	}

	final EventSource source = event.getSession();
	final EntityKey key = source.generateEntityKey( event.getRequestedId(), persister );

	source.getPersistenceContext().checkUniqueness( key, entity );

	if ( invokeUpdateLifecycle( entity, persister, source ) ) {
		reassociate( event, event.getObject(), event.getRequestedId(), persister );
		return;
	}

	// this is a transient object with existing persistent state not loaded by the session

	new OnUpdateVisitor( source, event.getRequestedId(), entity ).process( entity, persister );

	// TODO: put this stuff back in to read snapshot from
	// the second-level cache (needs some extra work)
	/*Object[] cachedState = null;

       if ( persister.hasCache() ) {
       	CacheEntry entry = (CacheEntry) persister.getCache()
       			.get( event.getRequestedId(), source.getTimestamp() );
           cachedState = entry==null ?
           		null :
           		entry.getState(); //TODO: half-assemble this stuff
       }*/

	source.getPersistenceContext().addEntity(
			entity,
			( persister.isMutable() ? Status.MANAGED : Status.READ_ONLY ),
			null, // cachedState,
			key,
			persister.getVersion( entity ),
			LockMode.NONE,
			true,
			persister,
			false,
			true // assume true, since we don't really know, and it doesn't matter
	);

	persister.afterReassociate( entity, source );

	if ( traceEnabled ) {
		LOG.tracev(
				"Updating {0}", MessageHelper.infoString(
				persister,
				event.getRequestedId(),
				source.getFactory()
		)
		);
	}

	cascadeOnUpdate( event, persister, entity );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:71,代码来源:DefaultSaveOrUpdateEventListener.java

示例2: reassociate

import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
/**
 * Associates a given entity (either transient or associated with another session) to
 * the given session.
 *
 * @param event The event triggering the re-association
 * @param object The entity to be associated
 * @param id The id of the entity.
 * @param persister The entity's persister instance.
 *
 * @return An EntityEntry representing the entity within this session.
 */
protected final EntityEntry reassociate(AbstractEvent event, Object object, Serializable id, EntityPersister persister) {

	if ( log.isTraceEnabled() ) {
		log.tracev(
				"Reassociating transient instance: {0}",
				MessageHelper.infoString( persister, id, event.getSession().getFactory() )
		);
	}

	final EventSource source = event.getSession();
	final EntityKey key = source.generateEntityKey( id, persister );

	source.getPersistenceContext().checkUniqueness( key, object );

	//get a snapshot
	Object[] values = persister.getPropertyValues( object );
	TypeHelper.deepCopy(
			values,
			persister.getPropertyTypes(),
			persister.getPropertyUpdateability(),
			values,
			source
	);
	Object version = Versioning.getVersion( values, persister );

	EntityEntry newEntry = source.getPersistenceContext().addEntity(
			object,
			( persister.isMutable() ? Status.MANAGED : Status.READ_ONLY ),
			values,
			key,
			version,
			LockMode.NONE,
			true,
			persister,
			false,
			true //will be ignored, using the existing Entry instead
	);

	new OnLockVisitor( source, id, object ).process( object, persister );

	persister.afterReassociate( object, source );

	return newEntry;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:57,代码来源:AbstractReassociateEventListener.java


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