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


Java EventSource.getPersistenceContext方法代码示例

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


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

示例1: logFlushResults

import org.hibernate.event.spi.EventSource; //导入方法依赖的package包/类
@SuppressWarnings( value = {"unchecked"} )
private void logFlushResults(FlushEvent event) {
	if ( !LOG.isDebugEnabled() ) {
		return;
	}
	final EventSource session = event.getSession();
	final PersistenceContext persistenceContext = session.getPersistenceContext();
	LOG.debugf(
			"Flushed: %s insertions, %s updates, %s deletions to %s objects",
			session.getActionQueue().numberOfInsertions(),
			session.getActionQueue().numberOfUpdates(),
			session.getActionQueue().numberOfDeletions(),
			persistenceContext.getNumberOfManagedEntities()
	);
	LOG.debugf(
			"Flushed: %s (re)creations, %s updates, %s removals to %s collections",
			session.getActionQueue().numberOfCollectionCreations(),
			session.getActionQueue().numberOfCollectionUpdates(),
			session.getActionQueue().numberOfCollectionRemovals(),
			persistenceContext.getCollectionEntries().size()
	);
	new EntityPrinter( session.getFactory() ).toString(
			persistenceContext.getEntitiesByKey().entrySet()
	);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:AbstractFlushingEventListener.java

示例2: onFlush

import org.hibernate.event.spi.EventSource; //导入方法依赖的package包/类
/** Handle the given flush event.
 *
 * @param event The flush event to be handled.
 * @throws HibernateException
 */
public void onFlush(FlushEvent event) throws HibernateException {
	final EventSource source = event.getSession();
	final PersistenceContext persistenceContext = source.getPersistenceContext();

	if ( persistenceContext.getNumberOfManagedEntities() > 0 ||
			persistenceContext.getCollectionEntries().size() > 0 ) {

		try {
			source.getEventListenerManager().flushStart();

			flushEverythingToExecutions( event );
			performExecutions( source );
			postFlush( source );
		}
		finally {
			source.getEventListenerManager().flushEnd(
					event.getNumberOfEntitiesProcessed(),
					event.getNumberOfCollectionsProcessed()
			);
		}

		postPostFlush( source );

		if ( source.getFactory().getStatistics().isStatisticsEnabled() ) {
			source.getFactory().getStatisticsImplementor().flush();
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:DefaultFlushEventListener.java

示例3: flushEverythingToExecutions

import org.hibernate.event.spi.EventSource; //导入方法依赖的package包/类
/**
 * Coordinates the processing necessary to get things ready for executions
 * as db calls by preping the session caches and moving the appropriate
 * entities and collections to their respective execution queues.
 *
 * @param event The flush event.
 * @throws HibernateException Error flushing caches to execution queues.
 */
protected void flushEverythingToExecutions(FlushEvent event) throws HibernateException {

	LOG.trace( "Flushing session" );

	EventSource session = event.getSession();

	final PersistenceContext persistenceContext = session.getPersistenceContext();
	session.getInterceptor().preFlush( new LazyIterator( persistenceContext.getEntitiesByKey() ) );

	prepareEntityFlushes( session, persistenceContext );
	// we could move this inside if we wanted to
	// tolerate collection initializations during
	// collection dirty checking:
	prepareCollectionFlushes( persistenceContext );
	// now, any collections that are initialized
	// inside this block do not get updated - they
	// are ignored until the next flush

	persistenceContext.setFlushing( true );
	try {
		int entityCount = flushEntities( event, persistenceContext );
		int collectionCount = flushCollections( session, persistenceContext );

		event.setNumberOfEntitiesProcessed( entityCount );
		event.setNumberOfCollectionsProcessed( collectionCount );
	}
	finally {
		persistenceContext.setFlushing(false);
	}

	//some statistics
	logFlushResults( event );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:42,代码来源:AbstractFlushingEventListener.java


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