/** * Get the query plan for a native SQL query, creating it and caching it if not already cached * * @param spec The native SQL query specification * * @return The query plan * * @throws QueryException Indicates a problem translating the query * @throws MappingException Indicates a problem translating the query */ @SuppressWarnings("unchecked") public NativeSQLQueryPlan getNativeSQLQueryPlan(final NativeSQLQuerySpecification spec) { NativeSQLQueryPlan value = (NativeSQLQueryPlan) queryPlanCache.get( spec ); if ( value == null ) { LOG.tracev( "Unable to locate native-sql query plan in cache; generating ({0})", spec.getQueryString() ); value = nativeQueryInterpreter.createQueryPlan( spec, factory ); queryPlanCache.putIfAbsent( spec, value ); } else { LOG.tracev( "Located native-sql query plan in cache ({0})", spec.getQueryString() ); } return value; }