Reputation: 1449
I have Person
entity with lazily fetched List<Contact> contacts
.
I got my person
entity object and some time later I want to get person's contacts (obviously I can do that only if entity is managed).
What is the best way to merge/put to context person
entity in Spring Data JPA?
Upvotes: 1
Views: 296
Reputation: 1449
This answers my question:
Person managedPerson = personRepository.save(person)
save
method checks if person
entity is new. If it is so, it persists entity, otherwise it merges it and returns back managed entity
Upvotes: 1