This repository was archived by the owner on Jan 13, 2023. It is now read-only.
Open
Conversation
# Conflicts: # employee-profile/src/main/java/com/bobocode/model/Employee.java # employee-profile/src/main/java/com/bobocode/model/EmployeeProfile.java
# Conflicts: # photo-comment-dao/src/main/java/com/bobocode/dao/PhotoDaoImpl.java # photo-comment-dao/src/main/java/com/bobocode/model/Photo.java
# Conflicts: # employee-profile/src/main/java/com/bobocode/model/Employee.java # photo-comment-dao/src/main/java/com/bobocode/model/PhotoComment.java
FedosovMax
reviewed
Sep 20, 2018
| @Override | ||
| public void update(Account account) { | ||
| throw new UnsupportedOperationException("I don't wanna work without implementation!"); // todo | ||
| performWithinPersistenceContext(em -> em.merge(account)); |
There was a problem hiding this comment.
Хочу уточнить, Merge вроде как возвращает объект с базы в persistence context, а как он выполняет апдейт с его помощью?
Collaborator
Author
There was a problem hiding this comment.
Since provided account is in the detached state (it has an id, and is not loaded to the Persistence Context), Hibernate will call the database to load this account by its id first. Then it will copy data from account you provided onto loaded account. So, if the account you provided has some fields changed, these changes will be applied to the loaded account, and since loaded account is changed in the scope of a persistence context, dirty checking will call database to perform an update.
# Conflicts: # company-products/src/main/java/com/bobocode/model/Product.java
# Conflicts: # author-book/src/main/java/com/bobocode/model/Book.java
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request is created in order to discuss the completed solution of the exercises. Feel free to ask any questions by adding comments to the PR ➕