Reputation: 1299
I've got situation like this:
@Transactional
@Override
public void register(String username, UserPasswordNew userPasswordNew, UserAccount userAccount) throws UserNameAlreadyExistsException {
.....
entityManager.merge(userAccountToSave);
}
I made some research but check me if I understand well. I've got entityManager
(transaction scope). Method register is @Transactional
so it means that this method is wrapped in proxy. When persistence context is created ? During the first call of entityManager.merge ()
?? Transaction is commit after method because it's wrapped in proxy. So persistence context is removed after commit ?
Upvotes: 1
Views: 115
Reputation: 292
Correct me if I am wrong, but you are using transaction scoped entitymanager, so during each call to entitymanager it ensure that persistence context exists, here entitymanager creates a new one and uses it to merge - and,as in transaction-scoped entitymanager, persistence context will be removed after each commit.
Upvotes: 1