-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix 'object references an unsaved transient instance' error [ACC-1827]
By adding FetchType.LAZY to @OnetoOne and @manytoone relations, their references are no longer automatically updated when CrudRepository.save() returns a different instance (usually when it is not yet present in the db). When fetching such an entity with an old reference, Hibernate will not find the id of the target entity and throws 'object references an unsaved transient instance' error. The problem is solved by setting the @OnetoOne or @manytoone relation manually after the other side was saved.
- Loading branch information
Showing
2 changed files
with
16 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters