Slackbot
09/23/2019, 2:27 PMCzar
09/23/2019, 3:00 PM@org.springframework.transaction.annotation.Transactional
on the update
fun.Sandy
09/23/2019, 3:01 PMCzar
09/23/2019, 3:04 PM@Transactional
Spring Data finishes the transaction at repository method, so the UserDao
entity is a POJO instead of managed bean.
The lazily initialized stuff is therefore just empty and when you save UserDao
you're effectively deleting all that stuff.
If, on the other hand, the function is annotated with @Transactional
, then both query and save operations happen in the same transaction and UserDao
is a managed entity in-between.Sandy
09/23/2019, 3:08 PMSandy
09/23/2019, 3:08 PMCzar
09/23/2019, 3:10 PMSandy
09/23/2019, 3:11 PMCzar
09/23/2019, 3:14 PM