Skip to content

session.find() will not respect NOWAIT locks starting from HR 3.1 / ORM 7.1 #2534

@markusdlugi

Description

@markusdlugi

We tried to update our application to Quarkus 3.26+ but noticed some issues in our tests which rely on an UPGRADE_NOWAIT lock. We are basically doing:

session.find(Entity.class, id, LockMode.UPGRADE_NOWAIT)

This worked fine in HR 3.0 / ORM 7.0, resulting in the following query:

    select
        e1_0.name,
    from
        Entity e1_0 
    where
        e1_0.id=$1 
    for
        no key update nowait

After the update to HR 3.1 / ORM 7.1, we see this query instead, missing the nowait clause:

    select
        e1_0.name
    from
        Entity e1_0 
    where
        e1_0.id=$1 
    for
        no key update of e1_0

Seems like the changes to the LockOptions which were done as part of ORM 7.1 broke something here. I actually found one workaround, but this is of course pretty cumbersome in comparison to the original find() call:

session.createQuery("FROM Entity e WHERE e.name = :id", Entity.class) 
    .setParameter("id", id) 
    .setLockMode(LockMode.UPGRADE_NOWAIT) 
    .getSingleResultOrNull()

We are using PostgreSQL, but I believe this behavior is the same regardless of dialect.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingregressionSomething that was working before. A test that we have disabled

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions