[jboss-cvs] JBossAS SVN: r104947 - projects/ejb-book/trunk/chxx-employeeregistry/src/test/java/org/jboss/ejb3/examples/employeeregistry.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue May 18 17:40:07 EDT 2010
Author: ALRubinger
Date: 2010-05-18 17:40:02 -0400 (Tue, 18 May 2010)
New Revision: 104947
Modified:
projects/ejb-book/trunk/chxx-employeeregistry/src/test/java/org/jboss/ejb3/examples/employeeregistry/EmployeeIntegrationTest.java
Log:
[EJBOOK-27] Show usage of EntityManager.merge()
Modified: projects/ejb-book/trunk/chxx-employeeregistry/src/test/java/org/jboss/ejb3/examples/employeeregistry/EmployeeIntegrationTest.java
===================================================================
--- projects/ejb-book/trunk/chxx-employeeregistry/src/test/java/org/jboss/ejb3/examples/employeeregistry/EmployeeIntegrationTest.java 2010-05-18 21:39:29 UTC (rev 104946)
+++ projects/ejb-book/trunk/chxx-employeeregistry/src/test/java/org/jboss/ejb3/examples/employeeregistry/EmployeeIntegrationTest.java 2010-05-18 21:40:02 UTC (rev 104947)
@@ -270,9 +270,12 @@
// Get an EM
final EntityManager em = emHook.getEntityManager();
- // Look up "Dave" again
- final Employee dave = em.find(Employee.class, ID_DAVE);
+ // Make a new "Dave" as a detached object with same primary key, but a different name
+ final Employee dave = new Employee(ID_DAVE, NAME_DAVE_NEW);
+ // Merge these changes on the detached instance with the DB
+ em.merge(dave);
+
// Ensure we see the name change
Assert.assertEquals("Employee Dave's name should have been changed", NAME_DAVE_NEW, dave.getName());
@@ -302,7 +305,7 @@
// Get an EM
final EntityManager em = emHook.getEntityManager();
- // Look up "Dave" again by ID from the EM
+ // Make a new "Dave" instance
final Employee dave = em.find(Employee.class, ID_DAVE);
log.info("Lookup of Dave after we changed his name on a detached instance: " + dave);
More information about the jboss-cvs-commits
mailing list