本文整理汇总了Java中org.hibernate.event.spi.PersistEventListener类的典型用法代码示例。如果您正苦于以下问题:Java PersistEventListener类的具体用法?Java PersistEventListener怎么用?Java PersistEventListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PersistEventListener类属于org.hibernate.event.spi包,在下文中一共展示了PersistEventListener类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: persistEventListeners
import org.hibernate.event.spi.PersistEventListener; //导入依赖的package包/类
private static Iterable<PersistEventListener> persistEventListeners(SessionImplementor session) {
return session
.getFactory()
.getServiceRegistry()
.getService( EventListenerRegistry.class )
.getEventListenerGroup( EventType.PERSIST )
.listeners();
}
示例2: 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();
}
示例3: 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();
}
示例4: 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;
}