entityManager
Scenario | EntityManager.persist | EntityManager.merge | SessionManager.saveOrUpdate |
---|---|---|---|
Object passed was never persisted | 1. Object added to persistence context as new entity 2. New entity inserted into database at flush/commit |
1. State copied to new entity. 2. New entity added to persistence context 3. New entity inserted into database at flush/commit 4. New entity returned |
1. Object added to persistence context as new entity 2. New entity inserted into database at flush/commit |
Object was previously persisted, but not loaded in this persistence context | 1. EntityExistsException thrown (or a PersistenceException at flush/commit) | 2. Existing entity loaded. 2. State copied from object to loaded entity 3. Loaded entity updated in database at flush/commit 4. Loaded entity returned |
1. Object added to persistence context 2. Loaded entity updated in database at flush/commit |
Object was previously persisted and already loaded in this persistence context | 1. EntityExistsException thrown (or a PersistenceException at flush or commit time) | 1. State from object copied to loaded entity 2. Loaded entity updated in database at flush/commit 3. Loaded entity returned |
1. NonUniqueObjectExceptionthrown |