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

REST Data Panache: JPA Entity with multiple associations not consistently updated #304

Open
snowdrop-bot opened this issue Mar 25, 2021 · 0 comments

Comments

@snowdrop-bot
Copy link
Collaborator

Describe the bug

When an Entity has multiple JPA associations (i.e. ManyToOne, ManyToMany and OneToMany), a removal to the ManyToOne field is not persisted when doing a PUT call.

Expected behavior

Get all the fields updated.

Actual behavior

The ManyToOne field is not part of the update.

To Reproduce

The reproducer is available at multiple-associations/hibernate-orm-panache-quickstart (based on from hibernate-orm-panache-quickstart from development branch).

To reproduce execute the test $ ./mvnw test -Dtest=PersonEndpointTest

Reproducer

The reproducer application has the Person entity with the following associations:

  • M:1 with Country
  • M:N with Fruits
  • 1:M with Car

The bean is deliberately missing the accessor methods for managing changes to associations with Fruits and Cars.

The test() method, basically, posts a Person with a valid Country and then it sends a PUT with a null country but the country is not updated consistently due to a "wrong" update query:

Hibernate: 
    update
        Person 
    set
        birth=?,
        name=? 
    where
        id=?

Commenting one of @ManyToMany or @OneToMany associations (@Transient annotation ready to be decommented) makes the test to work thanks to the execution of the expected update query.

I've also provided a testDb() method that works directly with the DB and it's not affected by the same issue.

Configuration

Screenshots

Environment (please complete the following information):

Output of uname -a or ver

Linux 5.10.16-200.fc33.x86_64 #1 SMP Sun Feb 14 03:02:32 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment 18.9 (build 11.0.10+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.10+9, mixed mode, sharing)

GraalVM version (if different from Java)

Quarkus version or git rev

999-SNAPSHOT (build 20210323.071124-626)

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)

Additional context

(Add any other context about the problem here.)


quarkusio#15961


$upstream:15961$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants