HHH-6862 Some additional small performance improvements
This commit is contained in:
parent
eb59e81bb9
commit
a6b761e209
|
@ -52,7 +52,6 @@ public class DefaultAutoFlushEventListener extends AbstractFlushingEventListener
|
||||||
public void onAutoFlush(AutoFlushEvent event) throws HibernateException {
|
public void onAutoFlush(AutoFlushEvent event) throws HibernateException {
|
||||||
final EventSource source = event.getSession();
|
final EventSource source = event.getSession();
|
||||||
if ( flushMightBeNeeded(source) ) {
|
if ( flushMightBeNeeded(source) ) {
|
||||||
final int oldSize = source.getActionQueue().numberOfCollectionRemovals();
|
|
||||||
flushEverythingToExecutions(event);
|
flushEverythingToExecutions(event);
|
||||||
if ( flushIsReallyNeeded(event, source) ) {
|
if ( flushIsReallyNeeded(event, source) ) {
|
||||||
LOG.trace( "Need to execute flush" );
|
LOG.trace( "Need to execute flush" );
|
||||||
|
@ -68,6 +67,7 @@ public class DefaultAutoFlushEventListener extends AbstractFlushingEventListener
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOG.trace( "Don't need to execute flush" );
|
LOG.trace( "Don't need to execute flush" );
|
||||||
|
final int oldSize = source.getActionQueue().numberOfCollectionRemovals();
|
||||||
source.getActionQueue().clearFromFlushNeededCheck( oldSize );
|
source.getActionQueue().clearFromFlushNeededCheck( oldSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
package org.hibernate.event.internal;
|
package org.hibernate.event.internal;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.engine.spi.PersistenceContext;
|
||||||
import org.hibernate.event.spi.EventSource;
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.event.spi.FlushEvent;
|
import org.hibernate.event.spi.FlushEvent;
|
||||||
import org.hibernate.event.spi.FlushEventListener;
|
import org.hibernate.event.spi.FlushEventListener;
|
||||||
|
@ -43,8 +44,9 @@ public class DefaultFlushEventListener extends AbstractFlushingEventListener imp
|
||||||
*/
|
*/
|
||||||
public void onFlush(FlushEvent event) throws HibernateException {
|
public void onFlush(FlushEvent event) throws HibernateException {
|
||||||
final EventSource source = event.getSession();
|
final EventSource source = event.getSession();
|
||||||
if ( source.getPersistenceContext().getEntityEntries().size() > 0 ||
|
final PersistenceContext persistenceContext = source.getPersistenceContext();
|
||||||
source.getPersistenceContext().getCollectionEntries().size() > 0 ) {
|
if ( persistenceContext.getEntityEntries().size() > 0 ||
|
||||||
|
persistenceContext.getCollectionEntries().size() > 0 ) {
|
||||||
|
|
||||||
flushEverythingToExecutions(event);
|
flushEverythingToExecutions(event);
|
||||||
performExecutions(source);
|
performExecutions(source);
|
||||||
|
|
|
@ -288,17 +288,19 @@ public class IndexBuilder {
|
||||||
|
|
||||||
//merge source into target
|
//merge source into target
|
||||||
private void mergeAnnotationMap(Map<DotName, List<AnnotationInstance>> source, Map<DotName, List<AnnotationInstance>> target) {
|
private void mergeAnnotationMap(Map<DotName, List<AnnotationInstance>> source, Map<DotName, List<AnnotationInstance>> target) {
|
||||||
if ( source != null && !source.isEmpty() ) {
|
if ( source != null ) {
|
||||||
for ( DotName annotationName : source.keySet() ) {
|
for ( Map.Entry<DotName, List<AnnotationInstance>> el : source.entrySet() ) {
|
||||||
if ( source.get( annotationName ).isEmpty() ) {
|
if ( el.getValue().isEmpty() ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
DotName annotationName = el.getKey();
|
||||||
|
List<AnnotationInstance> value = el.getValue();
|
||||||
List<AnnotationInstance> annotationInstanceList = target.get( annotationName );
|
List<AnnotationInstance> annotationInstanceList = target.get( annotationName );
|
||||||
if ( annotationInstanceList == null ) {
|
if ( annotationInstanceList == null ) {
|
||||||
annotationInstanceList = new ArrayList<AnnotationInstance>();
|
annotationInstanceList = new ArrayList<AnnotationInstance>();
|
||||||
target.put( annotationName, annotationInstanceList );
|
target.put( annotationName, annotationInstanceList );
|
||||||
}
|
}
|
||||||
annotationInstanceList.addAll( source.get( annotationName ) );
|
annotationInstanceList.addAll( value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue