HHH-6858 non-intrusive performance improvements

This commit is contained in:
Sanne Grinovero 2011-11-28 15:35:48 +00:00 committed by Strong Liu
parent 9e45ec3baf
commit fb0255a87a
5 changed files with 13 additions and 14 deletions

View File

@ -260,7 +260,6 @@ public class TransactionCoordinatorImpl implements TransactionCoordinator {
}
public void pulse() {
LOG.trace( "Starting transaction coordinator pulse" );
if ( transactionFactory().compatibleWithJtaSynchronization() ) {
// the configured transaction strategy says it supports callbacks via JTA synchronization, so attempt to
// register JTA synchronization if possible

View File

@ -45,7 +45,6 @@ import org.hibernate.engine.spi.EntityEntry;
import org.hibernate.engine.spi.PersistenceContext;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.Status;
import org.hibernate.event.service.spi.EventListenerGroup;
import org.hibernate.event.service.spi.EventListenerRegistry;
import org.hibernate.event.spi.EventSource;
import org.hibernate.event.spi.EventType;
@ -213,6 +212,12 @@ public abstract class AbstractFlushingEventListener implements Serializable {
// It is safe because of how IdentityMap implements entrySet()
final EventSource source = event.getSession();
final Iterable<FlushEntityEventListener> flushListeners = source
.getFactory()
.getServiceRegistry()
.getService( EventListenerRegistry.class )
.getEventListenerGroup( EventType.FLUSH_ENTITY )
.listeners();
final Map.Entry[] list = IdentityMap.concurrentEntries( source.getPersistenceContext().getEntityEntries() );
final int size = list.length;
@ -226,12 +231,7 @@ public abstract class AbstractFlushingEventListener implements Serializable {
if ( status != Status.LOADING && status != Status.GONE ) {
final FlushEntityEvent entityEvent = new FlushEntityEvent( source, me.getKey(), entry );
final EventListenerGroup<FlushEntityEventListener> listenerGroup = source
.getFactory()
.getServiceRegistry()
.getService( EventListenerRegistry.class )
.getEventListenerGroup( EventType.FLUSH_ENTITY );
for ( FlushEntityEventListener listener : listenerGroup.listeners() ) {
for ( FlushEntityEventListener listener : flushListeners ) {
listener.onFlushEntity( entityEvent );
}
}

View File

@ -77,7 +77,6 @@ import org.hibernate.UnknownProfileException;
import org.hibernate.UnresolvableObjectException;
import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.engine.internal.StatefulPersistenceContext;
import org.hibernate.engine.jdbc.LobCreationContext;
import org.hibernate.engine.jdbc.LobCreator;
import org.hibernate.engine.query.spi.FilterQueryPlan;
import org.hibernate.engine.query.spi.HQLQueryPlan;
@ -94,7 +93,6 @@ import org.hibernate.engine.spi.QueryParameters;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.Status;
import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl;
import org.hibernate.engine.transaction.spi.TransactionContext;
import org.hibernate.engine.transaction.spi.TransactionCoordinator;
import org.hibernate.engine.transaction.spi.TransactionImplementor;
import org.hibernate.event.service.spi.EventListenerGroup;
@ -1078,8 +1076,9 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc
if ( persistenceContext.getCascadeLevel() > 0 ) {
throw new HibernateException("Flush during cascade is dangerous");
}
FlushEvent flushEvent = new FlushEvent( this );
for ( FlushEventListener listener : listeners( EventType.FLUSH ) ) {
listener.onFlush( new FlushEvent( this ) );
listener.onFlush( flushEvent );
}
}

View File

@ -30,8 +30,8 @@ package org.hibernate.internal.util.compare;
*/
public final class EqualsHelper {
public static boolean equals(Object x, Object y) {
return x==y || ( x!=null && y!=null && x.equals(y) );
public static boolean equals(final Object x, final Object y) {
return x == y || ( x != null && y != null && x.equals( y ) );
}
private EqualsHelper() {}

View File

@ -459,6 +459,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
final Object[] propertyValues = virtualIdComponent.getPropertyValues( entity, entityMode );
final Type[] subTypes = virtualIdComponent.getSubtypes();
final Type[] copierSubTypes = mappedIdentifierType.getSubtypes();
final Iterable<PersistEventListener> persistEventListeners = persistEventListeners( session );
final int length = subTypes.length;
for ( int i = 0 ; i < length; i++ ) {
if ( propertyValues[i] == null ) {
@ -484,7 +485,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
else {
LOG.debug( "Performing implicit derived identity cascade" );
final PersistEvent event = new PersistEvent( null, propertyValues[i], (EventSource) session );
for ( PersistEventListener listener : persistEventListeners( session ) ) {
for ( PersistEventListener listener : persistEventListeners ) {
listener.onPersist( event );
}
pcEntry = session.getPersistenceContext().getEntry( propertyValues[i] );