snowdrop-zen / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
1 stars 0 forks source link

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

Open snowdrop-bot opened 3 years ago

snowdrop-bot commented 3 years ago

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:

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.)


https://github.com/quarkusio/quarkus/issues/15961


$upstream:15961$