Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reactive find with lock in Quarkus with reactive hibernate - Issue reproduced #1905

Open
alexjaravete opened this issue May 2, 2024 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@alexjaravete
Copy link

Hi, this is related to this issue #1896.

Hi, when using Quarkus with reactive hibernate and trying to run this findById(id, LockModeType.PESSIMISTIC_WRITE), I get following Error: JPA error: java.lang.UnsupportedOperationException
The error seems to be coming from here:
hibernate-reactive/hibernate-reactive-core/src/main/java/org/hibernate/reactive/event/impl/DefaultReactiveLockEventListener.java
Lines 238 to 241 in 5cb015d
@OverRide
public void onLock(LockEvent event) throws HibernateException {
throw new UnsupportedOperationException();
}
Is this intended, or is the implementation not finished? I can see that the last time this was edited was 4 years ago.

I was able to reproduce the issue when using a OneToMany and ManyToOne relationship.
By doing this, hibernate is forced to do a JOIN and the SELECT FOR UDPATE cannot be done in the same request.
When hibernate is trying to do the followup Lock, it throws an error.

The error should already show up after creating a Fruit and fetching it.
No Owner object is needed.
It's only there to trigger the issue.

This is the repository with the reproduced issue: https://github.com/alexjaravete/quarkus-quickstarts/tree/findById/hibernate-reactive-panache-quickstart

@alexjaravete alexjaravete changed the title Reactive find with lock in Quarkus with reactive hibernate Issue reprocuded Reactive find with lock in Quarkus with reactive hibernate - Issue reproduced May 2, 2024
@DavideD
Copy link
Member

DavideD commented May 2, 2024

Thanks for the project. I can see the error.

It seems quite complicated to solve, but I will give it a try

@DavideD DavideD added problem A limitation or source of discomfort and removed problem A limitation or source of discomfort labels Dec 6, 2024
@dreab8
Copy link
Member

dreab8 commented Jan 22, 2025

Hi @alexjaravete ,

I tried to run your reproducer and all tests pass

@DavideD
Copy link
Member

DavideD commented Jan 23, 2025

@dreab8, do you mean that this work in Hibernate Reactive 3?
Is it possible to add a unit test for this?

@DavideD DavideD added bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels Jan 23, 2025
@dreab8
Copy link
Member

dreab8 commented Jan 23, 2025

@DavideD I tried with the reproducer provided by @alexjaravete that uses 2.2.2 and the tests pass

@dreab8 dreab8 self-assigned this Jan 23, 2025
@dreab8
Copy link
Member

dreab8 commented Jan 23, 2025

Added

@Test
    public void testGetFruit() {
       given()
                .when()
                .get("/fruits/1")
                .then()
                .statusCode(200);
    }

and the problem showed up.

Thanks @DavideD

dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Jan 25, 2025
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Jan 27, 2025
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Jan 27, 2025
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Jan 27, 2025
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Jan 27, 2025
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Jan 27, 2025
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Jan 27, 2025
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Jan 27, 2025
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Jan 27, 2025
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Jan 27, 2025
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Jan 27, 2025
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Jan 27, 2025
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Jan 28, 2025
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants