/** * Convenience method to return if the specified query should use an "UPDATE" lock on returned * objects. First checks whether serializeRead is set on the query and, if not, falls back to the * setting for the class. * * @param query The query * @return Whether to use an "UPDATE" lock */ public static boolean useUpdateLockForQuery(Query query) { if (query.getSerializeRead() != null) { if (!query.getExecutionContext().getTransaction().isActive()) { // Only applies in a transaction return false; } // Query value takes top priority return query.getSerializeRead(); } else { // Fallback to transaction or class itself return query.getExecutionContext().getSerializeReadForClass(query.getCandidateClassName()); } }