HHH-9344 Convert DefaultResolveNaturalIdEventListener to use nanoTime instead of currentTimeMillis
This commit is contained in:
parent
c69f0e602c
commit
9f62b231ae
|
@ -24,6 +24,7 @@
|
||||||
package org.hibernate.event.internal;
|
package org.hibernate.event.internal;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy;
|
import org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy;
|
||||||
|
@ -117,7 +118,7 @@ public class DefaultResolveNaturalIdEventListener
|
||||||
final boolean stats = factory.getStatistics().isStatisticsEnabled();
|
final boolean stats = factory.getStatistics().isStatisticsEnabled();
|
||||||
long startTime = 0;
|
long startTime = 0;
|
||||||
if ( stats ) {
|
if ( stats ) {
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.nanoTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Serializable pk = event.getEntityPersister().loadEntityIdByNaturalId(
|
final Serializable pk = event.getEntityPersister().loadEntityIdByNaturalId(
|
||||||
|
@ -129,10 +130,11 @@ public class DefaultResolveNaturalIdEventListener
|
||||||
if ( stats ) {
|
if ( stats ) {
|
||||||
final NaturalIdRegionAccessStrategy naturalIdCacheAccessStrategy = event.getEntityPersister().getNaturalIdCacheAccessStrategy();
|
final NaturalIdRegionAccessStrategy naturalIdCacheAccessStrategy = event.getEntityPersister().getNaturalIdCacheAccessStrategy();
|
||||||
final String regionName = naturalIdCacheAccessStrategy == null ? null : naturalIdCacheAccessStrategy.getRegion().getName();
|
final String regionName = naturalIdCacheAccessStrategy == null ? null : naturalIdCacheAccessStrategy.getRegion().getName();
|
||||||
|
final long endTime = System.nanoTime();
|
||||||
|
final long milliseconds = TimeUnit.MILLISECONDS.convert( endTime - startTime, TimeUnit.NANOSECONDS );
|
||||||
factory.getStatisticsImplementor().naturalIdQueryExecuted(
|
factory.getStatisticsImplementor().naturalIdQueryExecuted(
|
||||||
regionName,
|
regionName,
|
||||||
System.currentTimeMillis() - startTime );
|
milliseconds );
|
||||||
}
|
}
|
||||||
|
|
||||||
//PK can be null if the entity doesn't exist
|
//PK can be null if the entity doesn't exist
|
||||||
|
|
Loading…
Reference in New Issue