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


Java PersistEventListener.onPersist方法代码示例

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


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

示例1: firePersist

import org.hibernate.event.spi.PersistEventListener; //导入方法依赖的package包/类
private void firePersist(Map copiedAlready, PersistEvent event) {
	errorIfClosed();
	checkTransactionSynchStatus();
	for ( PersistEventListener listener : listeners( EventType.PERSIST ) ) {
		listener.onPersist( event, copiedAlready );
	}
	delayedAfterCompletion();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:SessionImpl.java

示例2: firePersistOnFlush

import org.hibernate.event.spi.PersistEventListener; //导入方法依赖的package包/类
private void firePersistOnFlush(Map copiedAlready, PersistEvent event) {
	errorIfClosed();
	checkTransactionSynchStatus();
	for ( PersistEventListener listener : listeners( EventType.PERSIST_ONFLUSH ) ) {
		listener.onPersist( event, copiedAlready );
	}
	delayedAfterCompletion();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:SessionImpl.java

示例3: getIdentifier

import org.hibernate.event.spi.PersistEventListener; //导入方法依赖的package包/类
@Override
public Object getIdentifier(Object entity, EntityMode entityMode, SessionImplementor session) {
	final Object id = mappedIdentifierType.instantiate( entityMode );
	final Object[] propertyValues = virtualIdComponent.getPropertyValues( entity, entityMode );
	final Type[] subTypes = virtualIdComponent.getSubtypes();
	final Type[] copierSubTypes = mappedIdentifierType.getSubtypes();
	final Iterable<PersistEventListener> persistEventListeners = persistEventListeners( session );
	final PersistenceContext persistenceContext = session.getPersistenceContext();
	final int length = subTypes.length;
	for ( int i = 0 ; i < length; i++ ) {
		if ( propertyValues[i] == null ) {
			throw new HibernateException( "No part of a composite identifier may be null" );
		}
		//JPA 2 @MapsId + @IdClass points to the pk of the entity
		if ( subTypes[i].isAssociationType() && ! copierSubTypes[i].isAssociationType() ) {
			// we need a session to handle this use case
			if ( session == null ) {
				throw new AssertionError(
						"Deprecated version of getIdentifier (no session) was used but session was required"
				);
			}
			final Object subId;
			if ( HibernateProxy.class.isInstance( propertyValues[i] ) ) {
				subId = ( (HibernateProxy) propertyValues[i] ).getHibernateLazyInitializer().getIdentifier();
			}
			else {
				EntityEntry pcEntry = session.getPersistenceContext().getEntry( propertyValues[i] );
				if ( pcEntry != null ) {
					subId = pcEntry.getId();
				}
				else {
					LOG.debug( "Performing implicit derived identity cascade" );
					final PersistEvent event = new PersistEvent( null, propertyValues[i], (EventSource) session );
					for ( PersistEventListener listener : persistEventListeners ) {
						listener.onPersist( event );
					}
					pcEntry = persistenceContext.getEntry( propertyValues[i] );
					if ( pcEntry == null || pcEntry.getId() == null ) {
						throw new HibernateException( "Unable to process implicit derived identity cascade" );
					}
					else {
						subId = pcEntry.getId();
					}
				}
			}
			propertyValues[i] = subId;
		}
	}
	mappedIdentifierType.setPropertyValues( id, propertyValues, entityMode );
	return id;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:52,代码来源:AbstractEntityTuplizer.java


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