/** * 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; }
); value = new FilterQueryPlan( filterString, collectionRole, shallow, enabledFilters,factory ); queryPlanCache.putIfAbsent( key, value );
queryPlanCache.putIfAbsent( key, value );
/** * 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; }
@Override public void cacheSelectQueryPlan(Key key, SelectQueryPlan plan) { // todo (6.0) : LOG, see HHH-12855 queryPlanCache.putIfAbsent( key, plan ); }
@Override public void cacheSqmStatement(String key, SqmStatement sqmStatement) { // todo (6.0) : Log and stats, see HHH-12855 sqmStatementCache.putIfAbsent( key, sqmStatement ); }
private HQLQueryPlan putQueryPlanIfAbsent(SessionFactoryImplementor sfi, QueryPlanCacheKey cacheKey, HQLQueryPlan queryPlan) { BoundedConcurrentHashMap<QueryPlanCacheKey, HQLQueryPlan> queryPlanCache = getQueryPlanCache(sfi); HQLQueryPlan oldQueryPlan = queryPlanCache.putIfAbsent(cacheKey, queryPlan); if (oldQueryPlan != null) { queryPlan = oldQueryPlan; } return queryPlan; }
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 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; }