HHH-9344 Guard against unneeded invocation to System.currentTimeMillis() in HQLQueryPlan
This commit is contained in:
parent
67c86aaaf8
commit
ec0c205578
|
@ -75,6 +75,11 @@ public class HQLQueryPlan implements Serializable {
|
||||||
private final Set<String> enabledFilterNames;
|
private final Set<String> enabledFilterNames;
|
||||||
private final boolean shallow;
|
private final boolean shallow;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We'll check the trace level only once per instance
|
||||||
|
*/
|
||||||
|
private final boolean TRACE_ENABLED = LOG.isTraceEnabled();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a HQLQueryPlan
|
* Constructs a HQLQueryPlan
|
||||||
*
|
*
|
||||||
|
@ -200,7 +205,7 @@ public class HQLQueryPlan implements Serializable {
|
||||||
public List performList(
|
public List performList(
|
||||||
QueryParameters queryParameters,
|
QueryParameters queryParameters,
|
||||||
SessionImplementor session) throws HibernateException {
|
SessionImplementor session) throws HibernateException {
|
||||||
if ( LOG.isTraceEnabled() ) {
|
if ( TRACE_ENABLED ) {
|
||||||
LOG.tracev( "Find: {0}", getSourceQuery() );
|
LOG.tracev( "Find: {0}", getSourceQuery() );
|
||||||
queryParameters.traceParameters( session.getFactory() );
|
queryParameters.traceParameters( session.getFactory() );
|
||||||
}
|
}
|
||||||
|
@ -298,7 +303,7 @@ public class HQLQueryPlan implements Serializable {
|
||||||
public Iterator performIterate(
|
public Iterator performIterate(
|
||||||
QueryParameters queryParameters,
|
QueryParameters queryParameters,
|
||||||
EventSource session) throws HibernateException {
|
EventSource session) throws HibernateException {
|
||||||
if ( LOG.isTraceEnabled() ) {
|
if ( TRACE_ENABLED ) {
|
||||||
LOG.tracev( "Iterate: {0}", getSourceQuery() );
|
LOG.tracev( "Iterate: {0}", getSourceQuery() );
|
||||||
queryParameters.traceParameters( session.getFactory() );
|
queryParameters.traceParameters( session.getFactory() );
|
||||||
}
|
}
|
||||||
|
@ -336,7 +341,7 @@ public class HQLQueryPlan implements Serializable {
|
||||||
public ScrollableResults performScroll(
|
public ScrollableResults performScroll(
|
||||||
QueryParameters queryParameters,
|
QueryParameters queryParameters,
|
||||||
SessionImplementor session) throws HibernateException {
|
SessionImplementor session) throws HibernateException {
|
||||||
if ( LOG.isTraceEnabled() ) {
|
if ( TRACE_ENABLED ) {
|
||||||
LOG.tracev( "Iterate: {0}", getSourceQuery() );
|
LOG.tracev( "Iterate: {0}", getSourceQuery() );
|
||||||
queryParameters.traceParameters( session.getFactory() );
|
queryParameters.traceParameters( session.getFactory() );
|
||||||
}
|
}
|
||||||
|
@ -362,7 +367,7 @@ public class HQLQueryPlan implements Serializable {
|
||||||
*/
|
*/
|
||||||
public int performExecuteUpdate(QueryParameters queryParameters, SessionImplementor session)
|
public int performExecuteUpdate(QueryParameters queryParameters, SessionImplementor session)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
if ( LOG.isTraceEnabled() ) {
|
if ( TRACE_ENABLED ) {
|
||||||
LOG.tracev( "Execute update: {0}", getSourceQuery() );
|
LOG.tracev( "Execute update: {0}", getSourceQuery() );
|
||||||
queryParameters.traceParameters( session.getFactory() );
|
queryParameters.traceParameters( session.getFactory() );
|
||||||
}
|
}
|
||||||
|
@ -377,12 +382,12 @@ public class HQLQueryPlan implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ParameterMetadata buildParameterMetadata(ParameterTranslations parameterTranslations, String hql) {
|
private ParameterMetadata buildParameterMetadata(ParameterTranslations parameterTranslations, String hql) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = TRACE_ENABLED ? System.nanoTime() : 0;
|
||||||
final ParamLocationRecognizer recognizer = ParamLocationRecognizer.parseLocations( hql );
|
final ParamLocationRecognizer recognizer = ParamLocationRecognizer.parseLocations( hql );
|
||||||
final long end = System.currentTimeMillis();
|
|
||||||
|
|
||||||
if ( LOG.isTraceEnabled() ) {
|
if ( TRACE_ENABLED ) {
|
||||||
LOG.tracev( "HQL param location recognition took {0} mills ({1})", ( end - start ), hql );
|
final long end = System.nanoTime();
|
||||||
|
LOG.tracev( "HQL param location recognition took {0} nanoseconds ({1})", ( end - start ), hql );
|
||||||
}
|
}
|
||||||
|
|
||||||
int ordinalParamCount = parameterTranslations.getOrdinalParameterCount();
|
int ordinalParamCount = parameterTranslations.getOrdinalParameterCount();
|
||||||
|
|
Loading…
Reference in New Issue