Skip to content

Weird behavour when using bidirectional oneToMany in combination with jpa postload #3750

@JaimePolidura

Description

@JaimePolidura

Hello,

I',m unsure if this is project is the correct place to report the following behavour I've observed, please let me know if I should report it to another github project.

With the latest spring boot 3.4.x version, I have observed the following problem in my springboot project that uses spring data jpa to persist againsts postgres database. I have created a small springboot project to reproduce this bug github project

  • I have a parent entity with a oneToMany relationship to a child entity.
  • In the child entity I have a bidirectional manyToOne relationship to the parent.
  • Aditionally in the parent I have a jpa @PostLoad annotation where I just sort the list of children by an integer field.
  • I have added a spring boot test to persist a parent whith three children, and then load all children from database.
  • For your convenience, the pom.xml includes docker-maven-plugin to start postgres via docker, please use the following command: mvn docker:start -Pdocker

The test throws an exception because of during the postload in the list of children the first child's fields are null, interestingly other children have fields with values as expected, please see screenshot:

Image

I have added a feature branch in my project revert-to-old-springboot where I use spring boot 3.3.x instead and the test is successful and the bug does not appear.

Metadata

Metadata

Assignees

Labels

for: external-projectFor an external project and not something we can fix

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions