* @return true if this invocation caused the query being registered in the
* cache.
*/
private boolean preExecute(Map params) {
PreparedQueryCache cache = _em.getPreparedQueryCache();
if (cache == null) {
return false;
}
FetchConfiguration fetch = _query.getFetchConfiguration();
if (fetch.getReadLockLevel() != 0) {
if (cache.get(_id) != null) {
ignorePreparedQuery();
}
return false;
}
// Determine if the query has NULL parameters. If so, then do not use a PreparedQuery from the cache
for (Object val : params.values()) {
if (val == null) {
ignorePreparedQuery();
return false;
}
}
Boolean registered = cache.register(_id, _query, fetch);
boolean alreadyCached = (registered == null);
String lang = _query.getLanguage();
QueryStatistics<String> stats = cache.getStatistics();
if (alreadyCached && LANG_PREPARED_SQL.equals(lang)) {
PreparedQuery pq = _em.getPreparedQuery(_id);
if (pq.isInitialized()) {
try {
Map rep = pq.reparametrize(params, _em.getBroker());