/** * ADVANCED: * Set the max size of the expression query cache for avoiding regenerated dynamic query SQL. */ public void setExpressionQueryCacheMaxSize(int maxSize) { this.cachedExpressionQueries = new ConcurrentFixedCache(maxSize); }
/** * INTERNAL: * Return the cached update SQL call based on the updated fields. * PERF: Allow caching of the update SQL call to avoid regeneration. */ public Vector getCachedUpdateCalls(Vector updateFields) { return (Vector) this.cachedUpdateCalls.get(updateFields); }
/** * ADVANCED: * Return the max size of the expression query cache for avoiding regenerated dynamic query SQL. */ public int getExpressionQueryCacheMaxSize() { return cachedExpressionQueries.getMaxSize(); }
/** * Populate the query using the information retrieved from parsing the JPQL. */ public void populateQuery(String jpqlString, ObjectLevelReadQuery query, AbstractSession session) { // PERF: Check if the JPQL has already been parsed. // Only allow queries with default properties to be parse cached. boolean isCacheable = query.isDefaultPropertiesQuery(); DatabaseQuery cachedQuery = null; if (isCacheable) { cachedQuery = (DatabaseQuery)session.getProject().getJPQLParseCache().get(jpqlString); } if ((cachedQuery == null) || (!cachedQuery.isPrepared()) || (cachedQuery.getClass() != query.getClass())) { JPQLParser parser = parseEJBQLString(jpqlString); JPQLParseTree parseTree = parser.getParseTree(); parseTree.populateQuery(query, session); if (isCacheable) { session.getProject().getJPQLParseCache().put(jpqlString, query); } } else { query.prepareFromQuery(cachedQuery); query.setIsPrepared(true); } }
/** * INTERNAL: * Set the cached SQL call for the expression query. * PERF: Allow caching of expression query SQL call to avoid regeneration. */ public void putCachedExpressionQuery(DatabaseQuery query) { this.cachedExpressionQueries.put(query, query); } }
/** * ADVANCED: * Set the size of the update call cache. * The update call cache is used to cache the update SQL to avoid regeneration. * Since every update with different fields produces different SQL, * this cache allows caching of the update SQL based on the fields being updated. * The default cache size is 10, the update call cache can be disabled through setting the size to 0. */ public void setUpdateCallCacheSize(int updateCallCacheSize) { this.cachedUpdateCalls.setMaxSize(updateCallCacheSize); }
/** * INTERNAL: * Remove the cached expression query. * PERF: Allow caching of expression query SQL call to avoid regeneration. */ public void removeCachedExpressionQuery(DatabaseQuery query) { getCachedExpressionQueries().remove(query); }
/** * Remove a dynamic type from the system. * * This implementation assumes that the dynamic type has no relationships to * it and that it is not involved in an inheritance relationship. If there * are concurrent processes using this type when it is removed some * exceptions may occur. * * @param typeName */ public void removeType(String typeName) { DynamicType type = getType(typeName); if (type != null) { getSession().getIdentityMapAccessor().initializeIdentityMap(type.getJavaClass()); ClassDescriptor descriptor = type.getDescriptor(); fqClassnameToDescriptor.remove(descriptor.getJavaClassName()); getSession().getProject().getOrderedDescriptors().remove(descriptor); getSession().getProject().getDescriptors().remove(type.getJavaClass()); //bug 430318 - clear the parsed cache as queries in that cache could be using this descriptor getSession().getProject().getJPQLParseCache().clear(); ((AbstractSession)getSession()).getCommitManager().getCommitOrder().remove(type.getJavaClass()); } }
/** * Populate the query using the information retrieved from parsing the JPQL. */ public void populateQuery(String jpqlString, ObjectLevelReadQuery query, AbstractSession session) { // PERF: Check if the JPQL has already been parsed. // Only allow queries with default properties to be parse cached. boolean isCacheable = query.isDefaultPropertiesQuery(); DatabaseQuery cachedQuery = null; if (isCacheable) { cachedQuery = (DatabaseQuery)session.getProject().getJPQLParseCache().get(jpqlString); } if ((cachedQuery == null) || (!cachedQuery.isPrepared()) || (cachedQuery.getClass() != query.getClass())) { JPQLParser parser = parseEJBQLString(jpqlString); JPQLParseTree parseTree = parser.getParseTree(); parseTree.populateQuery(query, session); if (isCacheable) { session.getProject().getJPQLParseCache().put(jpqlString, query); } } else { query.prepareFromQuery(cachedQuery); query.setIsPrepared(true); } }
/** * INTERNAL: * Set the cached SQL call for the expression query. * PERF: Allow caching of expression query SQL call to avoid regeneration. */ public void putCachedExpressionQuery(DatabaseQuery query) { getCachedExpressionQueries().put(query, query); }
/** * ADVANCED: * Set the size of the update call cache. * The update call cache is used to cache the update SQL to avoid regeneration. * Since every update with different fields produces different SQL, * this cache allows caching of the update SQL based on the fields being updated. * The default cache size is 10, the update call cache can be disabled through setting the size to 0. */ public void setUpdateCallCacheSize(int updateCallCacheSize) { getCachedUpdateCalls().setMaxSize(updateCallCacheSize); }
/** * INTERNAL: * Remove the cached expression query. * PERF: Allow caching of expression query SQL call to avoid regeneration. */ public void removeCachedExpressionQuery(DatabaseQuery query) { getCachedExpressionQueries().remove(query); }
/** * Remove a dynamic type from the system. * * This implementation assumes that the dynamic type has no relationships to * it and that it is not involved in an inheritance relationship. If there * are concurrent processes using this type when it is removed some * exceptions may occur. * * @param typeName */ public void removeType(String typeName) { DynamicType type = getType(typeName); if (type != null) { getSession().getIdentityMapAccessor().initializeIdentityMap(type.getJavaClass()); ClassDescriptor descriptor = type.getDescriptor(); fqClassnameToDescriptor.remove(descriptor.getJavaClassName()); getSession().getProject().getOrderedDescriptors().remove(descriptor); getSession().getProject().getDescriptors().remove(type.getJavaClass()); //bug 430318 - clear the parsed cache as queries in that cache could be using this descriptor getSession().getProject().getJPQLParseCache().clear(); ((AbstractSession)getSession()).getCommitManager().getCommitOrder().remove(type.getJavaClass()); } }
/** * INTERNAL: * Return the JPQL parse cache. * This is used to optimize dynamic JPQL. */ public ConcurrentFixedCache getJPQLParseCache() { if (jpqlParseCache==null) { jpqlParseCache = new ConcurrentFixedCache(200); } return jpqlParseCache; }
/** * Populate the query using the information retrieved from parsing the JPQL. */ public void populateQuery(String jpqlString, ObjectLevelReadQuery query, AbstractSession session) { // PERF: Check if the JPQL has already been parsed. // Only allow queries with default properties to be parse cached. boolean isCacheable = query.isDefaultPropertiesQuery(); DatabaseQuery cachedQuery = null; if (isCacheable) { cachedQuery = (DatabaseQuery)session.getProject().getJPQLParseCache().get(jpqlString); } if ((cachedQuery == null) || (!cachedQuery.isPrepared()) || (cachedQuery.getClass() != query.getClass())) { JPQLParser parser = parseEJBQLString(jpqlString); JPQLParseTree parseTree = parser.getParseTree(); parseTree.populateQuery(query, session); if (isCacheable) { session.getProject().getJPQLParseCache().put(jpqlString, query); } } else { query.prepareFromQuery(cachedQuery); query.setIsPrepared(true); } }
/** * ADVANCED: * Return the size of the update call cache. * The update call cache is used to cache the update SQL to avoid regeneration. * Since every update with different fields produces different SQL, * this cache allows caching of the update SQL based on the fields being updated. * The default cache size is 10, the update call cache can be disabled through setting the size to 0. */ public int getUpdateCallCacheSize() { return this.cachedUpdateCalls.getMaxSize(); }
/** * INTERNAL: * Return the cached SQL call for the expression query. * PERF: Allow caching of expression query SQL call to avoid regeneration. */ public DatabaseQuery getCachedExpressionQuery(DatabaseQuery query) { return (DatabaseQuery)this.cachedExpressionQueries.get(query); }
/** * INTERNAL: * Set the cached SQL call for the expression query. * PERF: Allow caching of expression query SQL call to avoid regeneration. */ public void putCachedExpressionQuery(DatabaseQuery query) { getCachedExpressionQueries().put(query, query); }
/** * ADVANCED: * Set the size of the update call cache. * The update call cache is used to cache the update SQL to avoid regeneration. * Since every update with different fields produces different SQL, * this cache allows caching of the update SQL based on the fields being updated. * The default cache size is 10, the update call cache can be disabled through setting the size to 0. */ public void setUpdateCallCacheSize(int updateCallCacheSize) { getCachedUpdateCalls().setMaxSize(updateCallCacheSize); }
/** * INTERNAL: * Returns the collection of cached expression queries. */ private ConcurrentFixedCache getCachedExpressionQueries() { if (cachedExpressionQueries == null) { this.cachedExpressionQueries = new ConcurrentFixedCache(20); } return this.cachedExpressionQueries; }