/** * Obtain the parameter metadata for given native-sql query. * <p/> * for native-sql queries, the param metadata is determined outside any relation to a query plan, because * query plan creation and/or retrieval for a native-sql query depends on all of the return types having been * set, which might not be the case up-front when param metadata would be most useful * * @param query The query * @return The parameter metadata */ public ParameterMetadata getSQLParameterMetadata(final String query, boolean isOrdinalParameterZeroBased) { final ParameterMetadataKey key = new ParameterMetadataKey( query, isOrdinalParameterZeroBased ); ParameterMetadataImpl value = parameterMetadataCache.get( key ); if ( value == null ) { value = nativeQueryInterpreter.getParameterMetadata( query ); parameterMetadataCache.putIfAbsent( key, value ); } return value; }
Map<String,Filter> enabledFilters) throws QueryException, MappingException { final FilterQueryPlanKey key = new FilterQueryPlanKey( filterString, collectionRole, shallow, enabledFilters ); FilterQueryPlan value = (FilterQueryPlan) queryPlanCache.get( key ); if ( value == null ) { LOG.tracev(
/** * 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; }
throws QueryException, MappingException { final HQLQueryPlanKey key = new HQLQueryPlanKey( queryString, shallow, enabledFilters ); HQLQueryPlan value = (HQLQueryPlan) queryPlanCache.get( key ); boolean stats = factory.getStatistics().isStatisticsEnabled();
@Override public SelectQueryPlan getSelectQueryPlan(Key key) { // todo (6.0) : Log and stats, see HHH-12855 return (SelectQueryPlan) queryPlanCache.get( key ); }
@Override public SqmStatement getSqmStatement(String queryString) { return (SqmStatement) sqmStatementCache.get( queryString ); }
protected String getMultiGetQueryCacheQuery(EntityKey[] keys) { int numberOfKeys = keys.length; String query = multiGetQueryCache.get( numberOfKeys ); if ( query == null ) { query = createMultiGetOnMultiplePropertiesId( numberOfKeys ); String cached = multiGetQueryCache.putIfAbsent( numberOfKeys, query ); if ( cached != null ) { query = cached; } } return query; }
private CacheEntry<HQLQueryPlan> getQueryPlan(SessionFactoryImplementor sfi, Query query, QueryPlanCacheKey cacheKey) { BoundedConcurrentHashMap<QueryPlanCacheKey, HQLQueryPlan> queryPlanCache = getQueryPlanCache(sfi); HQLQueryPlan queryPlan = queryPlanCache.get(cacheKey); boolean fromCache = true; if (queryPlan == null) { fromCache = false; queryPlan = createQueryPlan(sfi, query); } return new CacheEntry<HQLQueryPlan>(queryPlan, fromCache); }
shallow, enabledFilters); XQueryPlan plan = (XQueryPlan)this.queryPlanCache.get(key); if (plan == null) { if (log.isTraceEnabled()) {
private RemoteStatements getTableQuery(NextValueRequest request) { String key = key( request ); RemoteStatements statements = queryCache.get( key ); if ( statements == null ) { statements = new RemoteStatements(); getUpdateTableSequenceQuery( statements, request ); RemoteStatements cached = queryCache.putIfAbsent( key, statements ); if ( cached != null ) { statements = cached; } } return statements; }
/** * Ex.: * <pre> * MATCH (n:hibernate_sequences:TABLE_BASED_SEQUENCE) WHERE n.sequence_name = {sequenceName} RETURN n * </pre> */ private String getTableQuery(IdSourceKey idSourceKey) { String query = queryCache.get( idSourceKey.getTable() ); if ( query == null ) { query = "MATCH (n" + labels( idSourceKey.getTable(), NodeLabel.TABLE_BASED_SEQUENCE.name() ) + ") WHERE n." + idSourceKey.getMetadata().getKeyColumnName() + " = {" + SEQUENCE_NAME_QUERY_PARAM + "} RETURN n"; String cached = queryCache.putIfAbsent( idSourceKey.getTable(), query ); if ( cached != null ) { query = cached; } } return query; }