-
Bug
-
Resolution: Done
-
Major
-
jBPM 3.2.9
-
None
Regarding the HQL query that is used to calculate nextDueDate in DispatcherThread, JobSession.getFirstUnownedDueJob, I just checked with a Hibernate expert and it could indeed be the case that this query returns the bigger part of the JBPM_JOB table.
The HQL query is defined like this:
<query name="JobSession.getFirstUnownedDueJob"> <![CDATA[ select job from org.jbpm.job.Job job where job.lockOwner is null and job.retries > 0 and job.isSuspended = false order by job.dueDate asc ]]> </query>
and the result is handled that way:
return (Job) query.setMaxResults(1).uniqueResult();
Hibernate can issue a request that returns all records from the DB, and then just restrict the result to a single row. To prevent this potentially expensive DB call, the 'correct' way would be to add further restrictions to the HQL.