OracleDialect: setMaxResults conflicts with LockMode.UPGRADE

Description

Generated SQL-Statements are syntactically wrong when mixing setMaxResults and setLockMode using Oracle9Dialect.

Simple example:

Query q = session.createQuery(
"from QueueableOrder o where o.status=(:status)");
q.setInteger("status", 0);
q.setMaxResults(bulkSize);
q.setLockMode("o", LockMode.UPGRADE);

produces the following SQL:

select * from (
select
queueableo0_.id as id,
queueableo0_.orderType as orderType,
queueableo0_.status as status,
from
ORDER_QUEUE queueableo0_
where (queueableo0_.status=)
for update
) where rownum <= ?

instead of

select * from (
select
queueableo0_.id as id,
queueableo0_.orderType as orderType,
queueableo0_.status as status,
from
ORDER_QUEUE queueableo0_
where (queueableo0_.status=)

) where rownum <= ? for update

This means, the "for update" is wrongly put into the inner clause which causes Oracle to prompt: ORA-00907: missing right parenthesis

Environment

None

Assignee

Unassigned

Reporter

Jonas Kilian

Labels

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Suitable for new contributors

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Components

Affects versions

Priority

Major
Configure