Spring Boot error with PUT operation and Entity View
pvncoder opened this issue · 0 comments
pvncoder commented
Description
When performing a PUT
operation on an Entity View
object that contains an empty list in a Spring Boot + Blaze Persistence project, and using evm.saveFull(em, object)
to save it, the following error occurs:
WARN 5624 --- [nio-8080-exec-2] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [org.springframework.orm.jpa.JpaSystemException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: br.com.dto.MyEntityView.myEntityViewList]
Expected behavior
The saveFull
operation should work for any Entity View
that contains a list within it (even if it is empty).
Actual behavior
The saveFull
operation fails with the mentioned error when attempting to save an Entity View
object that contains an empty list.
Steps to reproduce
- Download the zip file containing the test case (BlazePersistenceTestCaseSpringBootPutOperationIssue.zip);
- Run the command
./mvnw clean install
at the root of the project; - Run the Spring Boot project with your IDE of choice or using the command
java -jar target/blaze-persistence-test-case-spring-boot-put-operation-issue-0.0.1-SNAPSHOT.jar
; - Make a POST request to http://localhost:8080/users with the following JSON:
{
"username": "007 AGENT"
}
- After successfully creating a user, make a PUT request to http://localhost:8080/users/{idUser} with the following JSON:
{
"username": "008 AGENT"
}
In this last PUT request, you should encounter the error I described earlier.
Environment
Version: 1.6.11
Spring Boot: 3.2.3
JPA-Provider: Hibernate 6.4.4.Final
DBMS: h2, postgresql
Application Server: N/A