Skip to content

Commit

Permalink
HHH-5927 remove logging guard and correct javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
stliu committed Mar 6, 2012
1 parent b465917 commit 94e7994
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
Expand Up @@ -47,16 +47,15 @@
/**
* Acts as a cache for compiled query plans, as well as query-parameter metadata.
*
* @see Environment#QUERY_PLAN_CACHE_MAX_STRONG_REFERENCES
* @see Environment#QUERY_PLAN_CACHE_MAX_SOFT_REFERENCES
* @see Environment#QUERY_PLAN_CACHE_PARAMETER_METADATA_MAX_SIZE
* @see Environment#QUERY_PLAN_CACHE_MAX_SIZE
*
* @author Steve Ebersole
*/
public class QueryPlanCache implements Serializable {

private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, QueryPlanCache.class.getName());

private static final boolean isTraceEnabled = LOG.isTraceEnabled();
/**
* The default strong reference count.
*/
Expand Down Expand Up @@ -164,11 +163,11 @@ public HQLQueryPlan getHQLQueryPlan( String queryString, boolean shallow, Map en
HQLQueryPlanKey key = new HQLQueryPlanKey( queryString, shallow, enabledFilters );
HQLQueryPlan value = (HQLQueryPlan) queryPlanCache.get( key );
if ( value == null ) {
if( isTraceEnabled ) LOG.tracev( "Unable to locate HQL query plan in cache; generating ({0})", queryString );
LOG.tracev( "Unable to locate HQL query plan in cache; generating ({0})", queryString );
value = new HQLQueryPlan( queryString, shallow, enabledFilters, factory );
queryPlanCache.putIfAbsent( key, value );
} else {
if( isTraceEnabled ) LOG.tracev( "Located HQL query plan in cache ({0})", queryString );
LOG.tracev( "Located HQL query plan in cache ({0})", queryString );
}
return value;
}
Expand All @@ -180,34 +179,32 @@ public FilterQueryPlan getFilterQueryPlan(String filterString, String collection
FilterQueryPlanKey key = new FilterQueryPlanKey( filterString, collectionRole, shallow, enabledFilters );
FilterQueryPlan value = (FilterQueryPlan) queryPlanCache.get( key );
if(value == null){
if( isTraceEnabled ) LOG.tracev( "Unable to locate collection-filter query plan in cache; generating ({0} : {1} )",
LOG.tracev( "Unable to locate collection-filter query plan in cache; generating ({0} : {1} )",
collectionRole, filterString );
value = new FilterQueryPlan( filterString, collectionRole, shallow, enabledFilters,factory );
queryPlanCache.putIfAbsent( key, value );
} else {
if( isTraceEnabled ) LOG.tracev( "Located collection-filter query plan in cache ({0} : {1})", collectionRole, filterString );
LOG.tracev( "Located collection-filter query plan in cache ({0} : {1})", collectionRole, filterString );
}
return value;
}

public NativeSQLQueryPlan getNativeSQLQueryPlan(final NativeSQLQuerySpecification spec) {
NativeSQLQueryPlan value = (NativeSQLQueryPlan) queryPlanCache.get( spec );
if(value == null){
if( isTraceEnabled ) LOG.tracev( "Unable to locate native-sql query plan in cache; generating ({0})", spec.getQueryString() );
LOG.tracev( "Unable to locate native-sql query plan in cache; generating ({0})", spec.getQueryString() );
value = new NativeSQLQueryPlan( spec, factory);
queryPlanCache.putIfAbsent( spec, value );
} else {
if( isTraceEnabled ) LOG.tracev( "Located native-sql query plan in cache ({0})", spec.getQueryString() );
LOG.tracev( "Located native-sql query plan in cache ({0})", spec.getQueryString() );
}
return value;
}


//clean up QueryPlanCache when Sessionfactory is closed
public void cleanup() {
if ( isTraceEnabled ) {
LOG.trace( "Cleaning QueryPlan Cache" );
}
LOG.trace( "Cleaning QueryPlan Cache" );
queryPlanCache.clear();
parameterMetadataCache.clear();
}
Expand Down
Expand Up @@ -90,14 +90,15 @@
* <em>optional</em> methods of the {@link Map} and {@link Iterator}
* interfaces.
*
* <p>This class is copied from Infinispan, and was originally written
* by Doug Lea with assistance from members of JCP JSR-166 Expert Group and
* released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain</p>
*
*
* <p> Like {@link Hashtable} but unlike {@link HashMap}, this class
* does <em>not</em> allow <tt>null</tt> to be used as a key or value.
*
* <p>This class is a member of the
* <a href="{@docRoot}/../technotes/guides/collections/index.html">
* Java Collections Framework</a>.
*
* @since 1.5
* @author Doug Lea
* @param <K> the type of keys maintained by this map
* @param <V> the type of mapped values
Expand Down

0 comments on commit 94e7994

Please sign in to comment.