Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-dev] Transaction details

Ok, so it would appear my emails to this mailing list are delayed by a day. I'm not sure who's received what and in what order anymore, so I have re-attached the latest patches, please use this email as the source of truth and ignore all others.
 
Sorry for all the confusions, but hopefully these mailing lists issues will be resolved soon (and I hope you get this email today).
 
Please send me your feedback.
 
Thanks,
Guy
 
----- Original Message -----
Sent: Thursday, October 04, 2007 8:39 AM
Subject: Re: [eclipselink-dev] Transaction details

Please disregard this notice. Important edits since this email was sent (which was yesterday morning) have been incorporated. A new notice with new patches is to follow soon.
 
Cheers,
Guy
----- Original Message -----
Sent: Wednesday, October 03, 2007 9:59 AM
Subject: [eclipselink-dev] Transaction details

The attached eclipse patches outline some jpa packaging changes that are to be submitted. The changes arose from an Oracle internal bug (6059714).
 
Since there are no actual code changes, no new tests have been added and existing tests continue to pass.
 
Upon review it will be submitted. If you have any questions or concerns please let me know.
 
Cheers,
Guy
 
 


_______________________________________________
eclipselink-dev mailing list
eclipselink-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev


_______________________________________________
eclipselink-dev mailing list
eclipselink-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLComplexTestSuite.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLComplexTestSuite.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLComplexTestSuite.java	(working copy)
@@ -169,7 +169,7 @@
 
     public void complexABSTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
          
         Employee emp1 = (Employee)em.getActiveSession().readAllObjects(Employee.class).firstElement();
 	    Employee emp2 = (Employee)em.getActiveSession().readAllObjects(Employee.class).lastElement();
@@ -193,7 +193,7 @@
 
     public void complexABSWithParameterTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
 
         Employee emp = (Employee)em.getActiveSession().readAllObjects(Employee.class).firstElement();
         clearCache();
@@ -213,7 +213,7 @@
     
     public void compexInTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
          
         Employee emp1 = (Employee)em.getActiveSession().readAllObjects(Employee.class).firstElement();
 	    Employee emp2 = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(1);
@@ -246,7 +246,7 @@
     
     public void complexLengthTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();          
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();          
         
         Assert.assertFalse("Warning SQL doesnot support LENGTH function",  ((Session) JUnitTestCase.getServerSession()).getPlatform().isSQLServer());
         
@@ -266,7 +266,7 @@
     
     public void complexLikeTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();          
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();          
         
         Employee emp = (Employee)em.getActiveSession().readAllObjects(Employee.class).firstElement();
         
@@ -293,7 +293,7 @@
     
     public void complexNotInTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
          
         Employee emp1 = (Employee)em.getActiveSession().readAllObjects(Employee.class).firstElement();
         Employee emp2 = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(1);
@@ -329,7 +329,7 @@
     
     public void complexNotLikeTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
         
         Employee emp = (Employee)em.getActiveSession().readAllObjects(Employee.class).firstElement();
         
@@ -358,7 +358,7 @@
     
     public void complexParameterTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
         
         Employee emp = (Employee)em.getActiveSession().readAllObjects(Employee.class).firstElement();
                 
@@ -398,7 +398,7 @@
     
     public void complexReverseAbsTest()
     {
-       org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+       org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
          
         Employee emp1 = (Employee)em.getActiveSession().readAllObjects(Employee.class).firstElement();
 	    Employee emp2 = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(1);
@@ -423,7 +423,7 @@
     public void complexReverseLengthTest()
     {
         
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();          
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();          
         
         Assert.assertFalse("Warning SQL doesnot support LENGTH function",  ((Session) JUnitTestCase.getServerSession()).getPlatform().isSQLServer());
         
@@ -444,7 +444,7 @@
     
     public void complexReverseParameterTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();          
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();          
         
         Employee emp = (Employee)em.getActiveSession().readAllObjects(Employee.class).firstElement();
         
@@ -485,7 +485,7 @@
     
     public void complexReverseSqrtTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
          
         ReadAllQuery raq = new ReadAllQuery();
         ExpressionBuilder expbldr = new ExpressionBuilder();
@@ -519,7 +519,7 @@
     
     public void complexSqrtTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
          
         ReadAllQuery raq = new ReadAllQuery();
         ExpressionBuilder expbldr = new ExpressionBuilder();
@@ -552,7 +552,7 @@
     
     public void complexStringInTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
          
         Employee emp1 = (Employee)em.getActiveSession().readAllObjects(Employee.class).firstElement();
 	    Employee emp2 = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(1);
@@ -586,7 +586,7 @@
     
     public void complexStringNotInTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
          
         Employee emp1 = (Employee)em.getActiveSession().readAllObjects(Employee.class).firstElement();
 	    Employee emp2 = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(1);
@@ -624,7 +624,7 @@
     
     public void complexSubstringTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
          
         Employee expectedResult = (Employee)em.getActiveSession().readAllObjects(Employee.class).firstElement();
         
@@ -649,7 +649,7 @@
     
     public void complexLocateTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         String jpql = "SELECT e FROM Employee e WHERE e.firstName = 'Emanual' AND e.lastName = 'Smith'";
         Employee expectedResult = (Employee)em.createQuery(jpql).getSingleResult();
 
@@ -664,7 +664,7 @@
     
     public void complexNestedOneToManyUsingInClause()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
          
         Employee emp = (Employee)em.getActiveSession().readAllObjects(Employee.class).firstElement();
         
@@ -693,7 +693,7 @@
 
     public void complexUnusedVariableTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
          
         Employee emp = (Employee)em.getActiveSession().readAllObjects(Employee.class).firstElement();
         ReportQuery reportQuery = new ReportQuery();
@@ -717,7 +717,7 @@
 
     public void complexJoinTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         Collection emps = em.getActiveSession().readAllObjects(Employee.class);
         Employee empWithManager = null;
         Employee empWithOutManager = null;
@@ -767,8 +767,8 @@
      */
     public void complexMultipleJoinOfSameRelationship()
     {
-        org.eclipse.persistence.jpa.EntityManager em = 
-            (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = 
+            (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         String jpql = "SELECT p1, p2 FROM Employee emp JOIN emp.phoneNumbers p1 JOIN emp.phoneNumbers p2 " +
                       "WHERE p1.type = 'Pager' AND p2.areaCode = '613'";
         Query query = em.createQuery(jpql);
@@ -779,7 +779,7 @@
 
     public void complexFetchJoinTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
          
         Employee emp = (Employee)em.getServerSession().readAllObjects(Employee.class).firstElement();
         ReportQuery reportQuery = new ReportQuery();
@@ -804,7 +804,7 @@
     
     public void complexSelectRelationshipTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager(); 
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager(); 
         
         Collection emps = em.getActiveSession().readAllObjects(Employee.class);
         Employee empWithManager = null;
@@ -846,7 +846,7 @@
 
     public void complexConstructorTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager(); 
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager(); 
         
         Employee emp = (Employee)em.getActiveSession().readAllObjects(Employee.class).firstElement();
 
@@ -862,7 +862,7 @@
 
     public void complexConstructorVariableTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager(); 
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager(); 
         
         Employee emp = (Employee)em.getActiveSession().readAllObjects(Employee.class).firstElement();
 
@@ -878,7 +878,7 @@
 
     public void complexConstructorRelationshipTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager(); 
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager(); 
         
         Collection emps = em.getActiveSession().readAllObjects(Employee.class);
         Employee empWithManager = null;
@@ -926,7 +926,7 @@
 
     public void complexConstructorAggregatesTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager(); 
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager(); 
 
         Collection emps = em.getActiveSession().readAllObjects(Employee.class);
         Employee emp = null;
@@ -964,8 +964,8 @@
 
     public void complexConstructorCountOnJoinedVariableTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = 
-            (org.eclipse.persistence.jpa.EntityManager) createEntityManager(); 
+        org.eclipse.persistence.jpa.JpaEntityManager em = 
+            (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager(); 
 
         // find all employees with managed employees
         Collection emps = em.getActiveSession().readAllObjects(Employee.class);
@@ -991,7 +991,7 @@
     
     public void complexResultPropertiesTest() 
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
 
         String ejbql = "SELECT e FROM Employee e ORDER BY e.id";
         Query query = em.createQuery(ejbql);
@@ -1030,7 +1030,7 @@
     public void complexNamedQueryResultPropertiesTest() 
     {
         //This new added test case is for glassFish bug 2689 
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         
         Query query = em.createNamedQuery("findAllEmployeesOrderById");
         List allEmps = query.getResultList();
@@ -1084,7 +1084,7 @@
 
     public void complexInSubqueryTest() 
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
 
         ReportQuery reportQuery = new ReportQuery();
         reportQuery.dontMaintainCache();
@@ -1102,7 +1102,7 @@
     
     public void complexExistsTest() 
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         
         Collection allEmps = em.getActiveSession().readAllObjects(Employee.class);
         List expectedResult = new ArrayList();
@@ -1124,7 +1124,7 @@
     
     public void complexNotExistsTest() 
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         
         Collection allEmps = em.getActiveSession().readAllObjects(Employee.class);
         List expectedResult = new ArrayList();
@@ -1146,8 +1146,8 @@
 
     public void complexMemberOfTest() 
     {
-        org.eclipse.persistence.jpa.EntityManager em = 
-            (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = 
+            (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         
         Collection allEmps = em.getActiveSession().readAllObjects(Employee.class);
 
@@ -1177,8 +1177,8 @@
     
     public void complexNotMemberOfTest() 
     {
-        org.eclipse.persistence.jpa.EntityManager em = 
-            (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = 
+            (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         
         Collection allEmps = em.getActiveSession().readAllObjects(Employee.class);
         List expectedResult = new ArrayList();
@@ -1190,7 +1190,7 @@
     public void complexInheritanceTest()
     {
     
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
         
         ((AbstractSession) em.getActiveSession()).addAlias("ProjectBaseClass", getServerSession().getDescriptor(Project.class));
         
@@ -1216,7 +1216,7 @@
     
     public void complexInheritanceUsingNamedQueryTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
         
         Project expectedResult = (Project)em.getActiveSession().readAllObjects(Project.class).firstElement();
 	    
@@ -1258,8 +1258,8 @@
 
     public void complexNavigatingEmbedded ()
     {
-        org.eclipse.persistence.jpa.EntityManager em = 
-            (org.eclipse.persistence.jpa.EntityManager) createEntityManager(); 
+        org.eclipse.persistence.jpa.JpaEntityManager em = 
+            (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager(); 
     	String jpqlString = "SELECT e.formerEmployment.formerCompany FROM Employee e WHERE e.formerEmployment.formerCompany = 'Former company'";
         Query query = em.createQuery(jpqlString);
         List result = query.getResultList();
@@ -1271,8 +1271,8 @@
 
     public void complexNavigatingTwoLevelOfEmbeddeds ()
     {
-        org.eclipse.persistence.jpa.EntityManager em = 
-            (org.eclipse.persistence.jpa.EntityManager) createEntityManager(); 
+        org.eclipse.persistence.jpa.JpaEntityManager em = 
+            (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager(); 
     	String jpqlString = "SELECT emp.formerEmployment.period.startDate FROM Employee emp";
         Query query = em.createQuery(jpqlString);
         List result = query.getResultList();
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLInheritanceTestSuite.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLInheritanceTestSuite.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLInheritanceTestSuite.java	(working copy)
@@ -113,7 +113,7 @@
     }
 
     public void testStraightReadSuperClass() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
          
         Project project = (Project)em.createQuery("SELECT p from Project p").getResultList().get(0);
         clearCache();
@@ -125,7 +125,7 @@
     }
     
     public void testStraightReadSubClass() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
          
         SmallProject project = (SmallProject)em.createQuery("SELECT s from SmallProject s").getResultList().get(0);
         clearCache();
@@ -137,7 +137,7 @@
     }
 
     public void testJoinSuperClass() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
          
         Employee emp = (Employee)em.createQuery("SELECT e from Employee e JOIN e.projects p where e.lastName is not null").getResultList().get(0);
         clearCache();
@@ -150,7 +150,7 @@
     }
 
     public void testJoinSubClass() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
          
         Engineer emp = (Engineer)em.createQuery("SELECT e from Engineer e JOIN e.bestFriend b WHERE e.title is not null").getResultList().get(0);
         clearCache();
@@ -163,7 +163,7 @@
     }
 
     public void testJoinFetchSuperClass() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
          
         Employee emp = (Employee)em.createQuery("SELECT e from Employee e JOIN FETCH e.projects").getResultList().get(0);
         clearCache();
@@ -176,7 +176,7 @@
     }
 
     public void testJoinFetchSubClass() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
          
         Engineer emp = (Engineer)em.createQuery("SELECT e from Engineer e JOIN FETCH e.bestFriend").getResultList().get(0);
         clearCache();
@@ -194,7 +194,7 @@
      * See issue 860.
      */
     public void testJoinedInheritance() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
 
         String ejbqlString = "SELECT OBJECT(b) FROM BBB b WHERE b.foo = ?1";
         // query throws exception, if result not unique!
@@ -202,7 +202,7 @@
     }
     
     public void testJoinedInheritanceWithLeftOuterJoin1() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();        
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();        
         String ejbqlString = "SELECT t0.maxSpeed, t0.color, t0.description, t0.fuelCapacity, t0.fuelType, t0.id, t0.passengerCapacity, t1.name, t1.id FROM SportsCar t0 LEFT OUTER JOIN t0.owner t1";
         try {
             em.createQuery(ejbqlString).getResultList();
@@ -212,7 +212,7 @@
     }
     
     public void testJoinedInheritanceWithLeftOuterJoin2() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         String ejbqlString = "SELECT t0.color, t0.description, t0.fuelCapacity, t0.fuelType, t0.id, t0.passengerCapacity, t1.name, t1.id FROM FueledVehicle t0 LEFT OUTER JOIN t0.owner t1";
         try {
             em.createQuery(ejbqlString).getResultList();
@@ -222,7 +222,7 @@
     }
     
     public void testJoinedInheritanceWithLeftOuterJoin3() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         String ejbqlString = "SELECT t0.color, t0.description, t0.fuelCapacity, t0.fuelType, t0.id, t0.passengerCapacity, t1.name, t1.id FROM Bus t0 LEFT OUTER JOIN t0.busDriver t1";
         try {
             em.createQuery(ejbqlString).getResultList();
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLSimpleTestSuite.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLSimpleTestSuite.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLSimpleTestSuite.java	(working copy)
@@ -229,7 +229,7 @@
     //2.  Test both scenarios of using the cache and bypassing the cache
 
     public void simpleJoinFetchTest() throws Exception {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         simpleJoinFetchTest(em);
     }
     
@@ -238,7 +238,7 @@
     // tests that Fetch join works when returning objects that may already have been loaded in the em/uow (without the joined relationships)
     // Builds on simpleJoinFetchTest
     public void simpleJoinFetchTest2() throws Exception {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         //preload employees into the cache so that phonenumbers are not prefetched
         String ejbqlString = "SELECT e FROM Employee e";
         List result = em.createQuery(ejbqlString).getResultList();
@@ -246,7 +246,7 @@
         simpleJoinFetchTest(em);
     }
 
-    public void simpleJoinFetchTest(org.eclipse.persistence.jpa.EntityManager em) throws Exception {
+    public void simpleJoinFetchTest(org.eclipse.persistence.jpa.JpaEntityManager em) throws Exception {
         String ejbqlString = "SELECT e FROM Employee e LEFT JOIN FETCH e.phoneNumbers";
 
         //use the cache
@@ -313,7 +313,7 @@
     //Test case for selecting ALL employees from the database
 
     public void baseTestCase() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         List expectedResult = em.getActiveSession().readAllObjects(Employee.class);
 
@@ -327,7 +327,7 @@
     //Test case for ABS function in EJBQL
 
     public void simpleABSTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee expectedResult = (Employee)(em.getActiveSession().readAllObjects(Employee.class).firstElement());
 
@@ -349,7 +349,7 @@
     public void simpleBetweenAndTest() {
         BigDecimal empId = new BigDecimal(0);
 
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee employee = (Employee)(em.getActiveSession().readAllObjects(Employee.class).lastElement());
 
@@ -373,7 +373,7 @@
     public void simpleBetweenTest() {
         BigDecimal empId = new BigDecimal(0);
 
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee employee = (Employee)(em.getActiveSession().readAllObjects(Employee.class).lastElement());
 
@@ -396,7 +396,7 @@
     //Test case for concat function in EJBQL
 
     public void simpleConcatTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee expectedResult = (Employee)(em.getActiveSession().readAllObjects(Employee.class).firstElement());
 
@@ -424,7 +424,7 @@
     //Test case for concat function in EJBQL taking parameters
 
     public void simpleConcatTestWithParameters() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee expectedResult = (Employee)(em.getActiveSession().readAllObjects(Employee.class).firstElement());
 
@@ -453,7 +453,7 @@
     //Test case for concat function with constants in EJBQL
 
     public void simpleConcatTestWithConstants1() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee emp = (Employee)(em.getActiveSession().readAllObjects(Employee.class).firstElement());
 
@@ -486,7 +486,7 @@
     //Test case for double OR function in EJBQL
 
     public void simpleDistinctTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         String ejbqlString = "SELECT DISTINCT e FROM Employee e JOIN FETCH e.phoneNumbers ";
         List result = em.createQuery(ejbqlString).getResultList();
         Set testSet = new HashSet();
@@ -498,7 +498,7 @@
     }
 
     public void simpleDistinctNullTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         Employee emp = (Employee)em.createQuery("SELECT e from Employee e").getResultList().get(0);
         String oldFirstName = emp.getFirstName();
         em.getTransaction().begin();
@@ -535,7 +535,7 @@
     }
 
     public void simpleDistinctMultipleResultTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         String ejbqlString = "SELECT DISTINCT e, e.firstName FROM Employee e JOIN FETCH e.phoneNumbers ";
         List result = em.createQuery(ejbqlString).getResultList();
         Set testSet = new HashSet();
@@ -555,7 +555,7 @@
     public void simpleDoubleOrTest() {
         Employee emp1, emp2, emp3;
 
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         emp1 = (Employee)(em.getActiveSession().readAllObjects(Employee.class).firstElement());
         emp2 = (Employee)(em.getActiveSession().readAllObjects(Employee.class).elementAt(1));
@@ -578,7 +578,7 @@
     //Test case for equals brackets in EJBQL
 
     public void simpleEqualsBracketsTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee expectedResult = (Employee)(em.getActiveSession().readAllObjects(Employee.class).firstElement());
 
@@ -596,7 +596,7 @@
     //Test case for equals in EJBQL
 
     public void simpleEqualsTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee expectedResult = (Employee)(em.getActiveSession().readAllObjects(Employee.class).firstElement());
 
@@ -614,7 +614,7 @@
     //Test case for equals with join in EJBQL
 
     public void simpleEqualsTestWithJoin() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         ExpressionBuilder builder = new ExpressionBuilder();
         Expression whereClause = builder.anyOf("managedEmployees").get("address").get("city").equal("Ottawa");
@@ -631,7 +631,7 @@
     }
 
     public void simpleEqualsWithAs() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         Employee expectedResult = (Employee)(em.getActiveSession().readAllObjects(Employee.class).firstElement());
 
         clearCache();
@@ -646,7 +646,7 @@
     }
 
     public void collectionMemberIdentifierEqualsTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         ExpressionBuilder employees = new ExpressionBuilder();
         Expression exp = employees.get("firstName").equal("Bob");
@@ -665,7 +665,7 @@
     }
 
     public void abstractSchemaIdentifierEqualsTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee expectedResult = (Employee)em.getActiveSession().readAllObjects(Employee.class).firstElement();
 
@@ -679,7 +679,7 @@
     }
 
     public void abstractSchemaIdentifierNotEqualsTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Vector expectedResult = em.getActiveSession().readAllObjects(Employee.class);
 
@@ -698,7 +698,7 @@
 
     public void simpleInOneDotTest() {
         //select a specifif employee using Expr Bob Smithn
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         ReadObjectQuery roq = new ReadObjectQuery(Employee.class);
 
@@ -724,7 +724,7 @@
     }
 
     public void selectAverageQueryForByteColumnTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         String ejbqlString = "Select AVG(emp.salary)from Employee emp";
         Object result = em.createQuery(ejbqlString).getSingleResult();
@@ -733,7 +733,7 @@
     }
 
     public void simpleInTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee expectedResult = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(0);
 
@@ -747,7 +747,7 @@
     }
 
     public void simpleLengthTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Assert.assertFalse("Warning SQL doesnot support LENGTH function", (JUnitTestCase.getServerSession()).getPlatform().isSQLServer());
 
@@ -767,7 +767,7 @@
 
 
     public void simpleLikeTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee expectedResult = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(0);
 
@@ -782,7 +782,7 @@
     }
 
     public void simpleLikeTestWithParameter() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee emp = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(0);
 
@@ -809,7 +809,7 @@
     }
 
     public void simpleLikeEscapeTestWithParameter() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Address expectedResult = new Address();
         expectedResult.setCity("TAIYUAN");
@@ -843,7 +843,7 @@
     }
 
     public void simpleNotBetweenTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee emp1 = (Employee)em.getActiveSession().readAllObjects(Employee.class).firstElement();
         Employee emp2 = (Employee)em.getActiveSession().readAllObjects(Employee.class).lastElement();
@@ -873,7 +873,7 @@
     }
 
     public void simpleNotEqualsVariablesInteger() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Vector expectedResult = em.getActiveSession().readAllObjects(Employee.class);
 
@@ -892,7 +892,7 @@
     }
 
     public void simpleNotInTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee emp = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(0);
 
@@ -918,7 +918,7 @@
     }
 
     public void simpleNotLikeTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee emp = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(0);
 
@@ -943,7 +943,7 @@
     }
 
     public void simpleOrFollowedByAndTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee emp1 = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(0);
         Employee emp2 = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(1);
@@ -960,7 +960,7 @@
     }
 
     public void simpleOrFollowedByAndTestWithStaticNames() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         ExpressionBuilder builder = new ExpressionBuilder();
         Expression whereClause = builder.get("firstName").equal("John").or(builder.get("firstName").equal("Bob").and(builder.get("lastName").equal("Smith")));
@@ -981,7 +981,7 @@
     }
 
     public void simpleOrTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee emp1 = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(0);
         Employee emp2 = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(1);
@@ -999,7 +999,7 @@
     }
 
     public void simpleParameterTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee expectedResult = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(0);
 
@@ -1029,7 +1029,7 @@
 
     public void simpleParameterTestChangingParameters() {
 
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee emp1 = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(0);
         Employee emp2 = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(1);
@@ -1071,7 +1071,7 @@
     }
 
     public void simpleReverseAbsTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee expectedResult = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(0);
         clearCache();
@@ -1085,7 +1085,7 @@
     }
 
     public void simpleReverseConcatTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee expectedResult = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(0);
 
@@ -1108,7 +1108,7 @@
     }
 
     public void simpleReverseEqualsTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee expectedResult = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(0);
 
@@ -1124,7 +1124,7 @@
     }
 
     public void simpleReverseLengthTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee expectedResult = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(0);
 
@@ -1140,7 +1140,7 @@
     }
 
     public void simpleReverseParameterTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee emp = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(0);
 
@@ -1170,7 +1170,7 @@
     }
 
     public void simpleReverseSqrtTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         ExpressionBuilder expbldr = new ExpressionBuilder();
         Expression whereClause = expbldr.get("firstName").equal("SquareRoot").and(expbldr.get("lastName").equal("TestCase1"));
@@ -1196,7 +1196,7 @@
     }
 
     public void simpleReverseSubstringTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee expectedResult = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(0);
 
@@ -1218,7 +1218,7 @@
 
 
     public void simpleSqrtTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         ExpressionBuilder expbldr = new ExpressionBuilder();
         Expression whereClause = expbldr.get("firstName").equal("SquareRoot").and(expbldr.get("lastName").equal("TestCase1"));
@@ -1243,7 +1243,7 @@
     }
 
     public void simpleSubstringTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee expectedResult = (Employee)em.getActiveSession().readAllObjects(Employee.class).elementAt(0);
 
@@ -1259,7 +1259,7 @@
     }
 
     public void simpleNullTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee nullEmployee = new Employee();
         nullEmployee.setFirstName(null);
@@ -1295,7 +1295,7 @@
     }
 
     public void simpleNotNullTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         Employee nullEmployee = new Employee();
         nullEmployee.setFirstName(null);
         nullEmployee.setLastName("Test");
@@ -1328,7 +1328,7 @@
     }
 
     public void distinctTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         ReadAllQuery raq = new ReadAllQuery();
 
         ExpressionBuilder employee = new ExpressionBuilder();
@@ -1380,7 +1380,7 @@
     }
 
     public void conformResultsInUnitOfWorkTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         ReadObjectQuery readObjectQuery = new ReadObjectQuery();
 
         readObjectQuery.setReferenceClass(Employee.class);
@@ -1409,7 +1409,7 @@
     }
 
     public void simpleModTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Assert.assertFalse("Warning SQL/Sybase doesnot support MOD function", (JUnitTestCase.getServerSession()).getPlatform().isSQLServer() || (JUnitTestCase.getServerSession()).getPlatform().isSybase());
 
@@ -1442,7 +1442,7 @@
     }
 
     public void simpleIsEmptyTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         ExpressionBuilder builder = new ExpressionBuilder();
         Expression whereClause = builder.isEmpty("phoneNumbers");
@@ -1463,7 +1463,7 @@
     }
 
     public void simpleIsNotEmptyTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         ExpressionBuilder builder = new ExpressionBuilder();
         Expression whereClause = builder.notEmpty("phoneNumbers");
@@ -1485,7 +1485,7 @@
     }
 
     public void simpleApostrohpeTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Vector addresses = em.getActiveSession().readAllObjects(Address.class);
 
@@ -1511,7 +1511,7 @@
     }
 
     public void simpleEscapeUnderscoreTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Address expectedResult = new Address();
         expectedResult.setCity("Perth");
@@ -1541,7 +1541,7 @@
     }
 
     public void smallProjectMemberOfProjectsTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         ReadAllQuery query = new ReadAllQuery();
         Expression selectionCriteria = new ExpressionBuilder().anyOf("projects").equal(new ExpressionBuilder(SmallProject.class));
@@ -1564,7 +1564,7 @@
     }
 
     public void smallProjectNOTMemberOfProjectsTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         //query for those employees with Project named "Enterprise" (which should be
         //a SmallProject)
@@ -1598,7 +1598,7 @@
     //This test demonstrates the bug 4616218, waiting for bug fix
 
     public void selectCountOneToOneTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         ReportQuery query = new ReportQuery();
         query.setReferenceClass(PhoneNumber.class);
@@ -1622,7 +1622,7 @@
     }
 
     public void selectOneToOneTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         ReadAllQuery query = new ReadAllQuery();
         query.setReferenceClass(Address.class);
@@ -1645,7 +1645,7 @@
 
 
     public void selectPhonenumberDeclaredInINClauseTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         ReadAllQuery query = new ReadAllQuery();
         ExpressionBuilder employeeBuilder = new ExpressionBuilder(Employee.class);
@@ -1715,7 +1715,7 @@
      * This test was added to mirror a CTS failure.
      */
     public void selectPhoneUsingALLTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         ReadAllQuery query = new ReadAllQuery();
         ExpressionBuilder employeeBuilder = new ExpressionBuilder(Employee.class);
@@ -1745,7 +1745,7 @@
     }
 
     public void selectSimpleMemberOfWithParameterTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Employee expectedResult = (Employee)em.getActiveSession().readObject(Employee.class);
 
@@ -1781,7 +1781,7 @@
     }
 
     public void selectSimpleNotMemberOfWithParameterTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Vector expectedResult = em.getActiveSession().readAllObjects(Employee.class);
 
@@ -1822,7 +1822,7 @@
 
     public void selectUsingLockModeQueryHintTest() {
         Exception exception = null;
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Vector employees = em.getActiveSession().readAllObjects(Employee.class);
         Employee emp1 = (Employee)employees.lastElement();
@@ -1843,7 +1843,7 @@
     }
 
     public void selectSimpleBetweenWithParameterTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Vector employees = em.getActiveSession().readAllObjects(Employee.class);
 
@@ -1870,7 +1870,7 @@
     }
 
     public void selectSimpleInWithParameterTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         Vector employees = em.getActiveSession().readAllObjects(Employee.class);
 
@@ -1903,7 +1903,7 @@
     //Test case for ABS function in EJBQL
 
     public void simpleEnumTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         String ejbqlString;
 
@@ -1913,7 +1913,7 @@
     }
 
     public void selectNamedNativeQueryWithPositionalParameterTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         List results_QuestionMark_Number = null;
         List results_QuestionMark = null;
@@ -1979,7 +1979,7 @@
     }
 
     public void selectNativeQueryWithPositionalParameterTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         List results_QuestionMark_Number = null;
         List results_QuestionMark = null;
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLValidationTestSuite.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLValidationTestSuite.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLValidationTestSuite.java	(working copy)
@@ -24,7 +24,7 @@
 
 import org.eclipse.persistence.exceptions.*;
 import org.eclipse.persistence.internal.jpa.EntityManagerImpl;
-import org.eclipse.persistence.internal.jpa.base.RepeatableWriteUnitOfWork;
+import org.eclipse.persistence.internal.jpa.RepeatableWriteUnitOfWork;
 import org.eclipse.persistence.mappings.DirectToFieldMapping;
 import org.eclipse.persistence.testing.models.jpa.advanced.Employee;
 import org.eclipse.persistence.testing.models.jpa.advanced.EmployeePopulator;
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLComplexAggregateTestSuite.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLComplexAggregateTestSuite.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLComplexAggregateTestSuite.java	(working copy)
@@ -146,7 +146,7 @@
   
     public void complexAVGTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
                
         ExpressionBuilder expbldr = new ExpressionBuilder();
             
@@ -180,7 +180,7 @@
     public void complexCountDistinctWithGroupByAndHavingTest()
     {
         String havingFilterString = "Toronto";
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
         //Need to set the class in the expressionbuilder, as the Count(Distinct) will cause the 
         // query to change and be built around the Employee class instead of the Address class.
         ExpressionBuilder expbldr = new ExpressionBuilder(Address.class);
@@ -210,7 +210,7 @@
      */
     public void complexCountDistinctWithGroupByTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
         
         //need to set the class in the expressionbuilder, as the Count(Distinct) will cause the 
         // query to change and be built around the Employee class instead of the Address class.  
@@ -238,7 +238,7 @@
      */
     public void complexCountDistinctWithGroupByTest2()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
         
         //need to set the class in the expressionbuilder, as the Count(Distinct) will cause the 
         // query to change and be built around the Employee class instead of the Address class.  
@@ -266,7 +266,7 @@
      */
     public void complexHavingWithAggregate()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         
         // Test using the project id in COUNT, GROUP BY and HAVING
         ExpressionBuilder employeeBuilder = new ExpressionBuilder(Employee.class);
@@ -312,7 +312,7 @@
     
     public void complexCountTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
                
         ExpressionBuilder expbldr = new ExpressionBuilder();
             
@@ -340,7 +340,7 @@
      */
     public void complexCountWithGroupByTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
         //Need to set the class in the expressionbuilder, as the Count(Distinct) will cause the 
         // query to change and be built around the Employee class instead of the Address class.  
         ExpressionBuilder expbldr = new ExpressionBuilder(Address.class);
@@ -363,7 +363,7 @@
     
     public void complexDistinctCountTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
                
         ExpressionBuilder expbldr = new ExpressionBuilder();
             
@@ -388,7 +388,7 @@
     
     public void complexMaxTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
                
         ExpressionBuilder expbldr = new ExpressionBuilder();
             
@@ -408,7 +408,7 @@
     
     public void complexMinTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
                
         ExpressionBuilder expbldr = new ExpressionBuilder();
             
@@ -429,7 +429,7 @@
     
     public void complexSumTest()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();                  
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();                  
                
         ExpressionBuilder expbldr = new ExpressionBuilder();
             
@@ -453,8 +453,8 @@
      */
     public void complexCountDistinctOnBaseQueryClass()
     {
-        org.eclipse.persistence.jpa.EntityManager em = 
-            (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = 
+            (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         
         Long expectedResult = Long.valueOf(em.getActiveSession().readAllObjects(Employee.class).size());
         
@@ -470,8 +470,8 @@
      */
     public void complexCountOnJoinedVariableSimplePK()
     {
-        org.eclipse.persistence.jpa.EntityManager em = 
-            (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = 
+            (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
 
         // Need to create the expected result manually, because using the
         // TopLink query API would run into the same issue 2497.
@@ -499,8 +499,8 @@
      */
     public void complexCountOnJoinedVariableCompositePK()
     {
-        org.eclipse.persistence.jpa.EntityManager em = 
-            (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = 
+            (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
 
         // Need to create the expected result manually, because using the
         // TopLink query API would run into the same issue 2497.
@@ -528,8 +528,8 @@
      */
     public void complexCountOnJoinedCompositePK()
     {
-        org.eclipse.persistence.jpa.EntityManager em = 
-            (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = 
+            (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         try{
             em.getTransaction().begin();
                 Scientist s = new Scientist();
@@ -569,8 +569,8 @@
      */
     public void complexCountOnJoinedVariableOverManyToManySelfRefRelationship()
     {
-        org.eclipse.persistence.jpa.EntityManager em = 
-            (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = 
+            (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
 
         Long zero = Long.valueOf(0);
         List expectedResult = Arrays.asList(new Long[] { zero, zero, zero, zero });
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLExamplesTestSuite.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLExamplesTestSuite.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLExamplesTestSuite.java	(working copy)
@@ -18,7 +18,7 @@
 
 import junit.framework.Assert;
 
-import org.eclipse.persistence.jpa.EntityManager;
+import org.eclipse.persistence.jpa.JpaEntityManager;
 
 import junit.extensions.TestSetup;
 
@@ -153,7 +153,7 @@
     }
 
     public void findAllOrders() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         List expectedResult = em.getActiveSession().readAllObjects(Order.class);
 
         String ejbqlString = "SELECT o FROM OrderBean o";
@@ -164,7 +164,7 @@
     }
 
     public void findEmployeesInOntario() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         ExpressionBuilder builder = new ExpressionBuilder();
         Expression whereClause = builder.get("address").get("province").equal("ONT");
 
@@ -180,7 +180,7 @@
 
     public void findAllProvinceWithEmployees() {
         boolean testPass = false;
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         ExpressionBuilder builder = new ExpressionBuilder();
         Expression whereClause = builder.get("address").get("province");
 
@@ -203,7 +203,7 @@
     }
 
     public void findAllEmployeesWithPhoneNumbers() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         ExpressionBuilder builder = new ExpressionBuilder();
         Expression whereClause = builder.isEmpty("phoneNumbers").not();
 
@@ -225,7 +225,7 @@
     }
 
     public void findAllEmployeesWithOutPhoneNumbers() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         ExpressionBuilder builder = new ExpressionBuilder();
         Expression whereClause = builder.isEmpty("phoneNumbers");
 
@@ -243,7 +243,7 @@
     }
 
     public void findAllEmployeesWithCellPhones() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         ExpressionBuilder builder = new ExpressionBuilder();
         Expression whereClause = builder.anyOf("phoneNumbers").get("type").equal("Cellular");
 
@@ -264,7 +264,7 @@
     }
 
     public void findOrdersWithDifferentBilledCustomer() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         ExpressionBuilder builder = new ExpressionBuilder();
         Expression whereClause = builder.get("customer").equal(builder.get("billedCustomer")).not();
 
@@ -284,7 +284,7 @@
     }
 
     public void findEmployeeWithWorkPhone2258812() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         ExpressionBuilder builder = new ExpressionBuilder();
         Expression whereClause1 = builder.anyOf("phoneNumbers").get("type").equal("Work");
         Expression whereClause2 = builder.anyOf("phoneNumbers").get("number").equal("2258812");
@@ -303,7 +303,7 @@
     }
 
     public void parameterTest() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         List employeeList = em.getActiveSession().readAllObjects(Employee.class);
         Employee expectedEmployee = (Employee)employeeList.get(0);
         int i = 1;
@@ -324,7 +324,7 @@
 
 
     public void getOrderLargerThan() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         ExpressionBuilder builder1 = new ExpressionBuilder(Order.class);
         ExpressionBuilder builder2 = new ExpressionBuilder(Order.class);
@@ -349,7 +349,7 @@
     }
 
     public void getOrderForCustomer() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         ExpressionBuilder builder = new ExpressionBuilder();
         Expression whereClause = builder.get("name").equal("Jane Smith");
 
@@ -371,7 +371,7 @@
     }
 
     public void getSalesPersonForOrders() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         List expectedResult = em.getActiveSession().readAllObjects(SalesPerson.class);
 
@@ -383,7 +383,7 @@
     }
 
     public void testOuterJoin() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         ExpressionBuilder builder = new ExpressionBuilder();
         Expression whereClause = builder.anyOfAllowingNone("phoneNumbers").get("type").equal("Cellular");
         ReadAllQuery raq = new ReadAllQuery(Employee.class);
@@ -401,7 +401,7 @@
     }
 
     public void testExistsExpression() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         boolean testPass = false;
         ExpressionBuilder employeeBuilder = new ExpressionBuilder(Employee.class);
         ExpressionBuilder managerBuilder = new ExpressionBuilder(Employee.class);
@@ -431,7 +431,7 @@
     }
 
     public void testAllExpressions() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         boolean testPass = false;
         ExpressionBuilder mainQueryBuilder = new ExpressionBuilder(Employee.class);
         ExpressionBuilder subQueryBuilder = new ExpressionBuilder(Employee.class);
@@ -460,7 +460,7 @@
     }
 
     public void testCountInSubQuery() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         boolean testPass = false;
         ReportQuery mainQuery = new ReportQuery(Customer.class, new ExpressionBuilder());
         ReportQuery subQuery = new ReportQuery(Order.class, new ExpressionBuilder());
@@ -480,7 +480,7 @@
     }
 
     public void testGroupByHavingExpression() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         boolean testPass = true;
 
         ReadAllQuery raq = new ReadAllQuery(Employee.class, new ExpressionBuilder());
@@ -533,7 +533,7 @@
     }
 
     public void testGroupByHavingCount() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         boolean testPass = true;
         ReportQuery query = new ReportQuery(Employee.class, new ExpressionBuilder());
         query.returnWithoutReportQueryResult();
@@ -563,7 +563,7 @@
     }
 
     public void testConstructorQuery() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         String ejbqlString = "SELECT NEW org.eclipse.persistence.testing.models.jpa.relationships.CustomerDetails(c.customerId, o.quantity) FROM Customer " + "c JOIN c.orders o WHERE o.quantity > 100";
 
         List custDetails = em.createQuery(ejbqlString).getResultList();
@@ -572,7 +572,7 @@
     }
 
     public void testSumExpression() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         ReportQuery query = new ReportQuery(Employee.class, new ExpressionBuilder());
         Expression whereClause = query.getExpressionBuilder().get("address").get("province").equal("QUE");
@@ -586,7 +586,7 @@
     }
 
     public void testAvgExpression() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         ReportQuery query = new ReportQuery(Order.class, new ExpressionBuilder());
         query.addAverage("average quantity", query.getExpressionBuilder().get("quantity"), Double.class);
@@ -600,7 +600,7 @@
     //bug 5166658
 
     public void testCountExpression() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         ReportQuery query = new ReportQuery(Employee.class, new ExpressionBuilder());
         Expression whereClause1 = query.getExpressionBuilder().get("address").get("province").equal("QUE");
@@ -624,7 +624,7 @@
     }
 
     public void testOrderByExpression() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         ReadAllQuery raq = new ReadAllQuery(PhoneNumber.class, new ExpressionBuilder());
         Expression whereClause = raq.getExpressionBuilder().get("owner").get("address").get("province").equal("ONT");
@@ -640,7 +640,7 @@
     }
 
     public void testOrderByExpressionWithSelect() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         boolean testPass = true;
         ReportQuery query = new ReportQuery(PhoneNumber.class, new ExpressionBuilder());
         Expression whereClause = query.getExpressionBuilder().get("owner").get("address").get("province").equal("ONT");
@@ -673,7 +673,7 @@
     }
 
     public void testDeleteExpression() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         try {
             em.getTransaction().begin();
             String orderString = "DELETE FROM OrderBean o WHERE o.customer.name ='Karen McDonald' ";
@@ -703,7 +703,7 @@
     }
 
     public void testComplexDeleteExpression() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         try {
             em.getTransaction().begin();
             String orderString = "DELETE FROM OrderBean o WHERE o.customer.name ='Karen McDonald' ";
@@ -729,7 +729,7 @@
     //bug 5159164, 5159198   
 
     public void testUpdateExpression() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         int result = 0;
         UpdateAllQuery uaq = new UpdateAllQuery(Customer.class, new ExpressionBuilder());
         uaq.addUpdate(uaq.getExpressionBuilder().get("name"), "Test Case");
@@ -754,7 +754,7 @@
     //Bug5097278 Test case for updating the manager of ALL employees that have a certain address 
 
     public void updateAllTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         String empName = "Saunders";
         String manName = "Smitty";
@@ -782,7 +782,7 @@
 
     public void updateEmbeddedFieldTest() {
 
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
         Calendar startCalendar = Calendar.getInstance();
         startCalendar.set(1905, 11, 31, 0, 0, 0);
         java.sql.Date startDate = new java.sql.Date(startCalendar.getTime().getTime());
@@ -796,7 +796,7 @@
     //Bug5040609  Test if EJBQuery makes a clone of the original DatabaseQuery from the session
 
     public void namedQueryCloneTest() {
-        EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         List result1 = em.createNamedQuery("findAllCustomers").getResultList();
 
@@ -812,7 +812,7 @@
     //Bug5040609 Test case for aggregates as parameters in EJBQL
 
     public void aggregateParameterTest() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager)createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager)createEntityManager();
 
         ExpressionBuilder builder = new ExpressionBuilder();
         ReportQuery query = new ReportQuery(org.eclipse.persistence.testing.models.jpa.advanced.Employee.class, builder);
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLUnitTestSuite.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLUnitTestSuite.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLUnitTestSuite.java	(working copy)
@@ -127,7 +127,7 @@
     
     public Vector getAttributeFromAll(String attributeName, Vector objects, Class referenceClass){
 	   
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         
         ClassDescriptor descriptor = em.getActiveSession().getClassDescriptor(referenceClass);
 	    DirectToFieldMapping mapping = (DirectToFieldMapping)descriptor.getMappingForAttributeName(attributeName);
@@ -148,7 +148,7 @@
 	}
     
     public void testFirstResultOnNamedQuery(){
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         clearCache();
 
         Query query = em.createNamedQuery("findAllEmployeesByFirstName");
@@ -167,7 +167,7 @@
     }
     
     public void testOuterJoinOnOneToOne(){
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         clearCache();
         em.getTransaction().begin();
         int initialSize = em.createQuery("SELECT e from Employee e JOIN e.address a").getResultList().size(); 
@@ -182,7 +182,7 @@
     }
 
     public void testOuterJoinPolymorphic(){
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         clearCache();
         List resultList = null;
         try{
@@ -206,7 +206,7 @@
 		rq.addAttribute("areaCode", new ExpressionBuilder().anyOf("phoneNumbers").get("areaCode"));
     	rq.setReferenceClass(Employee.class);    
         rq.dontUseDistinct(); // distinct no longer used on joins in JPQL for gf bug 1395
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         Vector expectedResult = getAttributeFromAll("areaCode", (Vector)em.getActiveSession().executeQuery(rq),Employee.class);
         
         clearCache();
@@ -220,7 +220,7 @@
   
     public void testSelectPhoneNumberAreaCodeWithEmployee()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         ExpressionBuilder employees = new ExpressionBuilder();
         Expression exp = employees.get("firstName").equal("Bob");
         exp = exp.and(employees.get("lastName").equal("Smith"));
@@ -257,7 +257,7 @@
     
     public void testSelectPhoneNumberNumberWithEmployeeWithExplicitJoin()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         ExpressionBuilder employees = new ExpressionBuilder();
         Expression exp = employees.get("firstName").equal("Bob");
         exp = exp.and(employees.get("lastName").equal("Smith"));
@@ -295,7 +295,7 @@
     
     public void testSelectPhoneNumberNumberWithEmployeeWithFirstNameFirst()
     {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         ExpressionBuilder employees = new ExpressionBuilder();
         Expression exp = employees.get("firstName").equal("Bob");
         exp = exp.and(employees.get("lastName").equal("Smith"));
@@ -364,7 +364,7 @@
      * throws an SQl exception.
      */
     public void testMaxAndFirstResultsOnDataQuery(){
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         Exception exception = null;
         List resultList = null;
         clearCache();
@@ -386,7 +386,7 @@
      * throws an SQl exception.
      */
     public void testMaxAndFirstResultsOnDataQueryWithGroupBy() {
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         Exception exception = null;
         List resultList = null;
         clearCache();
@@ -424,7 +424,7 @@
      * For GF3233, Distinct process fail with NPE when relationship has NULL-valued target.
      */
     public void testDistinctSelectForEmployeeWithNullAddress(){
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         try {
             em.getTransaction().begin();
             Employee emp = new Employee();
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLParameterTestSuite.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLParameterTestSuite.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/ejb/ejbqltesting/JUnitJPQLParameterTestSuite.java	(working copy)
@@ -119,7 +119,7 @@
     //Test case for selecting employee from the database using parameters 
     public void multipleParameterTest()
     {          
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
       
         Employee employee = (Employee) (em.getActiveSession().readAllObjects(Employee.class).firstElement());
         Vector expectedResult = new Vector();
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/relationships/IsolatedCacheTestSuite.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/relationships/IsolatedCacheTestSuite.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/relationships/IsolatedCacheTestSuite.java	(working copy)
@@ -14,8 +14,8 @@
 
 import javax.persistence.*;
 
-import org.eclipse.persistence.internal.jpa.base.EntityManagerImpl;
-import org.eclipse.persistence.internal.jpa.base.RepeatableWriteUnitOfWork;
+import org.eclipse.persistence.internal.jpa.RepeatableWriteUnitOfWork;
+import org.eclipse.persistence.internal.jpa.EntityManagerImpl;
 import org.eclipse.persistence.testing.framework.junit.JUnitTestCase;
 import org.eclipse.persistence.testing.models.jpa.relationships.IsolatedItem;
 
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/relationships/ExecuteUpdateTest.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/relationships/ExecuteUpdateTest.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/relationships/ExecuteUpdateTest.java	(working copy)
@@ -9,7 +9,7 @@
  ******************************************************************************/  
 package org.eclipse.persistence.testing.tests.jpa.relationships;
 
-import org.eclipse.persistence.jpa.EntityManager;
+import org.eclipse.persistence.jpa.JpaEntityManager;
 import org.eclipse.persistence.internal.jpa.EntityManagerImpl;
 import org.eclipse.persistence.queries.UpdateAllQuery;
 import org.eclipse.persistence.testing.framework.*;
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/fieldaccess/relationships/IsolatedCacheTestSuite.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/fieldaccess/relationships/IsolatedCacheTestSuite.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/fieldaccess/relationships/IsolatedCacheTestSuite.java	(working copy)
@@ -14,8 +14,8 @@
 
 import javax.persistence.*;
 
-import org.eclipse.persistence.internal.jpa.base.EntityManagerImpl;
-import org.eclipse.persistence.internal.jpa.base.RepeatableWriteUnitOfWork;
+import org.eclipse.persistence.internal.jpa.RepeatableWriteUnitOfWork;
+import org.eclipse.persistence.internal.jpa.EntityManagerImpl;
 import org.eclipse.persistence.testing.framework.junit.JUnitTestCase;
 import org.eclipse.persistence.testing.models.jpa.fieldaccess.relationships.IsolatedItem;
 
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/fieldaccess/relationships/ExecuteUpdateTest.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/fieldaccess/relationships/ExecuteUpdateTest.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/fieldaccess/relationships/ExecuteUpdateTest.java	(working copy)
@@ -9,7 +9,7 @@
  ******************************************************************************/  
 package org.eclipse.persistence.testing.tests.jpa.fieldaccess.relationships;
 
-import org.eclipse.persistence.jpa.EntityManager;
+import org.eclipse.persistence.jpa.JpaEntityManager;
 import org.eclipse.persistence.internal.jpa.EntityManagerImpl;
 import org.eclipse.persistence.queries.UpdateAllQuery;
 import org.eclipse.persistence.testing.framework.*;
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/fieldaccess/advanced/ReportQueryConstructorExpressionTestSuite.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/fieldaccess/advanced/ReportQueryConstructorExpressionTestSuite.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/fieldaccess/advanced/ReportQueryConstructorExpressionTestSuite.java	(working copy)
@@ -93,7 +93,7 @@
         ReportQuery query = new ReportQuery(Employee.class, employees);
         query.addAttribute("firstName");
         query.addAttribute("lastName");
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager("fieldaccess");          
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager("fieldaccess");          
 
         Vector reportResults = (Vector)em.getActiveSession().executeQuery(query);
         
@@ -129,7 +129,7 @@
         ReportQuery query = new ReportQuery(Employee.class, employees);
         query.addAttribute("firstName");
         query.addAttribute("lastName");
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager("fieldaccess");          
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager("fieldaccess");          
 
         Vector reportResults = (Vector)em.getActiveSession().executeQuery(query);
 
@@ -159,7 +159,7 @@
         query.addItem("endDate", employees.get("period").get("endDate"));
         query.addAttribute("id");
 
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager("fieldaccess");          
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager("fieldaccess");          
 
         Vector reportResults = (Vector)em.getActiveSession().executeQuery(query);
         query = new ReportQuery(Employee.class, employees);
@@ -199,7 +199,7 @@
         query.addItem("endDate", employees.get("period").get("endDate"));
         query.addAttribute("id");
         query.endAddingToConstructorItem();
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager("fieldaccess");          
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager("fieldaccess");          
         QueryException exception = null;
         try{
             em.getActiveSession().executeQuery(query);
@@ -214,7 +214,7 @@
         ExpressionBuilder employees = new ExpressionBuilder();
         ReportQuery query = new ReportQuery(Employee.class, employees);
         query.addAttribute("salary");
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager("fieldaccess");          
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager("fieldaccess");          
 
         Vector reportResults = (Vector)em.getActiveSession().executeQuery(query);
 
@@ -252,7 +252,7 @@
         ReportQuery query = new ReportQuery(Employee.class, employees);
         query.addAttribute("firstName");
         query.addAttribute("lastName");
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager("fieldaccess");          
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager("fieldaccess");          
 
         Vector reportResults = (Vector)em.getActiveSession().executeQuery(query);
 
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/fieldaccess/advanced/EntityManagerJUnitTestSuite.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/fieldaccess/advanced/EntityManagerJUnitTestSuite.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/fieldaccess/advanced/EntityManagerJUnitTestSuite.java	(working copy)
@@ -54,7 +54,6 @@
 import org.eclipse.persistence.exceptions.ValidationException;
 import org.eclipse.persistence.tools.schemaframework.OracleSequenceDefinition;
 import org.eclipse.persistence.exceptions.QueryException;
-import org.eclipse.persistence.jpa.EJBQuery;
 import org.eclipse.persistence.expressions.Expression;
 import org.eclipse.persistence.expressions.ExpressionBuilder;
 import org.eclipse.persistence.sessions.Session;
@@ -181,7 +180,7 @@
         em.getTransaction().begin();
         List result = em.createQuery("SELECT OBJECT(e) FROM Employee e").getResultList();
         em.getTransaction().commit();
-        Object obj = ((org.eclipse.persistence.jpa.EntityManager)em).getServerSession().getIdentityMapAccessor().getFromIdentityMap(result.get(0));
+        Object obj = ((org.eclipse.persistence.jpa.JpaEntityManager)em).getServerSession().getIdentityMapAccessor().getFromIdentityMap(result.get(0));
         assertTrue("Failed to load the object into the shared cache when there were no changes in the UOW", obj != null);
         try{
             em.getTransaction().begin();
@@ -2274,7 +2273,7 @@
         em.getTransaction().commit();
         em.clear();
 
-        EJBQuery query = (EJBQuery)em.createQuery("SELECT e FROM Employee e WHERE e.lastName = 'Malone' order by e.firstName");
+        org.eclipse.persistence.jpa.JpaQuery query = (org.eclipse.persistence.jpa.JpaQuery)em.createQuery("SELECT e FROM Employee e WHERE e.lastName = 'Malone' order by e.firstName");
         query.setHint(EclipseLinkQueryHints.BATCH, "e.phoneNumbers");
         query.setHint(EclipseLinkQueryHints.BATCH, "e.manager.phoneNumbers");
         
@@ -2360,7 +2359,7 @@
         em.getTransaction().commit();
         em.clear();
 
-        EJBQuery query = (EJBQuery)em.createQuery("SELECT e FROM Employee e WHERE e.lastName = 'Malone' order by e.firstName");
+        org.eclipse.persistence.jpa.JpaQuery query = (org.eclipse.persistence.jpa.JpaQuery)em.createQuery("SELECT e FROM Employee e WHERE e.lastName = 'Malone' order by e.firstName");
         query.setHint(EclipseLinkQueryHints.FETCH, "e.manager");
         ReadAllQuery raq = (ReadAllQuery)query.getDatabaseQuery();
         List expressions = raq.getJoinedAttributeExpressions();
@@ -2494,7 +2493,7 @@
 
     // test for GlassFish bug 711 - throw a descriptive exception when an uninstantiated valueholder is serialized and then accessed
     public void testSerializedLazy(){
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager("fieldaccess");      
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager("fieldaccess");      
        
         em.getTransaction().begin();
         
@@ -2510,7 +2509,7 @@
         em.getTransaction().commit();
         em.close();
         clearCache("fieldaccess");
-        em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager("fieldaccess");
+        em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager("fieldaccess");
         String ejbqlString = "SELECT e FROM Employee e WHERE e.firstName = 'Owen' and e.lastName = 'Hargreaves'";
         List result = em.createQuery(ejbqlString).getResultList();
         emp = (Employee)result.get(0);
@@ -3975,7 +3974,7 @@
     // gf2074: EM.clear throws NPE (JTA case)
     public void testClearEntityManagerWithoutPersistenceContextSimulateJTA() {
         EntityManager em = createEntityManager("fieldaccess");
-        ServerSession ss = ((org.eclipse.persistence.jpa.EntityManager)em).getServerSession();
+        ServerSession ss = ((org.eclipse.persistence.jpa.JpaEntityManager)em).getServerSession();
         em.close();
         // in non-JTA case session doesn't have external transaction controller
         boolean hasExternalTransactionController = ss.hasExternalTransactionController();
@@ -4015,7 +4014,7 @@
             em.persist(emp);
             em.flush();
             
-            Query ejbQuery = ((org.eclipse.persistence.jpa.EntityManager)em).createDescriptorNamedQuery("findByFNameLName", Employee.class);
+            Query ejbQuery = ((org.eclipse.persistence.jpa.JpaEntityManager)em).createDescriptorNamedQuery("findByFNameLName", Employee.class);
             
             List results = ejbQuery.setParameter("fName", "Melvin").setParameter("lName", "Malone").getResultList();
             
@@ -4060,7 +4059,7 @@
             Vector args = new Vector(2);
             args.addElement(String.class);
             args.addElement(String.class);
-            Query ejbQuery = ((org.eclipse.persistence.jpa.EntityManager)em).createDescriptorNamedQuery("findEmployees", Employee.class, args);
+            Query ejbQuery = ((org.eclipse.persistence.jpa.JpaEntityManager)em).createDescriptorNamedQuery("findEmployees", Employee.class, args);
             
             List results = ejbQuery.setParameter("fName", "Melvin").setParameter("lName", "Malone").getResultList();
             
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMPersistAndFlushTest.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMPersistAndFlushTest.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMPersistAndFlushTest.java	(working copy)
@@ -10,7 +10,7 @@
 package org.eclipse.persistence.testing.tests.jpa.advanced;
 
 import java.util.*;
-import org.eclipse.persistence.jpa.EntityManager;
+import org.eclipse.persistence.jpa.JpaEntityManager;
 import org.eclipse.persistence.testing.framework.TestErrorException;
 import org.eclipse.persistence.testing.framework.TestWarningException;
 import org.eclipse.persistence.testing.models.jpa.advanced.*;
@@ -59,7 +59,7 @@
             
             getEntityManager().flush();
             //lets initialize the identity map to make sure they were persisted
-            ((EntityManager)getEntityManager()).getServerSession().getIdentityMapAccessor().initializeAllIdentityMaps();
+            ((JpaEntityManager)getEntityManager()).getServerSession().getIdentityMapAccessor().initializeAllIdentityMaps();
             getEntityManager().clear();
 
             persistedItems.put("after flush Employee", getEntityManager().find(Employee.class, empIDs[0]));
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/ReportQueryConstructorExpressionTestSuite.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/ReportQueryConstructorExpressionTestSuite.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/ReportQueryConstructorExpressionTestSuite.java	(working copy)
@@ -93,7 +93,7 @@
         ReportQuery query = new ReportQuery(Employee.class, employees);
         query.addAttribute("firstName");
         query.addAttribute("lastName");
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();          
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();          
 
         Vector reportResults = (Vector)em.getActiveSession().executeQuery(query);
         
@@ -129,7 +129,7 @@
         ReportQuery query = new ReportQuery(Employee.class, employees);
         query.addAttribute("firstName");
         query.addAttribute("lastName");
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();          
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();          
 
         Vector reportResults = (Vector)em.getActiveSession().executeQuery(query);
 
@@ -159,7 +159,7 @@
         query.addItem("endDate", employees.get("period").get("endDate"));
         query.addAttribute("id");
 
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();          
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();          
 
         Vector reportResults = (Vector)em.getActiveSession().executeQuery(query);
         query = new ReportQuery(Employee.class, employees);
@@ -199,7 +199,7 @@
         query.addItem("endDate", employees.get("period").get("endDate"));
         query.addAttribute("id");
         query.endAddingToConstructorItem();
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();          
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();          
         QueryException exception = null;
         try{
             em.getActiveSession().executeQuery(query);
@@ -214,7 +214,7 @@
         ExpressionBuilder employees = new ExpressionBuilder();
         ReportQuery query = new ReportQuery(Employee.class, employees);
         query.addAttribute("salary");
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();          
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();          
 
         Vector reportResults = (Vector)em.getActiveSession().executeQuery(query);
 
@@ -252,7 +252,7 @@
         ReportQuery query = new ReportQuery(Employee.class, employees);
         query.addAttribute("firstName");
         query.addAttribute("lastName");
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();          
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();          
 
         Vector reportResults = (Vector)em.getActiveSession().executeQuery(query);
 
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMMultipleFlushTests.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMMultipleFlushTests.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMMultipleFlushTests.java	(working copy)
@@ -10,7 +10,7 @@
 package org.eclipse.persistence.testing.tests.jpa.advanced;
 
 import java.util.*;
-import org.eclipse.persistence.jpa.EntityManager;
+import org.eclipse.persistence.jpa.JpaEntityManager;
 import org.eclipse.persistence.internal.jpa.EntityManagerImpl;
 import org.eclipse.persistence.testing.framework.*;
 import org.eclipse.persistence.testing.models.jpa.advanced.*;
@@ -179,7 +179,7 @@
         }
             
         //lets initialize the identity map to make sure they were persisted
-        ((EntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
+        ((JpaEntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
             
         employee = (Employee)getEntityManager().find(Employee.class, empIDs[1]);
         if ( (!employee.getLastName().equals("Fourlang"))){
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMRemoveAndFlushTest.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMRemoveAndFlushTest.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMRemoveAndFlushTest.java	(working copy)
@@ -10,7 +10,7 @@
 package org.eclipse.persistence.testing.tests.jpa.advanced;
 
 import java.util.HashMap;
-import org.eclipse.persistence.jpa.EntityManager;
+import org.eclipse.persistence.jpa.JpaEntityManager;
 import org.eclipse.persistence.testing.framework.TestErrorException;
 import org.eclipse.persistence.testing.models.jpa.advanced.*;
 import org.eclipse.persistence.testing.tests.jpa.EntityContainerTestBase;
@@ -57,7 +57,7 @@
             
             getEntityManager().flush();
             //lets initialize the identity map to make sure they were persisted
-            ((EntityManager)getEntityManager()).getServerSession().getIdentityMapAccessor().initializeAllIdentityMaps();
+            ((JpaEntityManager)getEntityManager()).getServerSession().getIdentityMapAccessor().initializeAllIdentityMaps();
             getEntityManager().clear(); //lear em as well or they will continue to be managed
 
             persistedItems.put("after flush Employee", getEntityManager().find(Employee.class, empIDs[0]));
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMCascadingPersistAndCommitTest.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMCascadingPersistAndCommitTest.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMCascadingPersistAndCommitTest.java	(working copy)
@@ -10,7 +10,7 @@
 package org.eclipse.persistence.testing.tests.jpa.advanced;
 
 import java.util.*;
-import org.eclipse.persistence.jpa.EntityManager;
+import org.eclipse.persistence.jpa.JpaEntityManager;
 import org.eclipse.persistence.testing.framework.TestErrorException;
 import org.eclipse.persistence.testing.models.jpa.advanced.*;
 import org.eclipse.persistence.testing.tests.jpa.EntityContainerTestBase;
@@ -62,7 +62,7 @@
         }
         
         //lets initialize the identity map to make sure they were persisted
-        ((EntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
+        ((JpaEntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
 
         emp = (Employee) getEntityManager().find(Employee.class, empIDs[0]);
         if (emp == null){
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMModifyAndRefreshTest.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMModifyAndRefreshTest.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMModifyAndRefreshTest.java	(working copy)
@@ -9,7 +9,7 @@
  ******************************************************************************/  
 package org.eclipse.persistence.testing.tests.jpa.advanced;
 
-import org.eclipse.persistence.jpa.EntityManager;
+import org.eclipse.persistence.jpa.JpaEntityManager;
 import org.eclipse.persistence.testing.framework.TestErrorException;
 import org.eclipse.persistence.testing.models.jpa.advanced.*;
 import org.eclipse.persistence.testing.tests.jpa.EntityContainerTestBase;
@@ -83,7 +83,7 @@
         }
         
         //lets initialize the identity map to make sure they were persisted
-        ((EntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
+        ((JpaEntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
 
         employee = getEntityManager().find(Employee.class, empIDs[0]);
         if(employee.getFirstName().equals("Tobin")) {
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMModifyAndMergeTest.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMModifyAndMergeTest.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMModifyAndMergeTest.java	(working copy)
@@ -9,7 +9,7 @@
  ******************************************************************************/  
 package org.eclipse.persistence.testing.tests.jpa.advanced;
 
-import org.eclipse.persistence.jpa.EntityManager;
+import org.eclipse.persistence.jpa.JpaEntityManager;
 import org.eclipse.persistence.testing.framework.TestErrorException;
 import org.eclipse.persistence.testing.models.jpa.advanced.*;
 import org.eclipse.persistence.testing.tests.jpa.CMP3TestModel;
@@ -91,7 +91,7 @@
         }
         
         //lets initialize the identity map to make sure they were persisted
-        ((EntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
+        ((JpaEntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
 
         employee = getEntityManager().find(Employee.class, empIDs[0]);
         if(!employee.getFirstName().equals("Ivy")) {
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMCascadingRemoveAndFlushTest.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMCascadingRemoveAndFlushTest.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMCascadingRemoveAndFlushTest.java	(working copy)
@@ -10,7 +10,7 @@
 package org.eclipse.persistence.testing.tests.jpa.advanced;
 
 import java.util.*;
-import org.eclipse.persistence.jpa.EntityManager;
+import org.eclipse.persistence.jpa.JpaEntityManager;
 import org.eclipse.persistence.testing.framework.TestErrorException;
 import org.eclipse.persistence.testing.models.jpa.advanced.*;
 import org.eclipse.persistence.testing.tests.jpa.EntityContainerTestBase;
@@ -58,7 +58,7 @@
 
             getEntityManager().flush();
             //lets initialize the identity map to make sure they were persisted
-            ((EntityManager)getEntityManager()).getServerSession().getIdentityMapAccessor().initializeAllIdentityMaps();
+            ((JpaEntityManager)getEntityManager()).getServerSession().getIdentityMapAccessor().initializeAllIdentityMaps();
             getEntityManager().clear();
 
             persistedItems.put("after flush Employee", getEntityManager().find(Employee.class, empIDs[0]));
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMModifyAndCommitTest.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMModifyAndCommitTest.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMModifyAndCommitTest.java	(working copy)
@@ -11,7 +11,7 @@
 
 import java.sql.Date;
 import java.util.*;
-import org.eclipse.persistence.jpa.EntityManager;
+import org.eclipse.persistence.jpa.JpaEntityManager;
 import org.eclipse.persistence.internal.jpa.EntityManagerImpl;
 import org.eclipse.persistence.testing.framework.*;
 import org.eclipse.persistence.testing.models.jpa.advanced.*;
@@ -236,7 +236,7 @@
         }
         
         //lets initialize the identity map to make sure they were persisted
-        ((EntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
+        ((JpaEntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
             
         employee = getEntityManager().find(Employee.class, empIDs[0]);
         if ( (!employee.getFirstName().equals("Wilfred"))){
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMPersistAndCommitTest.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMPersistAndCommitTest.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMPersistAndCommitTest.java	(working copy)
@@ -9,7 +9,7 @@
  ******************************************************************************/  
 package org.eclipse.persistence.testing.tests.jpa.advanced;
 
-import org.eclipse.persistence.jpa.EntityManager;
+import org.eclipse.persistence.jpa.JpaEntityManager;
 import org.eclipse.persistence.testing.framework.TestErrorException;
 import org.eclipse.persistence.testing.models.jpa.advanced.*;
 import org.eclipse.persistence.testing.tests.jpa.EntityContainerTestBase;
@@ -151,7 +151,7 @@
         }
 
         //lets initialize the identity map to make sure they were persisted
-        ((EntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
+        ((JpaEntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
         
         emp = getEntityManager().find(Employee.class, empIDs[0]);
         if (emp == null){
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMCascadingModifyAndRefreshTest.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMCascadingModifyAndRefreshTest.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMCascadingModifyAndRefreshTest.java	(working copy)
@@ -9,7 +9,7 @@
  ******************************************************************************/  
 package org.eclipse.persistence.testing.tests.jpa.advanced;
 
-import org.eclipse.persistence.jpa.EntityManager;
+import org.eclipse.persistence.jpa.JpaEntityManager;
 import org.eclipse.persistence.testing.framework.TestErrorException;
 import org.eclipse.persistence.testing.models.jpa.advanced.*;
 import org.eclipse.persistence.testing.tests.jpa.EntityContainerTestBase;
@@ -77,7 +77,7 @@
         }
         
         //lets initialize the identity map to make sure they were persisted
-        ((EntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
+        ((JpaEntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
 
         employee = getEntityManager().find(Employee.class, empIDs[0]);
         if(employee.getFirstName().equals("Tobin")) {
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMCascadingModifyAndMergeTest.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMCascadingModifyAndMergeTest.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMCascadingModifyAndMergeTest.java	(working copy)
@@ -9,7 +9,7 @@
  ******************************************************************************/  
 package org.eclipse.persistence.testing.tests.jpa.advanced;
 
-import org.eclipse.persistence.jpa.EntityManager;
+import org.eclipse.persistence.jpa.JpaEntityManager;
 import org.eclipse.persistence.testing.framework.TestErrorException;
 import org.eclipse.persistence.testing.models.jpa.advanced.*;
 import org.eclipse.persistence.testing.tests.jpa.CMP3TestModel;
@@ -84,7 +84,7 @@
         }
         
         //lets initialize the identity map to make sure they were persisted
-        ((EntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
+        ((JpaEntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
 
         employee = getEntityManager().find(Employee.class, empIDs[0]);
         if(!employee.getFirstName().equals("Ivy")) {
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMRemoveAndPersistTest.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMRemoveAndPersistTest.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMRemoveAndPersistTest.java	(working copy)
@@ -9,7 +9,7 @@
  ******************************************************************************/  
 package org.eclipse.persistence.testing.tests.jpa.advanced;
 
-import org.eclipse.persistence.jpa.EntityManager;
+import org.eclipse.persistence.jpa.JpaEntityManager;
 import org.eclipse.persistence.testing.framework.TestErrorException;
 import org.eclipse.persistence.testing.models.jpa.advanced.*;
 import org.eclipse.persistence.testing.tests.jpa.EntityContainerTestBase;
@@ -75,7 +75,7 @@
         }
 
         //lets initialize the identity map to make sure they were persisted
-        ((EntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
+        ((JpaEntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
 
         employee = getEntityManager().find(Employee.class, empIDs[0]);
         if(employee == null) {
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EntityManagerJUnitTestSuite.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EntityManagerJUnitTestSuite.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EntityManagerJUnitTestSuite.java	(working copy)
@@ -54,7 +54,6 @@
 import org.eclipse.persistence.exceptions.ValidationException;
 import org.eclipse.persistence.tools.schemaframework.OracleSequenceDefinition;
 import org.eclipse.persistence.exceptions.QueryException;
-import org.eclipse.persistence.jpa.EJBQuery;
 import org.eclipse.persistence.expressions.Expression;
 import org.eclipse.persistence.expressions.ExpressionBuilder;
 import org.eclipse.persistence.sessions.Session;
@@ -232,7 +231,7 @@
         em.getTransaction().begin();
         List result = em.createQuery("SELECT OBJECT(e) FROM Employee e").getResultList();
         em.getTransaction().commit();
-        Object obj = ((org.eclipse.persistence.jpa.EntityManager)em).getServerSession().getIdentityMapAccessor().getFromIdentityMap(result.get(0));
+        Object obj = ((org.eclipse.persistence.jpa.JpaEntityManager)em).getServerSession().getIdentityMapAccessor().getFromIdentityMap(result.get(0));
         assertTrue("Failed to load the object into the shared cache when there were no changes in the UOW", obj != null);
         try{
             em.getTransaction().begin();
@@ -2339,7 +2338,7 @@
         em.getTransaction().commit();
         em.clear();
 
-        EJBQuery query = (EJBQuery)em.createQuery("SELECT e FROM Employee e WHERE e.lastName = 'Malone' order by e.firstName");
+        org.eclipse.persistence.jpa.JpaQuery query = (org.eclipse.persistence.jpa.JpaQuery)em.createQuery("SELECT e FROM Employee e WHERE e.lastName = 'Malone' order by e.firstName");
         query.setHint(EclipseLinkQueryHints.BATCH, "e.phoneNumbers");
         query.setHint(EclipseLinkQueryHints.BATCH, "e.manager.phoneNumbers");
         
@@ -2425,7 +2424,7 @@
         em.getTransaction().commit();
         em.clear();
 
-        EJBQuery query = (EJBQuery)em.createQuery("SELECT e FROM Employee e WHERE e.lastName = 'Malone' order by e.firstName");
+        org.eclipse.persistence.jpa.JpaQuery query = (org.eclipse.persistence.jpa.JpaQuery)em.createQuery("SELECT e FROM Employee e WHERE e.lastName = 'Malone' order by e.firstName");
         query.setHint(EclipseLinkQueryHints.FETCH, "e.manager");
         ReadAllQuery raq = (ReadAllQuery)query.getDatabaseQuery();
         List expressions = raq.getJoinedAttributeExpressions();
@@ -2559,7 +2558,7 @@
 
     // test for GlassFish bug 711 - throw a descriptive exception when an uninstantiated valueholder is serialized and then accessed
     public void testSerializedLazy(){
-        org.eclipse.persistence.jpa.EntityManager em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();      
+        org.eclipse.persistence.jpa.JpaEntityManager em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();      
        
         em.getTransaction().begin();
         
@@ -2575,7 +2574,7 @@
         em.getTransaction().commit();
         em.close();
         clearCache();
-        em = (org.eclipse.persistence.jpa.EntityManager) createEntityManager();
+        em = (org.eclipse.persistence.jpa.JpaEntityManager) createEntityManager();
         String ejbqlString = "SELECT e FROM Employee e WHERE e.firstName = 'Owen' and e.lastName = 'Hargreaves'";
         List result = em.createQuery(ejbqlString).getResultList();
         emp = (Employee)result.get(0);
@@ -4173,7 +4172,7 @@
     // gf2074: EM.clear throws NPE (JTA case)
     public void testClearEntityManagerWithoutPersistenceContextSimulateJTA() {
         EntityManager em = createEntityManager();
-        ServerSession ss = ((org.eclipse.persistence.jpa.EntityManager)em).getServerSession();
+        ServerSession ss = ((org.eclipse.persistence.jpa.JpaEntityManager)em).getServerSession();
         em.close();
         // in non-JTA case session doesn't have external transaction controller
         boolean hasExternalTransactionController = ss.hasExternalTransactionController();
@@ -4213,7 +4212,7 @@
             em.persist(emp);
             em.flush();
             
-            Query ejbQuery = ((org.eclipse.persistence.jpa.EntityManager)em).createDescriptorNamedQuery("findByFNameLName", Employee.class);
+            Query ejbQuery = ((org.eclipse.persistence.jpa.JpaEntityManager)em).createDescriptorNamedQuery("findByFNameLName", Employee.class);
             
             List results = ejbQuery.setParameter("fName", "Melvin").setParameter("lName", "Malone").getResultList();
             
@@ -4258,7 +4257,7 @@
             Vector args = new Vector(2);
             args.addElement(String.class);
             args.addElement(String.class);
-            Query ejbQuery = ((org.eclipse.persistence.jpa.EntityManager)em).createDescriptorNamedQuery("findEmployees", Employee.class, args);
+            Query ejbQuery = ((org.eclipse.persistence.jpa.JpaEntityManager)em).createDescriptorNamedQuery("findEmployees", Employee.class, args);
             
             List results = ejbQuery.setParameter("fName", "Melvin").setParameter("lName", "Malone").getResultList();
             
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMCascadingPersistAndFlushTest.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMCascadingPersistAndFlushTest.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMCascadingPersistAndFlushTest.java	(working copy)
@@ -10,7 +10,7 @@
 package org.eclipse.persistence.testing.tests.jpa.advanced;
 
 import java.util.*;
-import org.eclipse.persistence.jpa.EntityManager;
+import org.eclipse.persistence.jpa.JpaEntityManager;
 import org.eclipse.persistence.testing.framework.TestErrorException;
 import org.eclipse.persistence.testing.models.jpa.advanced.*;
 import org.eclipse.persistence.testing.tests.jpa.EntityContainerTestBase;
@@ -79,7 +79,7 @@
             
             getEntityManager().flush();
             //lets initialize the identity map to make sure they were persisted
-            ((EntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
+            ((JpaEntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
 
             persistedItems.put("after flush Employee", getEntityManager().find(Employee.class, empIDs[0]));
             persistedItems.put("after flush Project", getEntityManager().find(Project.class, projIDs[0]));
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMRemoveAndCommitTests.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMRemoveAndCommitTests.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMRemoveAndCommitTests.java	(working copy)
@@ -10,7 +10,7 @@
 package org.eclipse.persistence.testing.tests.jpa.advanced;
 
 import java.util.*;
-import org.eclipse.persistence.jpa.EntityManager;
+import org.eclipse.persistence.jpa.JpaEntityManager;
 import org.eclipse.persistence.internal.jpa.EntityManagerImpl;
 import org.eclipse.persistence.testing.framework.*;
 import org.eclipse.persistence.testing.models.jpa.advanced.*;
@@ -145,7 +145,7 @@
             }
         }
         //lets initialize the identity map to make sure they were persisted
-        ((EntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
+        ((JpaEntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
 
         employee = getEntityManager().find(Employee.class, empIDs[1]);
         if ( employee != null){
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMModifyAndFlushTest.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMModifyAndFlushTest.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMModifyAndFlushTest.java	(working copy)
@@ -14,7 +14,7 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-import org.eclipse.persistence.jpa.EntityManager;
+import org.eclipse.persistence.jpa.JpaEntityManager;
 import org.eclipse.persistence.internal.jpa.EntityManagerImpl;
 import org.eclipse.persistence.testing.framework.*;
 import org.eclipse.persistence.testing.models.jpa.advanced.*;
@@ -92,7 +92,7 @@
 
             getEntityManager().flush();
             //lets initialize the identity map to make sure they were persisted
-            ((EntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
+            ((JpaEntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
 
             persistedItems.put("after flush Employee 0", getEntityManager().find(Employee.class, empIDs[0]));
 
@@ -114,7 +114,7 @@
 
             getEntityManager().flush();
             //lets initialize the identity map to make sure they were persisted
-            ((EntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
+            ((JpaEntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
 
             persistedItems.put("after flush Employee 1", getEntityManager().find(Employee.class, empIDs[1]));
 
@@ -144,7 +144,7 @@
 
             getEntityManager().flush();
             //lets initialize the identity map to make sure they were persisted
-            ((EntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
+            ((JpaEntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
 
             persistedItems.put("after flush Employee 2", getEntityManager().find(Employee.class, empIDs[2]));
 
@@ -167,7 +167,7 @@
 
             getEntityManager().flush();
             //lets initialize the identity map to make sure they were persisted
-            ((EntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
+            ((JpaEntityManager)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
 
             persistedItems.put("after flush Employees 0 with raise", getEntityManager().find(Employee.class, empIDs[0]));
             persistedItems.put("after flush Employees 1 with raise", getEntityManager().find(Employee.class, empIDs[1]));
Index: C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/jpaadvancedproperties/JPAAdvPropertiesJUnitTestCase.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/jpaadvancedproperties/JPAAdvPropertiesJUnitTestCase.java	(revision 2919)
+++ C:/Work/eclipse/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/jpaadvancedproperties/JPAAdvPropertiesJUnitTestCase.java	(working copy)
@@ -74,7 +74,7 @@
     public void testSessionEventListenerProperty() {
         
         EntityManager em = createEntityManager(persistenceUnitName);
-        org.eclipse.persistence.sessions.server.ServerSession session = ((org.eclipse.persistence.jpa.EntityManager)em.getDelegate()).getServerSession();
+        org.eclipse.persistence.sessions.server.ServerSession session = ((org.eclipse.persistence.jpa.JpaEntityManager)em.getDelegate()).getServerSession();
         try {
             //Create new customer
             em.getTransaction().begin();
@@ -130,7 +130,7 @@
 
     public void testExceptionHandlerProperty() {
         EntityManager em = createEntityManager(persistenceUnitName);
-        org.eclipse.persistence.sessions.server.ServerSession session = ((org.eclipse.persistence.jpa.EntityManager)em.getDelegate()).getServerSession();
+        org.eclipse.persistence.sessions.server.ServerSession session = ((org.eclipse.persistence.jpa.JpaEntityManager)em.getDelegate()).getServerSession();
         Expression exp = new ExpressionBuilder().get("name1").equal("George W.");
         try {
             Object result = session.readObject(Customer.class, exp);
@@ -144,7 +144,7 @@
     
     public void testNativeSQLProperty() {
         EntityManager em = createEntityManager(persistenceUnitName);
-        org.eclipse.persistence.sessions.server.ServerSession session = ((org.eclipse.persistence.jpa.EntityManager)em.getDelegate()).getServerSession();
+        org.eclipse.persistence.sessions.server.ServerSession session = ((org.eclipse.persistence.jpa.JpaEntityManager)em.getDelegate()).getServerSession();
         if(!session.getProject().getLogin().shouldUseNativeSQL()){
             assertTrue("The native sql flag specified as true by the property eclipselink.jdbc.native-sql in persistence.xml, it however read as false.", true);
         }
@@ -153,7 +153,7 @@
     
     public void testBatchwritingProperty(){
         EntityManager em = createEntityManager(persistenceUnitName);
-        org.eclipse.persistence.sessions.server.ServerSession session = ((org.eclipse.persistence.jpa.EntityManager)em.getDelegate()).getServerSession();
+        org.eclipse.persistence.sessions.server.ServerSession session = ((org.eclipse.persistence.jpa.JpaEntityManager)em.getDelegate()).getServerSession();
         
         if(!(session.getPlatform().usesBatchWriting() && 
            !session.getPlatform().usesJDBCBatchWriting() &&
@@ -165,7 +165,7 @@
     
     public void testCopyDescriptorNamedQueryToSessionProperty(){
         EntityManager em = createEntityManager(persistenceUnitName);
-        org.eclipse.persistence.sessions.server.ServerSession session = ((org.eclipse.persistence.jpa.EntityManager)em.getDelegate()).getServerSession();
+        org.eclipse.persistence.sessions.server.ServerSession session = ((org.eclipse.persistence.jpa.JpaEntityManager)em.getDelegate()).getServerSession();
         org.eclipse.persistence.queries.DatabaseQuery query = session.getQuery("customerReadByName");
         if(query == null){
             assertTrue("The copy descriptor named query is enable by the property eclipselink.session.include.descriptor.queries in persistence.xml, one descriptor named query has not been copied to the session", true);
@@ -175,7 +175,7 @@
     
     public void testCacheStatementsAndItsSizeProperty() {
         EntityManager em = createEntityManager(persistenceUnitName);
-        org.eclipse.persistence.sessions.server.ServerSession session = ((org.eclipse.persistence.jpa.EntityManager)em.getDelegate()).getServerSession();
+        org.eclipse.persistence.sessions.server.ServerSession session = ((org.eclipse.persistence.jpa.JpaEntityManager)em.getDelegate()).getServerSession();
         if(session.getConnectionPools().size()>0){//And if connection pooling is configured,
             if(!session.getProject().getLogin().shouldCacheAllStatements()){
                 assertTrue("Caching all statements flag set equals to true by property eclipselink.jdbc.cache-statements in persistence.xml, it however read as false.", true);
@@ -190,7 +190,7 @@
     
     public void testLoggingTyperProperty(){
         EntityManager em = createEntityManager(persistenceUnitName);
-        org.eclipse.persistence.sessions.server.ServerSession session = ((org.eclipse.persistence.jpa.EntityManager)em.getDelegate()).getServerSession();
+        org.eclipse.persistence.sessions.server.ServerSession session = ((org.eclipse.persistence.jpa.JpaEntityManager)em.getDelegate()).getServerSession();
         if(!(session.getSessionLog() instanceof org.eclipse.persistence.logging.JavaLog)){
             assertTrue("Logging type set to JavaLog, it however has been detected as different type logger.", true);
         }
Index: C:/Work/eclipse/eclipselink.core/src/org/eclipse/persistence/jpa/config/PersistenceUnitProperties.java
===================================================================
--- C:/Work/eclipse/eclipselink.core/src/org/eclipse/persistence/jpa/config/PersistenceUnitProperties.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.core/src/org/eclipse/persistence/jpa/config/PersistenceUnitProperties.java	(working copy)
@@ -9,6 +9,7 @@
  ******************************************************************************/  
 package org.eclipse.persistence.jpa.config;
 
+import java.io.File;
 import java.util.Map;
 import java.util.HashMap;
 
@@ -263,6 +264,33 @@
         PROPERTY_LOG_OVERRIDES.put(JDBC_PASSWORD, "xxxxxx");
     }
     
+    public static final String TOPLINK_ORM_THROW_EXCEPTIONS = "eclipselink.orm.throw.exceptions";
+    public static final String TOPLINK_VALIDATION_ONLY_PROPERTY = "eclipselink.validation-only";
+
+    public static final String DDL_GENERATION   = "eclipselink.ddl-generation";
+    
+    public static final String CREATE_ONLY      = "create-tables";
+    public static final String DROP_AND_CREATE  = "drop-and-create-tables";
+    public static final String NONE             = "none";
+    
+    public static final String APP_LOCATION     = "eclipselink.application-location";
+    
+    public static final String CREATE_JDBC_DDL_FILE = "eclipselink.create-ddl-jdbc-file-name";
+    public static final String DROP_JDBC_DDL_FILE   = "eclipselink.drop-ddl-jdbc-file-name";
+    
+    public static final String DEFAULT_APP_LOCATION = "." + File.separator;
+    public static final String DEFAULT_CREATE_JDBC_FILE_NAME = "createDDL.jdbc";
+    public static final String DEFAULT_DROP_JDBC_FILE_NAME = "dropDDL.jdbc";
+    public static final String JAVASE_DB_INTERACTION = "INTERACT_WITH_DB";    
+    
+    public static final String DDL_GENERATION_MODE = "eclipselink.ddl-generation.output-mode";
+    public static final String DDL_SQL_SCRIPT_GENERATION = "sql-script";
+    public static final String DDL_DATABASE_GENERATION = "database";
+    public static final String DDL_BOTH_GENERATION = "both";
+    // This is the default for now to ensure we still play nicely with Glassfish.
+    public static final String DEFAULT_DDL_GENERATION_MODE = DDL_SQL_SCRIPT_GENERATION;
+    
+    
     /** INTERNAL: Return the overridden log string. */
     public static final String getOverriddenLogStringForProperty(String propertyName){
         return PROPERTY_LOG_OVERRIDES.get(propertyName);
Index: C:/Work/eclipse/eclipselink.core/src/org/eclipse/persistence/internal/localization/i18n/ExceptionLocalizationResource.java
===================================================================
--- C:/Work/eclipse/eclipselink.core/src/org/eclipse/persistence/internal/localization/i18n/ExceptionLocalizationResource.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.core/src/org/eclipse/persistence/internal/localization/i18n/ExceptionLocalizationResource.java	(working copy)
@@ -101,7 +101,12 @@
                                            { "ejb30-wrong-query-hint-value", "Query {0}, query hint {1} has illegal value {2}."},
                                            { "ejb30-wrong-type-for-query-hint", "Query {0}, query hint {1} is not valid for this type of query."},
                                            { "ejb30-default-for-unknown-property", "Can't return default value for unknown property {0}."},
-                                           { "ejb30-illegal-property-value", "Property {0} has an illegal value {1}."}
+                                           { "ejb30-illegal-property-value", "Property {0} has an illegal value {1}."},
+                                           
+                                           { "jpa_helper_invalid_report_query", "The query of type {0} is not an EclipseLink report query and therefore, could not be converted."},
+                                           { "jpa_helper_invalid_read_all_query", "The query of type {0} is not an EclipseLink read all query and therefore, could not be converted."},
+                                           { "jpa_helper_invalid_query", "The query of type {0} is not an EclipseLink query and therefore, could not be converted."},
+                                           { "jpa_helper_invalid_entity_manager_factory", "The JPA entity manager factory {0} is not an EclipseLink entity manager factory and therefore, could not be converted."}
     };
 
     /**
Index: C:/Work/eclipse/eclipselink.core/src/org/eclipse/persistence/internal/sessions/UnitOfWorkIdentityMapAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.core/src/org/eclipse/persistence/internal/sessions/UnitOfWorkIdentityMapAccessor.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.core/src/org/eclipse/persistence/internal/sessions/UnitOfWorkIdentityMapAccessor.java	(working copy)
@@ -11,7 +11,7 @@
 
 import java.util.*;
 import org.eclipse.persistence.descriptors.ClassDescriptor;
-import org.eclipse.persistence.internal.jpa.base.RepeatableWriteUnitOfWork;
+import org.eclipse.persistence.internal.jpa.RepeatableWriteUnitOfWork;
 import org.eclipse.persistence.internal.identitymaps.*;
 import org.eclipse.persistence.internal.sessions.IdentityMapAccessor;
 import org.eclipse.persistence.expressions.*;
Index: C:/Work/eclipse/eclipselink.core/src/org/eclipse/persistence/internal/jpa/RepeatableWriteUnitOfWork.java
===================================================================
--- C:/Work/eclipse/eclipselink.core/src/org/eclipse/persistence/internal/jpa/RepeatableWriteUnitOfWork.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.core/src/org/eclipse/persistence/internal/jpa/RepeatableWriteUnitOfWork.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.base;
+package org.eclipse.persistence.internal.jpa;
 
 import java.util.Enumeration;
 import java.util.IdentityHashMap;
Index: C:/Work/eclipse/eclipselink.core/src/org/eclipse/persistence/internal/jpa/base/RepeatableWriteUnitOfWork.java
===================================================================
--- C:/Work/eclipse/eclipselink.core/src/org/eclipse/persistence/internal/jpa/base/RepeatableWriteUnitOfWork.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.core/src/org/eclipse/persistence/internal/jpa/base/RepeatableWriteUnitOfWork.java	(working copy)
@@ -1,407 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.base;
-
-import java.util.Enumeration;
-import java.util.IdentityHashMap;
-import java.util.Iterator;
-
-import org.eclipse.persistence.descriptors.ClassDescriptor;
-import org.eclipse.persistence.internal.descriptors.DescriptorIterator;
-import org.eclipse.persistence.internal.helper.IdentityHashtable;
-import org.eclipse.persistence.internal.localization.ExceptionLocalization;
-import org.eclipse.persistence.internal.sessions.UnitOfWorkImpl;
-import org.eclipse.persistence.exceptions.DatabaseException;
-import org.eclipse.persistence.exceptions.OptimisticLockException;
-import org.eclipse.persistence.internal.sessions.MergeManager;
-import org.eclipse.persistence.internal.sessions.UnitOfWorkChangeSet;
-import org.eclipse.persistence.internal.sessions.ObjectChangeSet;
-import org.eclipse.persistence.mappings.ForeignReferenceMapping;
-
-
-public class RepeatableWriteUnitOfWork extends UnitOfWorkImpl {
-    
-    /** Used to store the final UnitOfWorkChangeSet for merge into the shared cache */
-    protected UnitOfWorkChangeSet cumulativeUOWChangeSet;
-    /** Used to store objects already deleted from the db and unregistered */
-    protected IdentityHashtable unregisteredDeletedObjectsCloneToBackupAndOriginal;
-    
-    /** Used to determine if UnitOfWork should commit and rollback transactions 
-     * This is used when an EntityTransaction is controlling the transaction
-     */
-    protected boolean shouldTerminateTransaction;
-    
-    /** Used to determine if UnitOfWork.synchronizeAndResume method should
-     * resume (the normal behaviour); or alternatively clear the UnitOfWork.
-     */
-    protected boolean shouldClearForCloseInsteadOfResume = false;
-    
-    public RepeatableWriteUnitOfWork(org.eclipse.persistence.internal.sessions.AbstractSession parentSession){
-        super(parentSession);
-        this.shouldTerminateTransaction = true;
-        this.shouldNewObjectsBeCached = true;
-    }
-    
-    /**
-     * INTERNAL:
-     * Call this method if the uow will no longer used for comitting transactions:
-     * all the changes sets will be dereferenced, and (optionally) the cache cleared.
-     * If the uow is not released, but rather kept around for ValueHolders, then identity maps shouldn't be cleared:
-     * the parameter value should be 'false'. The lifecycle set to Birth so that uow ValueHolder still could be used.
-     * Alternatively, if called from release method then everything should go and therefore parameter value should be 'true'.
-     * In this case lifecycle won't change - uow.release (optionally) calls this method when it (uow) is already dead.
-     * The reason for calling this method from release is to free maximum memory right away:
-     * the uow might still be referenced by objects using UOWValueHolders (though they shouldn't be around
-     * they still might).
-     */
-    public void clearForClose(boolean shouldClearCache){
-        super.clearForClose(shouldClearCache);
-        this.cumulativeUOWChangeSet = null;
-        this.unregisteredDeletedObjectsCloneToBackupAndOriginal = null;
-    }
-    
-    /**
-     * INTERNAL:
-     * Indicates whether clearForClose methor should be called by release method.
-     */
-    public boolean shouldClearForCloseOnRelease() {
-        return true;
-    }
-    
-    /**
-     * INTERNAL:
-     * Commit the changes to any objects to the parent.
-     */
-    public void commitRootUnitOfWork() throws DatabaseException, OptimisticLockException {
-        commitToDatabaseWithChangeSet(false);
-        // unit of work has been committed so it's ok to set the cumulative into the UOW for merge
-        if(this.cumulativeUOWChangeSet != null) {
-            this.cumulativeUOWChangeSet.mergeUnitOfWorkChangeSet((UnitOfWorkChangeSet)this.getUnitOfWorkChangeSet(), this, true);
-            setUnitOfWorkChangeSet(this.cumulativeUOWChangeSet);
-        }
-
-        commitTransactionAfterWriteChanges(); // this method will commit the transaction
-                                              // and set the transaction flags appropriately
-
-        // Merge after commit	
-        mergeChangesIntoParent();
-    }
-
-    /**
-     * INTERNAL:
-     * Traverse the object to find references to objects not registered in this unit of work.
-     */
-    public void discoverUnregisteredNewObjects(IdentityHashtable clones, final IdentityHashtable knownNewObjects, final IdentityHashtable unregisteredExistingObjects, final IdentityHashtable visitedObjects) {
-        // This define an inner class for process the itteration operation, don't be scared, its just an inner class.
-        DescriptorIterator iterator = new DescriptorIterator() {
-            public void iterate(Object object) {
-                // If the object is read-only the do not continue the traversal.
-                if (isClassReadOnly(object.getClass(), this.getCurrentDescriptor())) {
-                    this.setShouldBreak(true);
-                    return;
-                }
-                
-                /* CR3440: Steven Vo
-                 * Include the case that object is original then do nothing.
-                 */
-                if (isSmartMerge() && isOriginalNewObject(object)) {
-                    return;
-                } else if (!isObjectRegistered(object)) { // Don't need to check for aggregates, as iterator does not iterate on them by default.
-                    if (checkForUnregisteredExistingObject(object)) { // Always ignore unregistered existing objects in JPA.
-                        // If the object exists we need to keep a record of this object to ignore it,
-                        // also need to stop iterating over it.
-                        unregisteredExistingObjects.put(object, object);
-                        this.setShouldBreak(true);
-                        return;
-                    } else {
-                        // This means it is a unregistered new object, only persist it if cascading, otherwise throw error.
-                        if ((getCurrentMapping() instanceof ForeignReferenceMapping) && ((ForeignReferenceMapping)getCurrentMapping()).isCascadePersist()) {
-                            ((RepeatableWriteUnitOfWork)getSession()).registerNewObjectForPersist(object, visitedObjects);
-                            knownNewObjects.put(object, object);
-                        } else {
-                            throw new IllegalStateException(ExceptionLocalization.buildMessage("new_object_found_during_commit", new Object[]{object}));
-                        }
-                    }
-                }
-            }
-        };
-
-        // Set the collection in the UnitofWork to be this list.
-        setUnregisteredExistingObjects(unregisteredExistingObjects);
-
-        iterator.setVisitedObjects(visitedObjects);
-        iterator.setResult(knownNewObjects);
-        iterator.setSession(this);
-        // When using wrapper policy in EJB the iteration should stop on beans,
-        // this is because EJB forces beans to be registered anyway and clone identity can be violated
-        // and the violated clones references to session objects should not be traversed.
-        iterator.setShouldIterateOverWrappedObjects(false);
-        
-        for (Enumeration clonesEnum = clones.keys(); clonesEnum.hasMoreElements(); ) {        
-            iterator.startIterationOn(clonesEnum.nextElement());
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     * Has writeChanges() been attempted on this UnitOfWork?  It may have
-     * either suceeded or failed but either way the UnitOfWork is in a highly
-     * restricted state.
-     */
-    public boolean isAfterWriteChangesButBeforeCommit() {
-        //dont' check for writechanges failure.
-        return (getLifecycle() == CommitTransactionPending);
-    }
-
-    /**
-     * INTERNAL:
-     * Return if the object has been deleted in this unit of work.
-     */
-    public boolean isObjectDeleted(Object object) {
-        if(super.isObjectDeleted(object)) {
-            return true;
-        } else {
-            if(unregisteredDeletedObjectsCloneToBackupAndOriginal != null) {
-                if(unregisteredDeletedObjectsCloneToBackupAndOriginal.containsKey(object)) {
-                    return true;
-                }
-            }
-            if (hasObjectsDeletedDuringCommit()) {
-                return getObjectsDeletedDuringCommit().containsKey(object);
-            } else {
-                return false;
-            }
-        }
-    }
-
-    /**
-     * INTERNAL:
-     * For synchronized units of work, dump SQL to database
-     */
-    public void issueSQLbeforeCompletion() {
-
-        super.issueSQLbeforeCompletion(false);
-
-        if (this.cumulativeUOWChangeSet != null && this.getUnitOfWorkChangeSet() != null){
-            // unit of work has been committed so it's ok to set the cumulative into the UOW for merge
-            this.cumulativeUOWChangeSet.mergeUnitOfWorkChangeSet((UnitOfWorkChangeSet)this.getUnitOfWorkChangeSet(), this, true);
-            setUnitOfWorkChangeSet(this.cumulativeUOWChangeSet);
-        }
-
-        commitTransactionAfterWriteChanges(); // this method will commit the transaction
-                                              // and set the transaction flags appropriately
-    }
-    
-    /**
-     * INTERNAL:
-     * Merge the attributes of the clone into the unit of work copy.
-     */
-    public Object mergeCloneWithReferences(Object rmiClone, MergeManager manager) {
-        Object mergedObject = super.mergeCloneWithReferences(rmiClone, manager);
-        
-        //iterate over new objects, assign sequences and put in the identitymap
-        IdentityHashMap itable = manager.getMergedNewObjects();
-        Iterator i = itable.values().iterator();
-        while ( i.hasNext() ){
-            Object newObjectClone = i.next();
-            assignSequenceNumber(newObjectClone);
-            registerNewObjectInIdentityMap(newObjectClone, null);
-        }
-        
-        return mergedObject;
-    }
-
-    /**
-     * INTERNAL:
-     * This method is used internally to update the tracked objects if required
-     */
-    public void updateChangeTrackersIfRequired(Object objectToWrite, ObjectChangeSet changeSetToWrite, UnitOfWorkImpl uow, ClassDescriptor descriptor) {
-        descriptor.getObjectChangePolicy().updateWithChanges(objectToWrite, changeSetToWrite, uow, descriptor);
-    }
-
-    /**
-     * INTERNAL:
-     * This method will cause the all of the tracked objects at this level to have
-     * their changes written to the database.  It will then decrement the depth
-     * level.
-     */
-    public void writeChanges() {
-            if (unregisteredDeletedObjectsCloneToBackupAndOriginal == null) {
-                unregisteredDeletedObjectsCloneToBackupAndOriginal = new IdentityHashtable(2);
-            }
-            if (getUnitOfWorkChangeSet() == null) {
-                setUnitOfWorkChangeSet(new UnitOfWorkChangeSet());
-            }
-            // This also assigns sequence numbers and discover unregistered new objects.
-            calculateChanges(getCloneMapping(), (UnitOfWorkChangeSet)getUnitOfWorkChangeSet(), true);
-            // Write those changes to the database.
-            UnitOfWorkChangeSet changeSet = (UnitOfWorkChangeSet)getUnitOfWorkChangeSet();
-            if (!changeSet.hasChanges() && !changeSet.hasForcedChanges() && ! this.hasDeletedObjects() && ! this.hasModifyAllQueries()){
-            	return;
-            }
-            try {
-                commitToDatabaseWithPreBuiltChangeSet(changeSet, false);
-                writesCompleted();
-            } catch (RuntimeException exception) {
-                setLifecycle(WriteChangesFailed);
-                throw exception;
-            }
-
-            Enumeration enumtr = getNewObjectsCloneToOriginal().keys();
-            while (enumtr.hasMoreElements()) {
-                Object clone = enumtr.nextElement();
-                Object original = getNewObjectsCloneToOriginal().get(clone);
-                if (original != null) {
-                    // No longer new to this unit of work, so need to store original.
-                    getCloneToOriginals().put(clone, original);
-                }
-            }
-            getNewObjectsCloneToOriginal().clear();
-            getNewObjectsOriginalToClone().clear();
-            
-            // bug 4730595: fix puts deleted objects in the UnitOfWorkChangeSet as they are removed.
-            getDeletedObjects().clear();
-            // Unregister all deleted objects,
-            // keep them along with their original and backup values in unregisteredDeletedObjectsCloneToBackupAndOriginal.
-            Enumeration enumDeleted = getObjectsDeletedDuringCommit().keys();
-            while (enumDeleted.hasMoreElements()) {
-                Object deletedObject = enumDeleted.nextElement();
-                Object[] backupAndOriginal = {getCloneMapping().get(deletedObject), getCloneToOriginals().get(deletedObject)};
-                unregisteredDeletedObjectsCloneToBackupAndOriginal.put(deletedObject, backupAndOriginal);
-                unregisterObject(deletedObject);
-            }
-            getObjectsDeletedDuringCommit().clear();
-
-            if (this.cumulativeUOWChangeSet == null) {
-                this.cumulativeUOWChangeSet = (UnitOfWorkChangeSet)getUnitOfWorkChangeSet();
-            } else {
-                // Merge those changes back into the backup clones and the final uowChangeSet.
-                this.cumulativeUOWChangeSet.mergeUnitOfWorkChangeSet((UnitOfWorkChangeSet)getUnitOfWorkChangeSet(), this, true);
-            }
-            // Clean up, new objects are now existing.
-            setUnitOfWorkChangeSet(new UnitOfWorkChangeSet());
-        }
-
-    /**
-     * INTERNAL:
-     * Called only by registerNewObjectForPersist method,
-     * and only if newObject is not already registered.
-     * If newObject is found in
-     * unregisteredDeletedObjectsCloneToBackupAndOriginal then it's re-registered,
-     * otherwise the superclass method called.
-     */
-    protected void registerNotRegisteredNewObjectForPersist(Object newObject, ClassDescriptor descriptor) {
-        if(unregisteredDeletedObjectsCloneToBackupAndOriginal != null) {
-            Object[] backupAndOriginal = (Object[])unregisteredDeletedObjectsCloneToBackupAndOriginal.remove(newObject);
-            if(backupAndOriginal != null) {
-                // backup
-                getCloneMapping().put(newObject, backupAndOriginal[0]);
-                // original
-                registerNewObjectClone(newObject, backupAndOriginal[1]);
-
-                // Check if the new objects should be cached.
-                registerNewObjectInIdentityMap(newObject, newObject);
-                
-                return;
-            }
-        }
-        super.registerNotRegisteredNewObjectForPersist(newObject, descriptor);
-    }
-
-    /**
-     * INTERNAL:
-     * This is internal to the uow, transactions should not be used explictly in a uow.
-     * The uow shares its parents transactions.
-     */
-    public void rollbackTransaction() throws DatabaseException {
-        if (this.shouldTerminateTransaction || getParent().getTransactionMutex().isNested()){
-            super.rollbackTransaction();
-        }else{
-            //rollback called which means txn failed.
-            //but rollback was stopped by entitytransaction which means the
-            //transaction will want to call release later.  Make sure release
-            //will rollback transaction.
-            setWasTransactionBegunPrematurely(true);
-        }
-    }
-
-    /**
-     * INTERNAL
-     * Synchronize the clones and update their backup copies.
-     * Called after commit and commit and resume.
-     */
-    public void synchronizeAndResume() {
-        if(this.shouldClearForCloseInsteadOfResume()) {
-            this.clearForClose(false);
-        } else {
-            this.cumulativeUOWChangeSet = null;
-            this.unregisteredDeletedObjectsCloneToBackupAndOriginal = null;
-            super.synchronizeAndResume();
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     * Called only by UnitOfWorkIdentityMapAccessor.getAndCloneCacheKeyFromParent method.
-     * Return unregisteredDeletedClone corresponding to the passed original, or null
-     */
-    public Object getUnregisteredDeletedCloneForOriginal(Object original) {
-        if(unregisteredDeletedObjectsCloneToBackupAndOriginal != null) {
-            Enumeration keys = unregisteredDeletedObjectsCloneToBackupAndOriginal.keys();
-            Enumeration values = unregisteredDeletedObjectsCloneToBackupAndOriginal.elements();
-            while(keys.hasMoreElements()) {
-                Object deletedObjectClone = keys.nextElement();
-                Object[] backupAndOriginal = (Object[])values.nextElement();
-                Object currentOriginal = backupAndOriginal[1];
-                if(original == currentOriginal) {
-                    return deletedObjectClone;
-                }
-            }
-        }
-        return null;
-    }
-    
-  /**
-   * INTERNAL:
-   * Wraps the org.eclipse.persistence.exceptions.OptimisticLockException in a  
-   * javax.persistence.OptimisticLockException. This conforms to the EJB3 specs
-   * @param commitTransaction 
-   */
-    protected void commitToDatabase(boolean commitTransaction) {
-        try {
-            super.commitToDatabase(commitTransaction);
-        } catch (org.eclipse.persistence.exceptions.OptimisticLockException ole) {
-            throw new javax.persistence.OptimisticLockException(ole);
-        }
-    }
-
-    /**
-     * INTERNAL:
-     * This is internal to the uow, transactions should not be used explictly in a uow.
-     * The uow shares its parents transactions.
-     */
-    public void commitTransaction() throws DatabaseException {
-        if (this.shouldTerminateTransaction || getParent().getTransactionMutex().isNested()){
-            super.commitTransaction();
-        }
-    }
-
-    public void setShouldTerminateTransaction(boolean shouldTerminateTransaction) {
-        this.shouldTerminateTransaction = shouldTerminateTransaction;
-    }
-    
-    public void setShouldClearForCloseInsteadOfResume(boolean shouldClearForCloseInsteadOfResume) {
-        this.shouldClearForCloseInsteadOfResume = shouldClearForCloseInsteadOfResume;
-    }
-
-    public boolean shouldClearForCloseInsteadOfResume() {
-        return shouldClearForCloseInsteadOfResume;
-    }
-}
Index: C:/Work/eclipse/eclipselink.core/src/org/eclipse/persistence/queries/DoesExistQuery.java
===================================================================
--- C:/Work/eclipse/eclipselink.core/src/org/eclipse/persistence/queries/DoesExistQuery.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.core/src/org/eclipse/persistence/queries/DoesExistQuery.java	(working copy)
@@ -178,8 +178,8 @@
                 
                 if (!invalid){
                     Object objectFromCache = cacheKey.getObject();
-                    if ((session instanceof org.eclipse.persistence.internal.jpa.base.RepeatableWriteUnitOfWork)&&
-                            (((org.eclipse.persistence.internal.jpa.base.RepeatableWriteUnitOfWork)session).getUnregisteredDeletedCloneForOriginal(objectFromCache)!=null)){
+                    if ((session instanceof org.eclipse.persistence.internal.jpa.RepeatableWriteUnitOfWork)&&
+                            (((org.eclipse.persistence.internal.jpa.RepeatableWriteUnitOfWork)session).getUnregisteredDeletedCloneForOriginal(objectFromCache)!=null)){
                   //session.isUnitOfWork() && objectFromCache!=null && ((UnitOfWorkImpl)session).isObjectDeleted(objectFromCache)){
                         if(shouldCheckCacheForDoesExist()){
                             return Boolean.FALSE;
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/jpa/PersistenceProvider.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/jpa/PersistenceProvider.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/jpa/PersistenceProvider.java	(working copy)
@@ -7,16 +7,168 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-
 package org.eclipse.persistence.jpa;
 
-import org.eclipse.persistence.jpa.EntityManagerFactoryProvider;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
 
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.spi.ClassTransformer;
+import javax.persistence.spi.PersistenceUnitInfo;
+
+import org.eclipse.persistence.exceptions.PersistenceUnitLoadingException;
+import org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl;
+import org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider;
+import org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl;
+import org.eclipse.persistence.internal.jpa.JavaSECMPInitializer;
+import org.eclipse.persistence.internal.jpa.PersistenceInitializationActivator;
+import org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor;
+import org.eclipse.persistence.internal.jpa.deployment.SEPersistenceUnitInfo;
+
 /**
  * This is the TopLink EJB 3.0 provider
  */
-public class PersistenceProvider extends EntityManagerFactoryProvider {
+public class PersistenceProvider implements javax.persistence.spi.PersistenceProvider, PersistenceInitializationActivator {
 
+	/**
+	 * Called by Persistence class when an EntityManagerFactory
+	 * is to be created.
+	 *
+	 * @param emName The name of the persistence unit
+	 * @param map A Map of properties for use by the
+	 * persistence provider. These properties may be used to
+	 * override the values of the corresponding elements in
+	 * the persistence.xml file or specify values for
+	 * properties not specified in the persistence.xml.
+	 * @return EntityManagerFactory for the persistence unit,
+	 * or null if the provider is not the right provider
+	 */
+	public EntityManagerFactory createEntityManagerFactory(String emName, Map properties){
+		Map nonNullProperties = (properties == null) ? new HashMap() : properties;
+	    String name = emName;
+	    if (name == null){
+	    	name = "";
+	    }
+
+	    JavaSECMPInitializer initializer = JavaSECMPInitializer.getJavaSECMPInitializer();
+	    EntityManagerSetupImpl emSetupImpl = null;
+	    ClassLoader currentLoader = Thread.currentThread().getContextClassLoader();
+
+	    try {
+	    	Enumeration<URL> resources = currentLoader.getResources("META-INF/persistence.xml");
+	        boolean initialized = false;
+	        while (resources.hasMoreElements()) {
+	        	URL url = PersistenceUnitProcessor.computePURootURL(resources.nextElement());
+	            String urlAndName = url + name;
+	            
+	            synchronized (EntityManagerFactoryProvider.emSetupImpls){
+	            	emSetupImpl = EntityManagerFactoryProvider.getEntityManagerSetupImpl(urlAndName);
+	                if (emSetupImpl == null || emSetupImpl.isUndeployed()){
+	                	if (!initialized) {
+	                		initializer.initialize(nonNullProperties, this);
+	                        initialized = true;
+	                	}
+	                        
+	                    emSetupImpl = EntityManagerFactoryProvider.getEntityManagerSetupImpl(urlAndName);
+	                }
+	            }
+
+	            // We found a match, stop looking.
+	            if (emSetupImpl != null) {
+	            	break;
+	            }
+	        }
+	    } catch (Exception e){
+	    	throw PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(currentLoader, e);
+	    }
+
+	    //gf bug 854  Returns null if EntityManagerSetupImpl for the name doesn't exist (e.g. a non-existant PU)
+	    if (emSetupImpl == null) {
+	    	return null;
+	    }
+	        
+	    if (!isPersistenceProviderSupported(emSetupImpl.getPersistenceUnitInfo().getPersistenceProviderClassName())){
+	    	return null;
+	    }
+
+	    // synchronized to prevent overriding of the class loader
+	    // and also calls to predeploy and undeploy by other threads -
+	    // the latter may alter result of shouldRedeploy method.
+	    synchronized(emSetupImpl) {
+	    	if(emSetupImpl.shouldRedeploy()) {
+	    		SEPersistenceUnitInfo persistenceInfo = (SEPersistenceUnitInfo)emSetupImpl.getPersistenceUnitInfo();
+	            persistenceInfo.setClassLoader(JavaSECMPInitializer.getMainLoader());
+	            if (emSetupImpl.isUndeployed()){
+	            	persistenceInfo.setNewTempClassLoader(JavaSECMPInitializer.getMainLoader());
+	            }
+	    	}
+	        // call predeploy
+	        // this will just increment the factory count since we should already be deployed
+	        emSetupImpl.predeploy(emSetupImpl.getPersistenceUnitInfo(), nonNullProperties);
+	    }
+	        
+	    EntityManagerFactoryImpl factory = null;
+	    try {
+	    	factory = new EntityManagerFactoryImpl(emSetupImpl, nonNullProperties);
+	    
+	        // This code has been added to allow validation to occur without actually calling createEntityManager
+	        if (emSetupImpl.shouldGetSessionOnCreateFactory(nonNullProperties)) {
+	        	factory.getServerSession();
+	        }
+	        return factory;
+	    } catch (RuntimeException ex) {
+	    	if(factory != null) {
+	    		factory.close();
+	        } else {
+	        	emSetupImpl.undeploy();
+	        }
+	        throw ex;
+	    }
+	}
+
+	/**
+	 * Called by the container when an EntityManagerFactory
+	 * is to be created.
+	 *
+	 * @param info Metadata for use by the persistence provider
+	 * @return EntityManagerFactory for the persistence unit
+	 * specified by the metadata
+	 * @param map A Map of integration-level properties for use
+	 * by the persistence provider.
+	 */
+	public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info, Map properties){
+		Map nonNullProperties = (properties == null) ? new HashMap() : properties;
+	    EntityManagerSetupImpl emSetupImpl = null;
+	    synchronized (EntityManagerFactoryProvider.emSetupImpls) {
+	    	String urlAndName = info.getPersistenceUnitRootUrl() + info.getPersistenceUnitName();
+	        emSetupImpl = EntityManagerFactoryProvider.getEntityManagerSetupImpl(urlAndName);
+	        if (emSetupImpl == null){
+	        	emSetupImpl = new EntityManagerSetupImpl();
+	            emSetupImpl.setIsInContainerMode(true);        
+	            EntityManagerFactoryProvider.addEntityManagerSetupImpl(urlAndName, emSetupImpl);
+	        }
+	    }
+	        
+	    ClassTransformer transformer = null;
+	    if(!emSetupImpl.isDeployed()) {
+	    	transformer = emSetupImpl.predeploy(info, nonNullProperties);
+	    }
+	    if (transformer != null){
+	    	info.addTransformer(transformer);
+	    }
+	    // When EntityManagerFactory is created, the session is only partially created
+	    // When the factory is actually accessed, the emSetupImpl will be used to complete the session construction
+	    EntityManagerFactoryImpl factory = new EntityManagerFactoryImpl(emSetupImpl, nonNullProperties);
+
+	    // This code has been added to allow validation to occur without actually calling createEntityManager
+	    if (emSetupImpl.shouldGetSessionOnCreateFactory(nonNullProperties)) {
+	    	factory.getServerSession();
+	    }
+	    return factory;
+	}
+
     /**
      * Returns whether the given persistence provider class is supported by this implementation
      * @param providerClassName
@@ -25,5 +177,4 @@
     public boolean isPersistenceProviderSupported(String providerClassName){
         return (providerClassName == null) || providerClassName.equals("") || providerClassName.equals(PersistenceProvider.class.getName());
     }
-
 }
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/jpa/JpaQuery.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/jpa/JpaQuery.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/jpa/JpaQuery.java	(revision 0)
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 1998, 2007 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ *     Oracle - initial API and implementation from Oracle TopLink
+ ******************************************************************************/  
+package org.eclipse.persistence.jpa;
+
+import java.util.Collection;
+import org.eclipse.persistence.queries.DatabaseQuery;
+
+/**
+ * PUBLIC:
+ * TopLInk specific EJB 3.0 query interface.  Provides the functionality defined in
+ * javax.persistence.Query and adds access to the underlying database query for TopLink specific
+ * functionality.
+ */
+public interface JpaQuery extends javax.persistence.Query {
+
+    /**
+     * PUBLIC:
+     * Return the cached database query for this EJBQueryImpl.  If the query is
+     * a named query and it has not yet been looked up, the query will be looked up
+     * and stored as the cached query.
+     */
+    public DatabaseQuery getDatabaseQuery();
+
+    /**
+     * PUBLIC:
+     * return the EntityManager for this query
+     */
+    public JpaEntityManager getEntityManager();
+
+    /**
+     * PUBLIC:
+     * Non-standard method to return results of a ReadQuery that has a containerPoliry
+     * that returns objects as a collection rather than a List
+     * @return Collection of results
+     */
+    public Collection getResultCollection();
+
+    /**
+     * PUBLIC:
+     * Replace the cached query with the given query.
+     */
+    public void setDatabaseQuery(DatabaseQuery query);
+
+}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/jpa/JpaEntityManager.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/jpa/JpaEntityManager.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/jpa/JpaEntityManager.java	(working copy)
@@ -25,7 +25,7 @@
  * @author Gordon Yorke
  */
 
-public interface EntityManager extends javax.persistence.EntityManager {
+public interface JpaEntityManager extends javax.persistence.EntityManager {
 
 	/**
 	 * This method returns the current session to the requestor.  The current session
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/jpa/EJBQuery.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/jpa/EJBQuery.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/jpa/EJBQuery.java	(working copy)
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.jpa;
-
-import java.util.Collection;
-import org.eclipse.persistence.queries.DatabaseQuery;
-
-/**
- * PUBLIC:
- * TopLInk specific EJB 3.0 query interface.  Provides the functionality defined in
- * javax.persistence.Query and adds access to the underlying database query for TopLink specific
- * functionality.
- */
-public interface EJBQuery extends javax.persistence.Query {
-
-    /**
-     * PUBLIC:
-     * Return the cached database query for this EJBQueryImpl.  If the query is
-     * a named query and it has not yet been looked up, the query will be looked up
-     * and stored as the cached query.
-     */
-    public DatabaseQuery getDatabaseQuery();
-
-    /**
-     * PUBLIC:
-     * return the EntityManager for this query
-     */
-    public EntityManager getEntityManager();
-
-    /**
-     * PUBLIC:
-     * Non-standard method to return results of a ReadQuery that has a containerPoliry
-     * that returns objects as a collection rather than a List
-     * @return Collection of results
-     */
-    public Collection getResultCollection();
-
-    /**
-     * PUBLIC:
-     * Replace the cached query with the given query.
-     */
-    public void setDatabaseQuery(DatabaseQuery query);
-
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/jpa/EntityManager.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/jpa/EntityManager.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/jpa/EntityManager.java	(working copy)
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.jpa;
-
-import java.util.Vector;
-
-import org.eclipse.persistence.sessions.*;
-import org.eclipse.persistence.expressions.Expression;
-import org.eclipse.persistence.sessions.server.ServerSession;
-
-/**
- * <p>
- * <b>Purpose</b>: Defines the Interface for TopLink extensions to the EntityManager
- * <p>
- * @see javax.persistence.EntityManager
- */
-/*
- * @author Gordon Yorke
- */
-
-public interface EntityManager extends javax.persistence.EntityManager {
-
-	/**
-	 * This method returns the current session to the requestor.  The current session
-	 * will be a the active UnitOfWork within a transaction and will be a 'scrap'
-	 * UnitOfWork outside of a transaction.  The caller is conserned about the results
-	 * then the getSession() or getUnitOfWork() API should be called.
-	 */
-    public Session getActiveSession();
-    
-    /**
-     * Return the underlying server session
-     */
-    public ServerSession getServerSession();
-    
-    /**
-     * This method will return the transactional UnitOfWork during the transaction and null
-     * outside of the transaction.
-     */
-    public UnitOfWork getUnitOfWork();
-    
-    /**
-     * This method will return a Session outside of a transaction and null within a transaction.
-     */
-    public Session getSession();
-    
-    /**
-     * This method is used to create a query using a Toplink Expression and the return type.
-     */
-    public javax.persistence.Query createQuery(Expression expression, Class resultType);
-    
-    /**
-     * This method will create a query object that wraps a TopLink Named Query.
-     */
-    public javax.persistence.Query createDescriptorNamedQuery(String queryName, Class descriptorClass);
-    
-    /**
-     * This method will create a query object that wraps a TopLink Named Query.
-     */
-    public javax.persistence.Query createDescriptorNamedQuery(String queryName, Class descriptorClass, Vector argumentTypes);
-
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/jpa/EntityManagerFactoryProvider.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/jpa/EntityManagerFactoryProvider.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/jpa/EntityManagerFactoryProvider.java	(working copy)
@@ -1,502 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.jpa;
-
-import java.io.File;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.Map;
-import java.util.HashMap;
-import javax.persistence.*;
-import javax.persistence.spi.*;
-
-import org.eclipse.persistence.jpa.config.TargetDatabase;
-import org.eclipse.persistence.jpa.config.PersistenceUnitProperties;
-import org.eclipse.persistence.exceptions.PersistenceUnitLoadingException;
-import org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl;
-import org.eclipse.persistence.internal.jpa.JavaSECMPInitializer;
-import org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl;
-import org.eclipse.persistence.internal.jpa.PersistenceInitializationActivator;
-import org.eclipse.persistence.internal.sessions.AbstractSession;
-import org.eclipse.persistence.logging.SessionLog;
-import org.eclipse.persistence.sessions.server.ServerSession;
-
-import org.eclipse.persistence.tools.schemaframework.SchemaManager;
-import org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor;
-import org.eclipse.persistence.internal.jpa.deployment.SEPersistenceUnitInfo;
-
-/**
- * This is the TopLink EJB 3.0 provider
- * The default constructor can be used to build the provider by reflection, after which it can
- * be used to create EntityManagerFactories
- */
-
-public class EntityManagerFactoryProvider implements javax.persistence.spi.PersistenceProvider, PersistenceInitializationActivator {
-
-    // The following constants are used in persistence xml or in createSessionManagerFactory methods to specify properties.
-    // Many property declarations were moved to org.eclipse.persistence.jpa.config.PersistenceUnitProperties class.
-
-    public static final String TOPLINK_ORM_THROW_EXCEPTIONS = "eclipselink.orm.throw.exceptions";
-    public static final String TOPLINK_VALIDATION_ONLY_PROPERTY = "eclipselink.validation-only";
-
-    public static final String DDL_GENERATION   = "eclipselink.ddl-generation";
-    
-    public static final String CREATE_ONLY      = "create-tables";
-    public static final String DROP_AND_CREATE  = "drop-and-create-tables";
-    public static final String NONE             = "none";
-    
-    public static final String APP_LOCATION     = "eclipselink.application-location";
-    
-    public static final String CREATE_JDBC_DDL_FILE = "eclipselink.create-ddl-jdbc-file-name";
-    public static final String DROP_JDBC_DDL_FILE   = "eclipselink.drop-ddl-jdbc-file-name";
-    
-    public static final String DEFAULT_APP_LOCATION = "." + File.separator;
-    public static final String DEFAULT_CREATE_JDBC_FILE_NAME = "createDDL.jdbc";
-    public static final String DEFAULT_DROP_JDBC_FILE_NAME = "dropDDL.jdbc";
-    public static final String JAVASE_DB_INTERACTION = "INTERACT_WITH_DB";    
-    
-    public static final String DDL_GENERATION_MODE = "eclipselink.ddl-generation.output-mode";
-    public static final String DDL_SQL_SCRIPT_GENERATION = "sql-script";
-    public static final String DDL_DATABASE_GENERATION = "database";
-    public static final String DDL_BOTH_GENERATION = "both";
-    // This is the default for now to ensure we still play nicely with Glassfish.
-    public static final String DEFAULT_DDL_GENERATION_MODE = DDL_SQL_SCRIPT_GENERATION;
-    
-    protected static final HashMap<String, EntityManagerSetupImpl> emSetupImpls = new HashMap<String, EntityManagerSetupImpl>();
-    // TEMPORARY - WILL BE REMOVED.
-    // Used to warn users about deprecated property name and suggest the valid name.
-    // TEMPORARY the old property names will be translated to the new ones and processed.
-    protected static final String oldPropertyNames[][] = {
-        {PersistenceUnitProperties.JDBC_WRITE_CONNECTIONS_MAX, "eclipselink.max-write-connections"},
-        {PersistenceUnitProperties.JDBC_WRITE_CONNECTIONS_MIN, "eclipselink.min-write-connections"},
-        {PersistenceUnitProperties.JDBC_READ_CONNECTIONS_MAX, "eclipselink.max-read-connections"},
-        {PersistenceUnitProperties.JDBC_READ_CONNECTIONS_MIN, "eclipselink.min-read-connections"},
-        {PersistenceUnitProperties.JDBC_BIND_PARAMETERS, "eclipselink.bind-all-parameters"},
-        {PersistenceUnitProperties.TARGET_DATABASE, "eclipselink.platform.class.name"},
-        {PersistenceUnitProperties.TARGET_SERVER, "eclipselink.server.platform.class.name"},
-        {PersistenceUnitProperties.CACHE_SIZE_DEFAULT, "eclipselink.cache.default-size"}
-    };
-
-    /**
-     * A default constructor is required by all Providers according the the EJB 3.0 specification
-     */
-    public EntityManagerFactoryProvider() {      
-    }
-
-    /**
-    * Called by Persistence class when an EntityManagerFactory
-    * is to be created.
-    *
-    * @param emName The name of the persistence unit
-    * @param map A Map of properties for use by the
-    * persistence provider. These properties may be used to
-    * override the values of the corresponding elements in
-    * the persistence.xml file or specify values for
-    * properties not specified in the persistence.xml.
-    * @return EntityManagerFactory for the persistence unit,
-    * or null if the provider is not the right provider
-    */
-	public EntityManagerFactory createEntityManagerFactory(String emName, Map properties){
-        Map nonNullProperties = (properties == null) ? new HashMap() : properties;
-        String name = emName;
-        if (name == null){
-            name = "";
-        }
-
-        JavaSECMPInitializer initializer = JavaSECMPInitializer.getJavaSECMPInitializer();
-        EntityManagerSetupImpl emSetupImpl = null;
-        ClassLoader currentLoader = Thread.currentThread().getContextClassLoader();
-
-        try {
-            Enumeration<URL> resources = currentLoader.getResources("META-INF/persistence.xml");
-            boolean initialized = false;
-            while (resources.hasMoreElements()) {
-                URL url = PersistenceUnitProcessor.computePURootURL(resources.nextElement());
-                String urlAndName = url + name;
-            
-                synchronized (EntityManagerFactoryProvider.emSetupImpls){
-                    emSetupImpl = EntityManagerFactoryProvider.getEntityManagerSetupImpl(urlAndName);
-                    if (emSetupImpl == null || emSetupImpl.isUndeployed()){
-                        if (!initialized) {
-                            initializer.initialize(nonNullProperties, this);
-                            initialized = true;
-                        }
-                        
-                        emSetupImpl = EntityManagerFactoryProvider.getEntityManagerSetupImpl(urlAndName);
-                    }
-                }
-
-                // We found a match, stop looking.
-                if (emSetupImpl != null) {
-                    break;
-                }
-            }
-        } catch (Exception e){
-            throw PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(currentLoader, e);
-        }
-
-        //gf bug 854  Returns null if EntityManagerSetupImpl for the name doesn't exist (e.g. a non-existant PU)
-        if (emSetupImpl == null) {
-            return null;
-        }
-        
-        if (!isPersistenceProviderSupported(emSetupImpl.getPersistenceUnitInfo().getPersistenceProviderClassName())){
-            return null;
-        }
-
-
-        // synchronized to prevent overriding of the class loader
-        // and also calls to predeploy and undeploy by other threads -
-        // the latter may alter result of shouldRedeploy method.
-        synchronized(emSetupImpl) {
-            if(emSetupImpl.shouldRedeploy()) {
-                SEPersistenceUnitInfo persistenceInfo = (SEPersistenceUnitInfo)emSetupImpl.getPersistenceUnitInfo();
-                persistenceInfo.setClassLoader(JavaSECMPInitializer.getMainLoader());
-                if (emSetupImpl.isUndeployed()){
-                    persistenceInfo.setNewTempClassLoader(JavaSECMPInitializer.getMainLoader());
-                }
-            }
-            // call predeploy
-            // this will just increment the factory count since we should already be deployed
-            emSetupImpl.predeploy(emSetupImpl.getPersistenceUnitInfo(), nonNullProperties);
-        }
-        
-        EntityManagerFactoryImpl factory = null;
-        try {
-            factory = new EntityManagerFactoryImpl(emSetupImpl, nonNullProperties);
-    
-            // This code has been added to allow validation to occur without actually calling createEntityManager
-            if (emSetupImpl.shouldGetSessionOnCreateFactory(nonNullProperties)) {
-                factory.getServerSession();
-            }
-            return factory;
-        } catch (RuntimeException ex) {
-            if(factory != null) {
-                factory.close();
-            } else {
-                emSetupImpl.undeploy();
-            }
-            throw ex;
-        }
-    }
-
-    /**
-    * Called by the container when an EntityManagerFactory
-    * is to be created.
-    *
-    * @param info Metadata for use by the persistence provider
-    * @return EntityManagerFactory for the persistence unit
-    * specified by the metadata
-    * @param map A Map of integration-level properties for use
-    * by the persistence provider.
-    */
-    public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info, Map properties){
-        Map nonNullProperties = (properties == null) ? new HashMap() : properties;
-        EntityManagerSetupImpl emSetupImpl = null;
-        synchronized (EntityManagerFactoryProvider.emSetupImpls) {
-            String urlAndName = info.getPersistenceUnitRootUrl() + info.getPersistenceUnitName();
-            emSetupImpl = EntityManagerFactoryProvider.getEntityManagerSetupImpl(urlAndName);
-            if (emSetupImpl == null){
-                emSetupImpl = new EntityManagerSetupImpl();
-                emSetupImpl.setIsInContainerMode(true);        
-                EntityManagerFactoryProvider.addEntityManagerSetupImpl(urlAndName, emSetupImpl);
-            }
-        }
-        
-        ClassTransformer transformer = null;
-        if(!emSetupImpl.isDeployed()) {
-            transformer = emSetupImpl.predeploy(info, nonNullProperties);
-        }
-        if (transformer != null){
-            info.addTransformer(transformer);
-        }
-        // When EntityManagerFactory is created, the session is only partially created
-        // When the factory is actually accessed, the emSetupImpl will be used to complete the session construction
-        EntityManagerFactoryImpl factory = new EntityManagerFactoryImpl(emSetupImpl, nonNullProperties);
-
-        // This code has been added to allow validation to occur without actually calling createEntityManager
-        if (emSetupImpl.shouldGetSessionOnCreateFactory(nonNullProperties)) {
-        	factory.getServerSession();
-        }
-        return factory;
-    }
-
-    /**
-     * Returns whether the given persistence provider class is supported by this implementation
-     * @param providerClassName
-     * @return
-     */
-    public boolean isPersistenceProviderSupported(String providerClassName){
-        return (providerClassName == null) || providerClassName.equals("") || providerClassName.equals(EntityManagerFactoryProvider.class.getName());
-    }
-    
-    /**
-     * Logs in to given session. If user has not specified  <codeTARGET_DATABASE</code>
-     * the plaform would be auto detected
-     * @param session The session to login to.
-     * @param properties User specified properties for the persistence unit
-     */
-    public static void login(ServerSession session, Map properties) {
-        String toplinkPlatform = (String)properties.get(PersistenceUnitProperties.TARGET_DATABASE);
-        if (!session.isConnected()) {
-            if (toplinkPlatform == null || toplinkPlatform.equals(TargetDatabase.Auto)) {
-                // if user has not specified a database platform, try to detect
-                session.loginAndDetectDatasource();
-            } else {
-                session.login();
-            }
-        }
-    }
-
-    public static void generateDDLFiles(ServerSession session, Map props,
-            boolean inSEmode) {
-        boolean createTables = false, shouldDropFirst = false;
-        String appLocation; 
-        String createDDLJdbc;
-        String dropDDLJdbc;
-        String ddlGeneration = NONE;
-        
-        if(null == props){
-            return;
-        }
-
-        ddlGeneration = (String)getConfigPropertyAsString(DDL_GENERATION, props, NONE);
-        ddlGeneration = ddlGeneration.toLowerCase();
-        if(ddlGeneration.equals(NONE)) {
-            return;
-        }
-
-        if(ddlGeneration.equals(CREATE_ONLY) || 
-            ddlGeneration.equals(DROP_AND_CREATE)) {
-            createTables = true;
-            if(ddlGeneration.equals(DROP_AND_CREATE)) {
-                shouldDropFirst = true;
-            }
-        } 
-        
-        if (createTables) {
-            String ddlGenerationMode = (String) getConfigPropertyAsString(DDL_GENERATION_MODE, props, DEFAULT_DDL_GENERATION_MODE);
-            // Optimize for cases where the value is explicitly set to NONE 
-            if (ddlGenerationMode.equals(NONE)) {                
-                return;
-            }
-            
-            appLocation = (String)getConfigPropertyAsString( APP_LOCATION, props, DEFAULT_APP_LOCATION);
-            createDDLJdbc = (String)getConfigPropertyAsString( CREATE_JDBC_DDL_FILE, props, DEFAULT_CREATE_JDBC_FILE_NAME);
-            dropDDLJdbc = (String)getConfigPropertyAsString( DROP_JDBC_DDL_FILE, props,  DEFAULT_DROP_JDBC_FILE_NAME);
-            
-            SchemaManager mgr = new SchemaManager(session);
-            
-            // The inSEmode checks here are only temporary to ensure we still 
-            // play nicely with Glassfish.
-            if (ddlGenerationMode.equals(DDL_DATABASE_GENERATION) || inSEmode) {
-                runInSEMode(mgr, shouldDropFirst);                
-                
-                if (inSEmode) {
-                    writeDDLsToFiles(mgr, appLocation,  createDDLJdbc,  dropDDLJdbc);      
-                }
-            } else if (ddlGenerationMode.equals(DDL_SQL_SCRIPT_GENERATION)) {
-                writeDDLsToFiles(mgr, appLocation,  createDDLJdbc,  dropDDLJdbc);                
-            } else if (ddlGenerationMode.equals(DDL_BOTH_GENERATION)) {
-                runInSEMode(mgr, shouldDropFirst);
-                writeDDLsToFiles(mgr, appLocation,  createDDLJdbc,  dropDDLJdbc);
-            }
-        }
-    }
-   
-    public static void runInSEMode(SchemaManager mgr, boolean shouldDropFirst) {
-        String str = getConfigPropertyAsString(JAVASE_DB_INTERACTION, null ,"true");
-        boolean interactWithDB = Boolean.valueOf(str.toLowerCase()).booleanValue();
-        if (!interactWithDB){
-            return;
-        }
-        createOrReplaceDefaultTables(mgr, shouldDropFirst);
-    }
-    
-  /**
-   * Check the provided map for an object with the given key.  If that object is not available, check the
-   * System properties.  If it is not available from either location, return the default value.
-   * @param propertyKey 
-   * @param map 
-   * @param defaultValue 
-   * @return 
-   */
-    public static String getConfigPropertyAsString(String propertyKey, Map overrides, String defaultValue){
-        String value = getConfigPropertyAsString(propertyKey, overrides);
-        if (value == null){
-            value = defaultValue;
-        }
-        return value;
-    }
-    
-    public static String getConfigPropertyAsString(String propertyKey, Map overrides){
-        String value = null;
-        if (overrides != null){
-            value = (String)overrides.get(propertyKey);
-        }
-        if (value == null){
-            value = System.getProperty(propertyKey);
-        }
-        
-        return value;
-    }
-
-    public static String getConfigPropertyAsStringLogDebug(String propertyKey, Map overrides, String defaultValue, AbstractSession session){
-        String value = getConfigPropertyAsStringLogDebug(propertyKey, overrides, session);
-        if (value == null){
-            value = defaultValue;
-            session.log(SessionLog.FINEST, SessionLog.PROPERTIES, "property_value_default", new Object[]{propertyKey, value});
-        }
-        return value;
-    }
-    
-    public static String getConfigPropertyAsStringLogDebug(String propertyKey, Map overrides, AbstractSession session){
-        String value = null;
-        if (overrides != null){
-            value = (String)overrides.get(propertyKey);
-        }
-        if (value == null){
-            value = System.getProperty(propertyKey);
-        }
-        if(value != null && session !=  null) {
-            String overrideValue = PersistenceUnitProperties.getOverriddenLogStringForProperty(propertyKey);;           
-            String logValue = (overrideValue == null) ? value : overrideValue;
-            session.log(SessionLog.FINEST, SessionLog.PROPERTIES, "property_value_specified", new Object[]{propertyKey, logValue});
-        }
-        
-        return value;
-    }
-    
-    public static Object getConfigPropertyLogDebug(String propertyKey, Map overrides, AbstractSession session){
-        Object value = null;
-        if (overrides != null){
-            value = overrides.get(propertyKey);
-        }
-        if (value == null){
-            value = System.getProperty(propertyKey);
-        }
-        if(value != null && session !=  null) {
-            String overrideValue = PersistenceUnitProperties.getOverriddenLogStringForProperty(propertyKey);;           
-            Object logValue = (overrideValue == null) ? value : overrideValue;
-            session.log(SessionLog.FINEST, SessionLog.PROPERTIES, "property_value_specified", new Object[]{propertyKey, logValue});
-        }
-        
-        return value;
-    }
-
-    public static void createOrReplaceDefaultTables(
-        SchemaManager mgr, boolean shouldDropFirst) {          
-        if (shouldDropFirst){
-            mgr.replaceDefaultTables(true, true); 
-        } else { 
-            mgr.createDefaultTables(true); 
-        }
-    }
-
-    public static void writeDDLsToFiles(SchemaManager mgr,  String appLocation,
-        String createDDLJdbc, String dropDDLJdbc) {
-        // Ensure that the appLocation string ends with  File.seperator 
-        appLocation = addFileSeperator(appLocation);
-        if (null != createDDLJdbc) {
-            String createJdbcFileName = appLocation + createDDLJdbc;
-            mgr.outputCreateDDLToFile(createJdbcFileName);
-        }
-
-        if (null != dropDDLJdbc) {
-            String dropJdbcFileName = appLocation + dropDDLJdbc;              
-            mgr.outputDropDDLToFile(dropJdbcFileName);
-        }
-
-        mgr.setCreateSQLFiles(false);
-        // When running in the application server environment always ensure that
-        // we write out both the drop and create table files.
-        createOrReplaceDefaultTables(mgr, true);
-        mgr.closeDDLWriter();
-    }
-    
-    public static String addFileSeperator(String appLocation) {
-        int strLength = appLocation.length();
-        if (appLocation.substring(strLength -1, strLength).equals(File.separator)) {
-            return appLocation;
-        } else {
-            return appLocation + File.separator;
-        }
-    }
-
-  /**
-   * Merge the properties from the source object into the target object.  If the property
-   * exists in both objects, use the one from the target
-   * @param target 
-   * @param source 
-   * @return the target object
-   */
-    public static Map mergeMaps(Map target, Map source){
-        Map map = new HashMap();
-        if (source != null){
-            map.putAll(source);
-        }
-
-        if (target != null){
-            map.putAll(target);
-        }
-        return map;
-    }
-
-  /**
-   * This is a TEMPORARY method that will be removed.
-   * DON'T USE THIS METHOD - for internal use only.
-   * @param Map m
-   * @param AbstractSession session
-   */
-    public static void translateOldProperties(Map m, AbstractSession session) {
-        for(int i=0; i < oldPropertyNames.length; i++) {
-            Object value = getConfigPropertyAsString(oldPropertyNames[i][1], m);
-            if(value != null) {
-                if(session != null){
-                    session.log(SessionLog.INFO, SessionLog.TRANSACTION, "deprecated_property", oldPropertyNames[i]);
-                }
-                m.put(oldPropertyNames[i][0], value);
-            }
-        }
-    }
-
-    public static void warnOldProperties(Map m, AbstractSession session) {
-        for(int i=0; i < oldPropertyNames.length; i++) {
-            Object value = m.get(oldPropertyNames[i][1]);
-            if(value != null) {
-                session.log(SessionLog.INFO, SessionLog.TRANSACTION, "deprecated_property", oldPropertyNames[i]);
-            }
-        }
-    }
-    
-    /**
-     * Return the setup class for a given entity manager name 
-     * @param emName 
-     */
-      public static EntityManagerSetupImpl getEntityManagerSetupImpl(String emName){
-          if (emName == null){
-              return (EntityManagerSetupImpl)emSetupImpls.get("");
-          }
-          return (EntityManagerSetupImpl)emSetupImpls.get(emName);
-      }
-      
-      /**
-       * Add an EntityManagerSetupImpl to the cached list
-       * These are used to ensure all persistence units that are the same get the same underlying session
-       * @param name
-       * @param setup
-       */
-      public static void addEntityManagerSetupImpl(String name, EntityManagerSetupImpl setup){
-          if (name == null){
-              emSetupImpls.put("", setup);
-          }
-          emSetupImpls.put(name, setup);
-      }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/jpa/JpaHelper.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/jpa/JpaHelper.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/jpa/JpaHelper.java	(revision 0)
@@ -0,0 +1,196 @@
+/*******************************************************************************
+ * Copyright (c) 1998, 2007 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ *     Oracle - initial API and implementation from Oracle TopLink
+ ******************************************************************************/  
+package org.eclipse.persistence.jpa; 
+
+import javax.persistence.EntityManagerFactory; 
+import javax.persistence.Query; 
+import org.eclipse.persistence.internal.jpa.*; 
+import org.eclipse.persistence.internal.localization.ExceptionLocalization;
+import org.eclipse.persistence.jpa.JpaEntityManager; 
+import org.eclipse.persistence.queries.*; 
+import org.eclipse.persistence.sessions.server.Server; 
+import org.eclipse.persistence.sessions.server.ServerSession; 
+import org.eclipse.persistence.sessions.factories.SessionFactory; 
+
+/** 
+ * This sample illustrates the JPA helper methods that may be of use 
+ * to EclipseLink customers attempting to leverage EclipseLink specific functionality. 
+ * 
+ * @author Doug Clarke 
+ */ 
+public class JpaHelper { 
+    /** 
+     * Verify if the JPA provider is EclipseLink. If you are in a container 
+     * and not in a transaction this method may incorrectly return false. 
+     * It is always more reliable to check isEclipseLink on the EMF or Query. 
+     */ 
+    public static boolean isEclipseLink(javax.persistence.EntityManager em) { 
+        try { 
+            JpaEntityManager emImpl = getEntityManager(em); 
+        } catch (IllegalArgumentException iae) { 
+            return false; 
+        } 
+
+        return em != null; 
+    } 
+
+    /** 
+     * Verify if the JPA provider is EclipseLink 
+     */ 
+    public static boolean isEclipseLink(EntityManagerFactory emf) { 
+        try { 
+            getEntityManagerFactory(emf); 
+        } catch (IllegalArgumentException iae) { 
+            return false; 
+        } 
+
+        return true; 
+    } 
+
+    /** 
+     * Verify if the JPA provider is EclipseLink 
+     */ 
+    public static boolean isEclipseLink(Query query) { 
+        try { 
+            getReadAllQuery(query); 
+        } catch (IllegalArgumentException iae) { 
+            return false; 
+        }
+
+        return true; 
+    } 
+
+    /** 
+     * Determine if the JPA query is a EclipseLink ReportQuery. Useful for 
+     * frameworks that want to dtermine which get_X_Query method they can 
+     * safely invoke. 
+     */ 
+    public static boolean isReportQuery(Query query) { 
+        try { 
+            getReportQuery(query); 
+        } catch (IllegalArgumentException iae) { 
+            return false; 
+        } 
+        return true; 
+    } 
+
+    /** 
+     * Access the internal EclipseLink query wrapped within the JPA query. A 
+     * EclipseLink JPA created from JP QL  contains a ReportQuery if multiple 
+     * items or a non-entity type is being returned. This method will fail 
+     * if a single entity type is being returned as the query is a ReadAllQuery. 
+     * 
+     * @see JpaHelper#getReadAllQuery 
+     */ 
+    public static ReportQuery getReportQuery(Query query) { 
+        if (EJBQueryImpl.class.isAssignableFrom(query.getClass())) { 
+            DatabaseQuery dbQuery = ((EJBQueryImpl)query).getDatabaseQuery(); 
+            if (dbQuery.isReportQuery()) { 
+                return (ReportQuery)dbQuery; 
+            } 
+
+            throw new IllegalArgumentException(ExceptionLocalization.buildMessage("jpa_helper_invalid_report_query" + query.getClass()));
+        } 
+ 
+        throw new IllegalArgumentException(ExceptionLocalization.buildMessage("jpa_helper_invalid_query" + query.getClass()));         
+    } 
+
+    /** 
+     * Access the internal EclipseLink query wrapped within the JPA query. A EclipseLink 
+     * JPA created from JP QL only contains a ReadAllQuery if only a single entity 
+     * type is being returned. 
+     * 
+     * A ReadAllQuery is the super class of a ReportQuery so this method will 
+     * always work for either a ReportQuery or ReadAllQuery. 
+     */ 
+    public static ReadAllQuery getReadAllQuery(Query query) { 
+        if (EJBQueryImpl.class.isAssignableFrom(query.getClass())) { 
+            DatabaseQuery dbQuery = ((EJBQueryImpl)query).getDatabaseQuery(); 
+            if (dbQuery.isReadAllQuery()) { 
+                return (ReadAllQuery)dbQuery; 
+            } 
+
+            throw new IllegalArgumentException(ExceptionLocalization.buildMessage("jpa_helper_invalid_read_all_query" + query.getClass()));
+        } 
+        
+        throw new IllegalArgumentException(ExceptionLocalization.buildMessage("jpa_helper_invalid_query" + query.getClass()));                
+    } 
+
+    /** 
+     * Create a EclipseLink JPA query dynamically given a EclipseLink query. 
+     */ 
+    public static Query createQuery(ReadAllQuery query, javax.persistence.EntityManager em) { 
+        EntityManagerImpl emImpl = (EntityManagerImpl)getEntityManager(em); 
+        return new EJBQueryImpl(query, emImpl); 
+    } 
+
+    /** 
+     * Convert a JPA entityManager into a EclipseLink specific one. This will work 
+     * both within a JavaSE deployment as well as within a container where the 
+     * EntityManager may be wrapped. 
+     * 
+     * In the case where the container is not in a transaction it may return null 
+     * for its delegate. When this happens the only way to access an EntityManager 
+     * is to use the EntityManagerFactory to create a temporary one where the 
+     * application manage its lifecycle. 
+     */ 
+    public static JpaEntityManager getEntityManager(javax.persistence.EntityManager entityManager) { 
+        if (JpaEntityManager.class.isAssignableFrom(entityManager.getClass())) { 
+            return (JpaEntityManager)entityManager; 
+        } 
+
+        if (entityManager.getDelegate() != null) { 
+            return getEntityManager((JpaEntityManager)entityManager.getDelegate()); 
+        } 
+
+        return null; 
+    } 
+
+    /** 
+     * Given a JPA EntityManagerFactory attempt to cast it to a EclipseLink EMF. 
+     */ 
+    public static EntityManagerFactoryImpl getEntityManagerFactory(EntityManagerFactory emf) { 
+        if (EntityManagerFactoryImpl.class.isAssignableFrom(emf.getClass())) { 
+            return (EntityManagerFactoryImpl)emf; 
+        } 
+
+
+        //throw new IllegalArgumentException("jpa.Helper.getEntityManagerFactory could not access EclipseLink EMF: " + emf);
+        throw new IllegalArgumentException(ExceptionLocalization.buildMessage("jpa_helper_invalid_entity_manager_factory" + emf.getClass()));
+    } 
+
+    /** 
+     * Retrieve the shared server session from the EMF. 
+     */ 
+    public static Server getServerSession(EntityManagerFactory emf) { 
+        return getEntityManagerFactory(emf).getServerSession(); 
+    } 
+
+    /** 
+     * Create a EclipseLink EMF given a ServerSession that has already been created 
+     * and logged in. 
+     */ 
+    public static javax.persistence.EntityManagerFactory createEntityManagerFactory(Server session) { 
+        return new EntityManagerFactoryImpl((ServerSession)session); 
+    } 
+
+    /** 
+     * Create a EclipseLink EMF using a session name and sessions.xml. This is 
+     * equivalent to using the EclipseLink.session-xml and EclipseLink.session-name PU 
+     * properties with the exception that no persistence.xml is required. 
+     * 
+     * The application would be required to manage this singleton EMF. 
+     */ 
+    public static EntityManagerFactoryImpl createEntityManagerFactory(String sessionName) { 
+        SessionFactory sf = new SessionFactory(sessionName); 
+        // Verify that shared session is a ServerSession 
+        return new EntityManagerFactoryImpl((ServerSession)sf.getSharedSession()); 
+    } 
+}
\ No newline at end of file
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/columns/xml/XMLJoinColumns.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/columns/xml/XMLJoinColumns.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/columns/xml/XMLJoinColumns.java	(working copy)
@@ -7,16 +7,15 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.columns;
+package org.eclipse.persistence.internal.jpa.metadata.columns.xml;
 
+import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataJoinColumns;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
+
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
-import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataJoinColumns;
-
 /**
  * Object to hold onto xml join column metadata.
  * 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/columns/xml/XMLDiscriminatorColumn.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/columns/xml/XMLDiscriminatorColumn.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/columns/xml/XMLDiscriminatorColumn.java	(working copy)
@@ -7,15 +7,14 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.columns;
-
+package org.eclipse.persistence.internal.jpa.metadata.columns.xml;
+
+import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataDiscriminatorColumn;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
+
 import org.w3c.dom.Node;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
-import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataDiscriminatorColumn;
-
 /**
  * Object to hold onto an xml discriminator column metadata.
  * 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/columns/xml/XMLPrimaryKeyJoinColumn.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/columns/xml/XMLPrimaryKeyJoinColumn.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/columns/xml/XMLPrimaryKeyJoinColumn.java	(working copy)
@@ -7,16 +7,15 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.columns;
+package org.eclipse.persistence.internal.jpa.metadata.columns.xml;
 
-import org.w3c.dom.Node;
+import org.eclipse.persistence.internal.helper.DatabaseTable;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
 import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataPrimaryKeyJoinColumn;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
 
-import org.eclipse.persistence.internal.helper.DatabaseTable;
+import org.w3c.dom.Node;
 
 /**
  * Object to hold onto XML primary key join column metadata in TopLink database 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/columns/xml/XMLPrimaryKeyJoinColumns.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/columns/xml/XMLPrimaryKeyJoinColumns.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/columns/xml/XMLPrimaryKeyJoinColumns.java	(working copy)
@@ -7,17 +7,16 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.columns;
+package org.eclipse.persistence.internal.jpa.metadata.columns.xml;
 
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
+import org.eclipse.persistence.internal.helper.DatabaseTable;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
 import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataPrimaryKeyJoinColumns;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
 
-import org.eclipse.persistence.internal.helper.DatabaseTable;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 
 /**
  * Object to hold onto XML primary key join column metadata.
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/columns/xml/XMLColumn.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/columns/xml/XMLColumn.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/columns/xml/XMLColumn.java	(working copy)
@@ -7,17 +7,15 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.columns;
+package org.eclipse.persistence.internal.jpa.metadata.columns.xml;
 
 import java.lang.reflect.AnnotatedElement;
-
+
+import org.eclipse.persistence.internal.jpa.metadata.accessors.xml.XMLBasicAccessor;
 import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataColumn;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
 
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLBasicAccessor;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-
 import org.w3c.dom.Node;
 
 /**
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/columns/xml/XMLJoinColumn.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/columns/xml/XMLJoinColumn.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/columns/xml/XMLJoinColumn.java	(working copy)
@@ -7,15 +7,14 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.columns;
+package org.eclipse.persistence.internal.jpa.metadata.columns.xml;
 
-import org.w3c.dom.Node;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
 import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataJoinColumn;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
 
+import org.w3c.dom.Node;
+
 /**
  * Object to hold onto xml join column metadata in a TopLink database fields.
  * 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/EmbeddedAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/EmbeddedAccessor.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/EmbeddedAccessor.java	(working copy)
@@ -15,17 +15,20 @@
 import static org.eclipse.persistence.internal.jpa.metadata.accessors.EmbeddedAccessor.AccessType.UNDEFINED;
 
 import javax.persistence.*;
+
+import org.eclipse.persistence.internal.helper.DatabaseField;
+
+import org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor;
+import org.eclipse.persistence.internal.jpa.metadata.MetadataHelper;
 
 import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject;
-import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataClass;
+import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataClass;
+import org.eclipse.persistence.internal.jpa.metadata.accessors.xml.XMLClassAccessor;
+
 import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataColumn;
 
-import org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor;
-import org.eclipse.persistence.internal.jpa.metadata.MetadataHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLClassAccessor;
-import org.eclipse.persistence.internal.helper.DatabaseField;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
 
 import org.eclipse.persistence.mappings.AggregateObjectMapping;
 import org.eclipse.persistence.mappings.DatabaseMapping;
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLMappedSuperclassAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLMappedSuperclassAccessor.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLMappedSuperclassAccessor.java	(working copy)
@@ -7,14 +7,14 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.accessors;
+package org.eclipse.persistence.internal.jpa.metadata.accessors.xml;
 
 import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject;
 
 import org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor;
 import org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
 
 import org.w3c.dom.Node;
 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLManyToManyAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLManyToManyAccessor.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLManyToManyAccessor.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.accessors;
+package org.eclipse.persistence.internal.jpa.metadata.accessors.xml;
 
 import java.util.List;
 
@@ -16,10 +16,10 @@
 
 import org.eclipse.persistence.internal.jpa.metadata.tables.MetadataJoinTable;
 
-import org.eclipse.persistence.internal.jpa.xml.tables.XMLJoinTable;
+import org.eclipse.persistence.internal.jpa.metadata.tables.xml.XMLJoinTable;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
 
 import org.w3c.dom.Node;
 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLAccessor.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLAccessor.java	(working copy)
@@ -7,9 +7,9 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.accessors;
+package org.eclipse.persistence.internal.jpa.metadata.accessors.xml;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
 
 /**
  * An XMLAccessor should implement this interface.
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLBasicAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLBasicAccessor.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLBasicAccessor.java	(working copy)
@@ -7,23 +7,18 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.accessors;
+package org.eclipse.persistence.internal.jpa.metadata.accessors.xml;
 
 import org.eclipse.persistence.internal.jpa.metadata.accessors.BasicAccessor;
 import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject;
+import org.eclipse.persistence.internal.jpa.metadata.accessors.xml.XMLClassAccessor;
 import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataColumn;
-
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLClassAccessor;
-
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLColumn;
-
-import org.eclipse.persistence.internal.jpa.xml.sequencing.XMLGeneratedValue;
-import org.eclipse.persistence.internal.jpa.xml.sequencing.XMLTableGenerator;
-import org.eclipse.persistence.internal.jpa.xml.sequencing.XMLSequenceGenerator;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
+import org.eclipse.persistence.internal.jpa.metadata.columns.xml.XMLColumn;
+import org.eclipse.persistence.internal.jpa.metadata.sequencing.xml.XMLGeneratedValue;
+import org.eclipse.persistence.internal.jpa.metadata.sequencing.xml.XMLTableGenerator;
+import org.eclipse.persistence.internal.jpa.metadata.sequencing.xml.XMLSequenceGenerator;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
 import org.eclipse.persistence.internal.helper.DatabaseField;
 
 import org.w3c.dom.Node;
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLClassAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLClassAccessor.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLClassAccessor.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.accessors;
+package org.eclipse.persistence.internal.jpa.metadata.accessors.xml;
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
@@ -15,54 +15,50 @@
 import java.net.URL;
 import java.util.Map;
 
+import org.eclipse.persistence.internal.helper.DatabaseTable;
+
+import org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor;
+import org.eclipse.persistence.internal.jpa.metadata.MetadataHelper;
+import org.eclipse.persistence.internal.jpa.metadata.MetadataPersistenceUnit;
+import org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor;
+
 import org.eclipse.persistence.internal.jpa.metadata.accessors.ClassAccessor;
 import org.eclipse.persistence.internal.jpa.metadata.accessors.MetadataAccessor;
-
 import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject;
 import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataClass;
 import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataField;
 import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataMethod;
+import org.eclipse.persistence.internal.jpa.metadata.accessors.xml.XMLBasicAccessor;
+import org.eclipse.persistence.internal.jpa.metadata.accessors.xml.XMLEmbeddedAccessor;
+import org.eclipse.persistence.internal.jpa.metadata.accessors.xml.XMLManyToManyAccessor;
+import org.eclipse.persistence.internal.jpa.metadata.accessors.xml.XMLManyToOneAccessor;
+import org.eclipse.persistence.internal.jpa.metadata.accessors.xml.XMLOneToManyAccessor;
+import org.eclipse.persistence.internal.jpa.metadata.accessors.xml.XMLOneToOneAccessor;
+import org.eclipse.persistence.internal.jpa.metadata.accessors.xml.XMLTransientAccessor;
 
 import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataPrimaryKeyJoinColumns;
+import org.eclipse.persistence.internal.jpa.metadata.columns.xml.XMLColumn;
+import org.eclipse.persistence.internal.jpa.metadata.columns.xml.XMLDiscriminatorColumn;
+import org.eclipse.persistence.internal.jpa.metadata.columns.xml.XMLJoinColumns;
+import org.eclipse.persistence.internal.jpa.metadata.columns.xml.XMLPrimaryKeyJoinColumns;
 
 import org.eclipse.persistence.internal.jpa.metadata.listeners.MetadataEntityListener;
+import org.eclipse.persistence.internal.jpa.metadata.listeners.xml.XMLEntityClassListener;
+import org.eclipse.persistence.internal.jpa.metadata.listeners.xml.XMLEntityListener;
 
-import org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor;
-import org.eclipse.persistence.internal.jpa.metadata.MetadataHelper;
-import org.eclipse.persistence.internal.jpa.metadata.MetadataPersistenceUnit;
-import org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor;
+import org.eclipse.persistence.internal.jpa.metadata.queries.xml.XMLNamedNativeQuery;
+import org.eclipse.persistence.internal.jpa.metadata.queries.xml.XMLNamedQuery;
+import org.eclipse.persistence.internal.jpa.metadata.queries.xml.XMLSQLResultSetMapping;
 
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLBasicAccessor;
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLEmbeddedAccessor;
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLManyToManyAccessor;
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLManyToOneAccessor;
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLOneToManyAccessor;
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLOneToOneAccessor;
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLTransientAccessor;
+import org.eclipse.persistence.internal.jpa.metadata.sequencing.xml.XMLSequenceGenerator;
+import org.eclipse.persistence.internal.jpa.metadata.sequencing.xml.XMLTableGenerator;
 
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLColumn;
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLDiscriminatorColumn;
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLJoinColumns;
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLPrimaryKeyJoinColumns;
+import org.eclipse.persistence.internal.jpa.metadata.tables.xml.XMLSecondaryTable;
+import org.eclipse.persistence.internal.jpa.metadata.tables.xml.XMLTable;
 
-import org.eclipse.persistence.internal.jpa.xml.listeners.XMLEntityClassListener;
-import org.eclipse.persistence.internal.jpa.xml.listeners.XMLEntityListener;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
 
-import org.eclipse.persistence.internal.jpa.xml.queries.XMLNamedNativeQuery;
-import org.eclipse.persistence.internal.jpa.xml.queries.XMLNamedQuery;
-import org.eclipse.persistence.internal.jpa.xml.queries.XMLSQLResultSetMapping;
-
-import org.eclipse.persistence.internal.jpa.xml.sequencing.XMLSequenceGenerator;
-import org.eclipse.persistence.internal.jpa.xml.sequencing.XMLTableGenerator;
-
-import org.eclipse.persistence.internal.jpa.xml.tables.XMLSecondaryTable;
-import org.eclipse.persistence.internal.jpa.xml.tables.XMLTable;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-
-import org.eclipse.persistence.internal.helper.DatabaseTable;
-
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import org.w3c.dom.Document;
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLOneToOneAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLOneToOneAccessor.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLOneToOneAccessor.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.accessors;
+package org.eclipse.persistence.internal.jpa.metadata.accessors.xml;
 
 import java.util.List;
 
@@ -17,10 +17,10 @@
 import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataJoinColumns;
 import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataPrimaryKeyJoinColumns;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
 
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLJoinColumns;
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLPrimaryKeyJoinColumns;
+import org.eclipse.persistence.internal.jpa.metadata.columns.xml.XMLJoinColumns;
+import org.eclipse.persistence.internal.jpa.metadata.columns.xml.XMLPrimaryKeyJoinColumns;
 
 import org.eclipse.persistence.internal.helper.DatabaseTable;
 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLEmbeddedIdAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLEmbeddedIdAccessor.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLEmbeddedIdAccessor.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.accessors;
+package org.eclipse.persistence.internal.jpa.metadata.accessors.xml;
 
 import org.eclipse.persistence.internal.jpa.metadata.accessors.ClassAccessor;
 import org.eclipse.persistence.internal.jpa.metadata.accessors.EmbeddedIdAccessor;
@@ -17,10 +17,10 @@
 
 import org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
 
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLColumn;
+import org.eclipse.persistence.internal.jpa.metadata.columns.xml.XMLColumn;
 
 import org.eclipse.persistence.mappings.AggregateObjectMapping;
 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLTransientAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLTransientAccessor.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLTransientAccessor.java	(working copy)
@@ -7,12 +7,12 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.accessors;
+package org.eclipse.persistence.internal.jpa.metadata.accessors.xml;
 
 import org.eclipse.persistence.internal.jpa.metadata.accessors.MetadataAccessor;
 import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject;
 
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLClassAccessor;
+import org.eclipse.persistence.internal.jpa.metadata.accessors.xml.XMLClassAccessor;
 
 import org.w3c.dom.Node;
 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLManyToOneAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLManyToOneAccessor.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLManyToOneAccessor.java	(working copy)
@@ -7,17 +7,18 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.accessors;
+package org.eclipse.persistence.internal.jpa.metadata.accessors.xml;
 
 import java.util.List;
 
 import org.eclipse.persistence.internal.jpa.metadata.accessors.ManyToOneAccessor;
 import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject;
+import org.eclipse.persistence.internal.jpa.metadata.accessors.xml.XMLClassAccessor;
+
 import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataJoinColumns;
+import org.eclipse.persistence.internal.jpa.metadata.columns.xml.XMLJoinColumns;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLClassAccessor;
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLJoinColumns;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
 
 import org.w3c.dom.Node;
 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLOneToManyAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLOneToManyAccessor.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLOneToManyAccessor.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.accessors;
+package org.eclipse.persistence.internal.jpa.metadata.accessors.xml;
 
 import java.util.List;
 
@@ -16,10 +16,10 @@
 
 import org.eclipse.persistence.internal.jpa.metadata.tables.MetadataJoinTable;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
 
-import org.eclipse.persistence.internal.jpa.xml.tables.XMLJoinTable;
+import org.eclipse.persistence.internal.jpa.metadata.tables.xml.XMLJoinTable;
 
 import org.w3c.dom.Node;
 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLEmbeddedAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLEmbeddedAccessor.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/xml/XMLEmbeddedAccessor.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.accessors;
+package org.eclipse.persistence.internal.jpa.metadata.accessors.xml;
 
 import org.eclipse.persistence.internal.jpa.metadata.accessors.ClassAccessor;
 import org.eclipse.persistence.internal.jpa.metadata.accessors.EmbeddedAccessor;
@@ -17,10 +17,10 @@
 
 import org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
 
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLColumn;
+import org.eclipse.persistence.internal.jpa.metadata.columns.xml.XMLColumn;
 
 import org.eclipse.persistence.mappings.AggregateObjectMapping;
 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/ClassAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/ClassAccessor.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/ClassAccessor.java	(working copy)
@@ -70,6 +70,7 @@
 import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataClass;
 import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataField;
 import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataMethod;
+import org.eclipse.persistence.internal.jpa.metadata.accessors.xml.XMLMappedSuperclassAccessor;
 
 import org.eclipse.persistence.internal.jpa.metadata.cache.MetadataCache;
 import org.eclipse.persistence.internal.jpa.metadata.cache.MetadataTimeOfDay;
@@ -83,6 +84,7 @@
 
 import org.eclipse.persistence.internal.jpa.metadata.listeners.MetadataEntityClassListener;
 import org.eclipse.persistence.internal.jpa.metadata.listeners.MetadataEntityListener;
+import org.eclipse.persistence.internal.jpa.metadata.listeners.xml.XMLEntityListener;
 
 import org.eclipse.persistence.internal.jpa.metadata.locking.MetadataOptimisticLocking;
 
@@ -101,10 +103,8 @@
 import org.eclipse.persistence.internal.jpa.metadata.tables.MetadataSecondaryTable;
 import org.eclipse.persistence.internal.jpa.metadata.tables.MetadataTable;
 
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLMappedSuperclassAccessor;
-import org.eclipse.persistence.internal.jpa.xml.listeners.XMLEntityListener;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
 
 import org.eclipse.persistence.internal.helper.DatabaseField;
 import org.eclipse.persistence.internal.helper.DatabaseTable;
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataProject.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataProject.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataProject.java	(working copy)
@@ -36,7 +36,7 @@
 import org.eclipse.persistence.internal.sessions.AbstractSession;
 
 import org.eclipse.persistence.internal.jpa.EJBQueryImpl;
-import org.eclipse.persistence.internal.jpa.base.QueryHintsHandler;
+import org.eclipse.persistence.internal.jpa.QueryHintsHandler;
 
 import org.eclipse.persistence.internal.jpa.metadata.accessors.MetadataAccessor;
 import org.eclipse.persistence.internal.jpa.metadata.accessors.RelationshipAccessor;
@@ -54,7 +54,7 @@
 import org.eclipse.persistence.internal.jpa.metadata.sequencing.MetadataTableGenerator;
 import org.eclipse.persistence.internal.jpa.metadata.sequencing.MetadataSequenceGenerator;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
 
 import org.eclipse.persistence.queries.StoredProcedureCall;
 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataDescriptor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataDescriptor.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataDescriptor.java	(working copy)
@@ -35,7 +35,7 @@
 
 import org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy;
 
-import org.eclipse.persistence.internal.jpa.base.CMP3Policy;
+import org.eclipse.persistence.internal.jpa.CMP3Policy;
 
 import org.eclipse.persistence.internal.jpa.metadata.MetadataConstants;
 
@@ -49,7 +49,7 @@
 
 import org.eclipse.persistence.internal.jpa.metadata.listeners.MetadataEntityListener;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
 
 import org.eclipse.persistence.internal.helper.DatabaseField;
 import org.eclipse.persistence.internal.helper.DatabaseTable;
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/XMLHelper.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/XMLHelper.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/XMLHelper.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml;
+package org.eclipse.persistence.internal.jpa.metadata.xml;
 
 import java.io.InputStream;
 import java.io.IOException;
@@ -34,9 +34,9 @@
 import org.eclipse.persistence.internal.jpa.metadata.MetadataHelper;
 import org.eclipse.persistence.internal.jpa.metadata.MetadataLogger;
 
-import org.eclipse.persistence.internal.jpa.xml.parser.XPathEngine;
-import org.eclipse.persistence.internal.jpa.xml.parser.XMLException;
-import org.eclipse.persistence.internal.jpa.xml.parser.XMLExceptionHandler;
+import org.eclipse.persistence.internal.jpa.metadata.xml.parser.XPathEngine;
+import org.eclipse.persistence.internal.jpa.metadata.xml.parser.XMLException;
+import org.eclipse.persistence.internal.jpa.metadata.xml.parser.XMLExceptionHandler;
 
 /**
  * Utility class used for handling element inspection.
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/XMLValidator.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/XMLValidator.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/XMLValidator.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml;
+package org.eclipse.persistence.internal.jpa.metadata.xml;
 
 import java.lang.reflect.AnnotatedElement;
 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/parser/XMLException.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/parser/XMLException.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/parser/XMLException.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.parser;
+package org.eclipse.persistence.internal.jpa.metadata.xml.parser;
 
 import java.util.ArrayList;
 import java.util.List;
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/parser/XMLNodeList.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/parser/XMLNodeList.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/parser/XMLNodeList.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.parser;
+package org.eclipse.persistence.internal.jpa.metadata.xml.parser;
 
 import java.util.ArrayList;
 import org.w3c.dom.Node;
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/parser/XPathEngine.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/parser/XPathEngine.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/parser/XPathEngine.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.parser;
+package org.eclipse.persistence.internal.jpa.metadata.xml.parser;
 
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/parser/PersistenceContentHandler.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/parser/PersistenceContentHandler.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/parser/PersistenceContentHandler.java	(working copy)
@@ -7,21 +7,18 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.parser;
+package org.eclipse.persistence.internal.jpa.metadata.xml.parser;
 
 import org.xml.sax.Locator;
 import org.xml.sax.SAXException;
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
 
-import java.net.URL;
-import java.net.MalformedURLException;
 import java.util.Vector;
 import javax.persistence.spi.PersistenceUnitTransactionType;
 
 import org.eclipse.persistence.internal.jpa.deployment.SEPersistenceUnitInfo;
-import org.eclipse.persistence.internal.jpa.jdbc.base.DataSourceImpl;
-import org.eclipse.persistence.logging.AbstractSessionLog;
+import org.eclipse.persistence.internal.jpa.jdbc.DataSourceImpl;
 
 public class PersistenceContentHandler implements ContentHandler {
     private static final String NAMESPACE_URI = "http://java.sun.com/xml/ns/persistence";;
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/parser/XMLExceptionHandler.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/parser/XMLExceptionHandler.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/parser/XMLExceptionHandler.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.parser;
+package org.eclipse.persistence.internal.jpa.metadata.xml.parser;
 
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXException;
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/XMLConstants.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/XMLConstants.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/xml/XMLConstants.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml;
+package org.eclipse.persistence.internal.jpa.metadata.xml;
 
 /**
  * INTERNAL:
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataProcessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataProcessor.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataProcessor.java	(working copy)
@@ -37,12 +37,13 @@
 import org.eclipse.persistence.internal.jpa.metadata.MetadataLogger;
 import org.eclipse.persistence.internal.jpa.metadata.accessors.ClassAccessor;
 import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataClass;
+import org.eclipse.persistence.internal.jpa.metadata.accessors.xml.XMLClassAccessor;
+
 import org.eclipse.persistence.internal.jpa.metadata.converters.MetadataStructConverter;
 
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLClassAccessor;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLValidator;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLValidator;
 
 import org.eclipse.persistence.internal.sessions.AbstractSession;
 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/sequencing/xml/XMLTableGenerator.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/sequencing/xml/XMLTableGenerator.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/sequencing/xml/XMLTableGenerator.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.sequencing;
+package org.eclipse.persistence.internal.jpa.metadata.sequencing.xml;
 
 import java.util.List;
 import java.util.ArrayList;
@@ -15,11 +15,9 @@
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLAccessor;
-
+import org.eclipse.persistence.internal.jpa.metadata.accessors.xml.XMLAccessor;
 import org.eclipse.persistence.internal.jpa.metadata.sequencing.MetadataTableGenerator;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
 
 /**
  * Object to hold onto an xml table generator metadata.
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/sequencing/xml/XMLSequenceGenerator.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/sequencing/xml/XMLSequenceGenerator.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/sequencing/xml/XMLSequenceGenerator.java	(working copy)
@@ -7,15 +7,15 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.sequencing;
+package org.eclipse.persistence.internal.jpa.metadata.sequencing.xml;
 
 import org.w3c.dom.Node;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
 import org.eclipse.persistence.internal.jpa.metadata.sequencing.MetadataSequenceGenerator;
 
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
+
 /**
  * Object to hold onto an XML sequence generator metadata.
  * 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/sequencing/xml/XMLGeneratedValue.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/sequencing/xml/XMLGeneratedValue.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/sequencing/xml/XMLGeneratedValue.java	(working copy)
@@ -7,12 +7,12 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.sequencing;
+package org.eclipse.persistence.internal.jpa.metadata.sequencing.xml;
 
 import org.eclipse.persistence.internal.jpa.metadata.sequencing.MetadataGeneratedValue;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
 
 import org.w3c.dom.Node;
 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataPersistenceUnit.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataPersistenceUnit.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataPersistenceUnit.java	(working copy)
@@ -9,7 +9,7 @@
  ******************************************************************************/  
 package org.eclipse.persistence.internal.jpa.metadata;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
 
 /**
  * Metadata object to hold persistence unit information.
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/listeners/xml/XMLEntityListener.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/listeners/xml/XMLEntityListener.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/listeners/xml/XMLEntityListener.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.listeners;
+package org.eclipse.persistence.internal.jpa.metadata.listeners.xml;
 
 import org.eclipse.persistence.internal.jpa.metadata.listeners.MetadataEntityListener;
 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/listeners/xml/XMLEntityClassListener.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/listeners/xml/XMLEntityClassListener.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/listeners/xml/XMLEntityClassListener.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.listeners;
+package org.eclipse.persistence.internal.jpa.metadata.listeners.xml;
 
 import java.lang.reflect.Method;
 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/tables/xml/XMLSecondaryTable.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/tables/xml/XMLSecondaryTable.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/tables/xml/XMLSecondaryTable.java	(working copy)
@@ -7,20 +7,19 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.tables;
+package org.eclipse.persistence.internal.jpa.metadata.tables.xml;
 
 import org.w3c.dom.Node;
 
+import org.eclipse.persistence.internal.helper.DatabaseTable;
+
 import org.eclipse.persistence.internal.jpa.metadata.MetadataLogger;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLPrimaryKeyJoinColumns;
-
+import org.eclipse.persistence.internal.jpa.metadata.columns.xml.XMLPrimaryKeyJoinColumns;
 import org.eclipse.persistence.internal.jpa.metadata.tables.MetadataSecondaryTable;
 
-import org.eclipse.persistence.internal.helper.DatabaseTable;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
 
 /**
  * Object to hold onto an XML secondary table metadata in a TopLink database 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/tables/xml/XMLTableHelper.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/tables/xml/XMLTableHelper.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/tables/xml/XMLTableHelper.java	(working copy)
@@ -7,14 +7,15 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.tables;
+package org.eclipse.persistence.internal.jpa.metadata.tables.xml;
 
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
+
+import org.eclipse.persistence.internal.helper.DatabaseTable;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-import org.eclipse.persistence.internal.helper.DatabaseTable;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
 
 import java.util.List;
 import java.util.ArrayList;
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/tables/xml/XMLJoinTable.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/tables/xml/XMLJoinTable.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/tables/xml/XMLJoinTable.java	(working copy)
@@ -7,18 +7,18 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.tables;
+package org.eclipse.persistence.internal.jpa.metadata.tables.xml;
 
 import org.eclipse.persistence.internal.jpa.metadata.MetadataLogger;
 
-import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataJoinColumns;
+import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataJoinColumns;
+import org.eclipse.persistence.internal.jpa.metadata.columns.xml.XMLJoinColumns;
+
 import org.eclipse.persistence.internal.jpa.metadata.tables.MetadataJoinTable;
 
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLJoinColumns;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/tables/xml/XMLTable.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/tables/xml/XMLTable.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/tables/xml/XMLTable.java	(working copy)
@@ -7,13 +7,13 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.tables;
+package org.eclipse.persistence.internal.jpa.metadata.tables.xml;
 
 import org.eclipse.persistence.internal.jpa.metadata.MetadataLogger;
 import org.eclipse.persistence.internal.jpa.metadata.tables.MetadataTable;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
 
 import org.w3c.dom.Node;
 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/queries/xml/XMLNamedNativeQuery.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/queries/xml/XMLNamedNativeQuery.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/queries/xml/XMLNamedNativeQuery.java	(working copy)
@@ -7,15 +7,15 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.queries;
+package org.eclipse.persistence.internal.jpa.metadata.queries.xml;
 
 import org.eclipse.persistence.internal.jpa.metadata.MetadataLogger;
 
 import org.eclipse.persistence.internal.jpa.metadata.queries.MetadataQueryHint;
 import org.eclipse.persistence.internal.jpa.metadata.queries.MetadataNamedNativeQuery;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
 
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/queries/xml/XMLFieldResult.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/queries/xml/XMLFieldResult.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/queries/xml/XMLFieldResult.java	(working copy)
@@ -7,12 +7,12 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.queries;
+package org.eclipse.persistence.internal.jpa.metadata.queries.xml;
 
 import org.w3c.dom.Node;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
 
 import org.eclipse.persistence.internal.jpa.metadata.queries.MetadataFieldResult;
 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/queries/xml/XMLSQLResultSetMapping.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/queries/xml/XMLSQLResultSetMapping.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/queries/xml/XMLSQLResultSetMapping.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.queries;
+package org.eclipse.persistence.internal.jpa.metadata.queries.xml;
 
 import java.util.List;
 import java.util.ArrayList;
@@ -15,11 +15,11 @@
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
 import org.eclipse.persistence.internal.jpa.metadata.queries.MetadataEntityResult;
-import org.eclipse.persistence.internal.jpa.metadata.queries.MetadataSQLResultSetMapping;
+import org.eclipse.persistence.internal.jpa.metadata.queries.MetadataSQLResultSetMapping;
+
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
 
 /**
  * Object to hold onto an XML sql result set mapping metadata.
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/queries/xml/XMLNamedQuery.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/queries/xml/XMLNamedQuery.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/queries/xml/XMLNamedQuery.java	(working copy)
@@ -7,15 +7,15 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.queries;
+package org.eclipse.persistence.internal.jpa.metadata.queries.xml;
 
 import org.eclipse.persistence.internal.jpa.metadata.MetadataLogger;
 
 import org.eclipse.persistence.internal.jpa.metadata.queries.MetadataQueryHint;
 import org.eclipse.persistence.internal.jpa.metadata.queries.MetadataNamedQuery;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
 
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/queries/xml/XMLEntityResult.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/queries/xml/XMLEntityResult.java	(revision 0)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/queries/xml/XMLEntityResult.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.queries;
+package org.eclipse.persistence.internal.jpa.metadata.queries.xml;
 
 import java.util.List;
 import java.util.ArrayList;
@@ -15,8 +15,8 @@
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLHelper;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
 
 import org.eclipse.persistence.internal.jpa.metadata.queries.MetadataFieldResult;
 import org.eclipse.persistence.internal.jpa.metadata.queries.MetadataEntityResult;
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/deployment/PersistenceUnitProcessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/deployment/PersistenceUnitProcessor.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/deployment/PersistenceUnitProcessor.java	(working copy)
@@ -33,10 +33,10 @@
 import org.eclipse.persistence.exceptions.PersistenceUnitLoadingException;
 import org.eclipse.persistence.exceptions.XMLParseException;
 import org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-import org.eclipse.persistence.internal.jpa.xml.parser.PersistenceContentHandler;
-import org.eclipse.persistence.internal.jpa.xml.parser.XMLException;
-import org.eclipse.persistence.internal.jpa.xml.parser.XMLExceptionHandler;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLConstants;
+import org.eclipse.persistence.internal.jpa.metadata.xml.parser.PersistenceContentHandler;
+import org.eclipse.persistence.internal.jpa.metadata.xml.parser.XMLException;
+import org.eclipse.persistence.internal.jpa.metadata.xml.parser.XMLExceptionHandler;
 import org.eclipse.persistence.internal.sessions.AbstractSession;
 import org.eclipse.persistence.logging.AbstractSessionLog;
 import org.eclipse.persistence.logging.SessionLog;
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/TransactionManagerImpl.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/TransactionManagerImpl.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/TransactionManagerImpl.java	(working copy)
@@ -7,13 +7,13 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.transaction.base;
+package org.eclipse.persistence.internal.jpa.transaction;
 
 import java.sql.Connection;
 import java.sql.SQLException;
 import javax.transaction.*;
-import org.eclipse.persistence.internal.jpa.base.ExceptionFactory;
-import org.eclipse.persistence.internal.jpa.jdbc.base.DataSourceImpl;
+import org.eclipse.persistence.internal.jpa.ExceptionFactory;
+import org.eclipse.persistence.internal.jpa.jdbc.DataSourceImpl;
 
 /**
  * Implementation of JTA Transaction manager class.
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/EntityTransactionWrapper.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/EntityTransactionWrapper.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/EntityTransactionWrapper.java	(working copy)
@@ -12,6 +12,10 @@
 import javax.persistence.EntityTransaction;
 import javax.persistence.TransactionRequiredException;
 import org.eclipse.persistence.internal.jpa.EntityManagerImpl;
+import org.eclipse.persistence.internal.jpa.RepeatableWriteUnitOfWork;
+import org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl;
+import org.eclipse.persistence.internal.localization.ExceptionLocalization;
+import org.eclipse.persistence.internal.sessions.UnitOfWorkImpl;
 import org.eclipse.persistence.exceptions.TransactionException;
 
 /**
@@ -22,39 +26,101 @@
  * 
  * @see org.eclipse.persistence.internal.jpa.transaction.EntityTransactionWrapper
  */
-public class EntityTransactionWrapper 
-    extends org.eclipse.persistence.internal.jpa.transaction.base.EntityTransactionWrapper 
-    implements TransactionWrapper
-{
+public class EntityTransactionWrapper extends TransactionWrapperImpl implements TransactionWrapper {
+	protected EntityTransactionImpl entityTransaction;
 
     public EntityTransactionWrapper(EntityManagerImpl entityManager) {
         super(entityManager);
     }
     
-  /**
-   * Lazy initialize the EntityTransaction.
-   * There can only be one EntityTransaction at a time.
-   */
-    public EntityTransaction getTransaction(){
-        if (entityTransaction == null){
-            entityTransaction = new EntityTransactionImpl(this);
+
+    /**
+     * INTERNAL:
+     * This method will be used to check for a transaction and throws exception if none exists.
+     * If this methiod returns without exception then a transaction exists.
+     * This method must be called before accessing the localUOW.
+     */
+    public Object checkForTransaction(boolean validateExistence){
+        if (entityTransaction != null && entityTransaction.isActive()) {
+            return entityTransaction;
         }
-        return (EntityTransaction)entityTransaction;
+        if (validateExistence){
+            throwCheckTransactionFailedException();
+        }
+        return null;
     }
 
     /**
+     * INTERNAL:
+     * THis method is used to get the active UnitOfWork.  It is special in that it will
+     * return the required RepeatableWriteUnitOfWork required by the EntityManager.  Once 
+     * RepeatableWrite is merged into existing UnitOfWork this code can go away.
+     */
+    public RepeatableWriteUnitOfWork getTransactionalUnitOfWork(Object transaction){
+        if (transaction == null){
+            return null;
+        }
+        if (this.localUOW == null){
+            this.localUOW = new RepeatableWriteUnitOfWork(entityManager.getServerSession().acquireClientSession());
+            this.localUOW.setShouldCascadeCloneToJoinedRelationship(true);
+        }
+        return (RepeatableWriteUnitOfWork)this.localUOW;
+    }
+    
+    public EntityManagerImpl getEntityManager(){
+        return entityManager;
+    }
+
+    /**
+     * Lazy initialize the EntityTransaction.
+     * There can only be one EntityTransaction at a time.
+     */
+      public EntityTransaction getTransaction(){
+          if (entityTransaction == null){
+              entityTransaction = new EntityTransactionImpl(this);
+          }
+          return (EntityTransaction)entityTransaction;
+      }
+      
+    public void registerUnitOfWorkWithTxn(UnitOfWorkImpl uow){
+        throw new TransactionRequiredException(ExceptionLocalization.buildMessage("join_trans_called_on_entity_trans"));// no JTA transactions availab
+    }
+    
+    /**
     * Mark the current transaction so that the only possible
     * outcome of the transaction is for the transaction to be
     * rolled back.
     * This is an internal method and if the txn is not active will do nothing
     */
-    public void setRollbackOnlyInternal(){
-        if (this.getTransaction().isActive()){
-            this.getTransaction().setRollbackOnly();
-        }
+    // From old parent
+    //public void setRollbackOnlyInternal(){
+      //  if (entityTransaction != null && entityTransaction.isActive()){
+        //    entityTransaction.setRollbackOnly();
+        //}
+    //}
+    
+    /**
+     * Mark the current transaction so that the only possible
+     * outcome of the transaction is for the transaction to be
+     * rolled back.
+     * This is an internal method and if the txn is not active will do nothing
+     */
+     public void setRollbackOnlyInternal(){
+         if (this.getTransaction().isActive()){
+             this.getTransaction().setRollbackOnly();
+         }
+     }
+        
+    public boolean shouldFlushBeforeQuery(UnitOfWorkImpl uow){
+        return true;
     }
-        
+    
+    // From old parent
+    //protected void throwCheckTransactionFailedException() {
+      //  throw TransactionException.transactionNotActive();
+    //}
+
     protected void throwCheckTransactionFailedException() {
         throw new TransactionRequiredException(TransactionException.transactionNotActive().getMessage());
-    }
+    }    
 }
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/EntityTransactionImpl.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/EntityTransactionImpl.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/EntityTransactionImpl.java	(working copy)
@@ -9,31 +9,180 @@
  ******************************************************************************/  
 package org.eclipse.persistence.internal.jpa.transaction;
 
+import javax.persistence.RollbackException;
+
+import org.eclipse.persistence.exceptions.TransactionException;
+import org.eclipse.persistence.internal.jpa.RepeatableWriteUnitOfWork;
+import org.eclipse.persistence.internal.jpa.transaction.EntityTransactionWrapper;
+import org.eclipse.persistence.internal.localization.ExceptionLocalization;
+
 /**
  * JDK 1.5 version of the EntityTransaction.  Differs from base version only in that
  * it takes a JDK 1.5 version of the EntityTransactionWrapper.
  *
  * @see org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl
  */
-public class EntityTransactionImpl 
-    extends org.eclipse.persistence.internal.jpa.transaction.base.EntityTransactionImpl
-    implements javax.persistence.EntityTransaction 
-{
+public class EntityTransactionImpl implements javax.persistence.EntityTransaction {
+    protected EntityTransactionWrapper wrapper;
+    
+    protected boolean active = false;
+    
+    protected boolean rollbackOnly = false;
+
     public EntityTransactionImpl(EntityTransactionWrapper wrapper) {
-        super(wrapper);
-    }       
-	/**
-     * Commit the current transaction, writing any un-flushed changes to the database.
-     * This can only be invoked if {@link #isActive()} returns <code>true</code>.
-     * @throws IllegalStateException if isActive() is false.
-     * @throws PersistenceException if the commit fails.
+        this.wrapper = wrapper;
+    }
+    
+    /**
+     * Start the current transaction. This can only be invoked if {@link #isActive()} returns
+     * <code>false</code>.
+     * @throws IllegalStateException if isActive() is true.
      */
-    public void commit(){
-      try{
-        super.commit();
-      }catch (org.eclipse.persistence.exceptions.EclipseLinkException tlException ) {
+    public void begin(){
+    	if (isActive()){
+    		throw new IllegalStateException(TransactionException.transactionIsActive().getMessage());
+    	}
+    	
+    	if (this.wrapper.getEntityManager().isExtended()){
+    		// so we have a resource local extended em so get the PC from the entity manager
+    		this.wrapper.localUOW = this.wrapper.getEntityManager().getActivePersistenceContext(null);
+    		this.wrapper.localUOW.setShouldTerminateTransaction(false);
+    	} else {
+    		this.wrapper.localUOW = new RepeatableWriteUnitOfWork(this.wrapper.getEntityManager().getServerSession().acquireClientSession());
+    		this.wrapper.localUOW.setShouldTerminateTransaction(false);
+    		this.wrapper.localUOW.setShouldCascadeCloneToJoinedRelationship(true);
+    	}
+    	
+    	this.active = true;
+    }
+
+  /**
+   * Commit the current transaction, writing any un-flushed changes to the database.
+   * This can only be invoked if {@link #isActive()} returns <code>true</code>.
+   * @throws IllegalStateException if isActive() is false.
+   * @throws PersistenceException if the commit fails.
+   */
+  public void commit(){
+    try{
+      commitInternal();
+    }catch (org.eclipse.persistence.exceptions.EclipseLinkException tlException ) {
 		//put here to avoid EJB3.0 dependencies in TopLink for jdk 1.4 
-        throw new javax.persistence.RollbackException(tlException);
-      }
-    } 
+      throw new javax.persistence.RollbackException(tlException);
+    }
+  } 
+  
+  /**
+   * Commit the current transaction, writing any un-flushed changes to the database.
+   * This can only be invoked if {@link #isActive()} returns <code>true</code>.
+   * @throws IllegalStateException if isActive() is false.
+   */
+  protected void commitInternal(){
+    if (!isActive()){
+      throw new IllegalStateException(TransactionException.transactionNotActive().getMessage());
+    }
+    try {
+        if (this.wrapper.localUOW != null){
+            this.wrapper.localUOW.setShouldTerminateTransaction(true);
+            if (! this.rollbackOnly){
+                if (this.wrapper.localUOW.shouldResumeUnitOfWorkOnTransactionCompletion()){
+                    this.wrapper.localUOW.commitAndResume();
+                    return;
+                }else{
+                  this.wrapper.localUOW.commit();
+                  // all change sets and are cleared, but the cache is kept
+                  this.wrapper.localUOW.clearForClose(false);
+                }
+            } else {
+                throw new RollbackException(ExceptionLocalization.buildMessage("rollback_because_of_rollback_only"));
+            }
+        }
+    }catch (RuntimeException ex){
+        if (this.wrapper.localUOW != null){
+            wrapper.getEntityManager().removeExtendedPersistenceContext();
+            this.wrapper.localUOW.release();
+            this.wrapper.localUOW.getParent().release();
+        }
+        if(! this.rollbackOnly) {
+            throw new RollbackException(ex);
+        } else {
+            // it's a RollbackException
+            throw ex;
+        }
+    } finally {
+        this.active = false;
+        this.rollbackOnly = false;
+        wrapper.setLocalUnitOfWork(null);            
+    }
+  }
+
+  /**
+   * Roll back the current transaction, discarding any changes that have happened
+   * in this transaction. This can only be invoked if {@link #isActive()} returns
+   * <code>true</code>.
+   * @throws IllegalStateException if isActive() is false.
+   */
+  public void rollback(){
+    if (!isActive()){
+      throw new IllegalStateException(TransactionException.transactionNotActive().getMessage());
+    }
+    try{
+        if (wrapper.getLocalUnitOfWork() != null){
+            this.wrapper.localUOW.setShouldTerminateTransaction(true);
+            this.wrapper.localUOW.release();
+            this.wrapper.localUOW.getParent().release();
+        }
+    }finally{
+        this.active = false;
+        this.rollbackOnly = false;
+        wrapper.getEntityManager().removeExtendedPersistenceContext();
+        wrapper.setLocalUnitOfWork(null);            
+    }
+  }
+
+  /**
+   * Mark the current transaction so that the only possible
+   * outcome of the transaction is for the transaction to be
+   * rolled back.
+   * @throws IllegalStateException if isActive() is false.
+   */
+  public void setRollbackOnly(){
+	  if (!isActive()){
+		  throw new IllegalStateException(TransactionException.transactionNotActive().getMessage());
+	  }
+	  
+	  this.rollbackOnly = true;
+  }
+
+/**
+ * Here incase a user does not commit or rollback an enityTransaction but just
+ * throws it away.  If we do not rollback the txn the connection will go
+ * back into the pool.
+ */
+protected void finalize() throws Throwable{
+    try{
+        if (isActive())
+            this.rollback();
+    }finally{
+        super.finalize();
+    }
 }
+
+/**
+* Determine whether the current transaction has been marked
+* for rollback.
+* @throws IllegalStateException if isActive() is false.
+*/
+public boolean getRollbackOnly(){
+    if (!isActive()){
+        throw new IllegalStateException(TransactionException.transactionNotActive().getMessage());
+    }
+    return this.rollbackOnly;
+}
+
+	/**
+   * Check to see if the current transaction is in progress.
+   */
+  public boolean isActive(){
+      return this.active;
+  }
+}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/JTATransactionWrapper.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/JTATransactionWrapper.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/JTATransactionWrapper.java	(working copy)
@@ -12,6 +12,9 @@
 import javax.persistence.EntityTransaction;
 import javax.persistence.TransactionRequiredException;
 import org.eclipse.persistence.internal.jpa.EntityManagerImpl;
+import org.eclipse.persistence.internal.jpa.RepeatableWriteUnitOfWork;
+import org.eclipse.persistence.internal.sessions.UnitOfWorkImpl;
+import org.eclipse.persistence.transaction.AbstractTransactionController;
 import org.eclipse.persistence.exceptions.TransactionException;
 
 /**
@@ -22,24 +25,116 @@
  * 
  * @see org.eclipse.persistence.internal.jpa.transactionJTATransactionWrapper
  */
-public class JTATransactionWrapper 
-    extends org.eclipse.persistence.internal.jpa.transaction.base.JTATransactionWrapper 
-    implements TransactionWrapper
-{
+public class JTATransactionWrapper extends TransactionWrapperImpl implements TransactionWrapper {
 
+	 //This is a quick reference for the external Transaction Controller
+    protected AbstractTransactionController txnController;
+    
     public JTATransactionWrapper(EntityManagerImpl entityManager) {
         super(entityManager);
+        this.txnController = (AbstractTransactionController)entityManager.getServerSession().getExternalTransactionController();
     }
+
+    /**
+     * INTERNAL:
+     * This method will be used to check for a transaction and throws exception if none exists.
+     * If this methiod returns without exception then a transaction exists.
+     * This method must be called before accessing the localUOW.
+     */
+    public Object checkForTransaction(boolean validateExistence){
+        Object transaction = this.txnController.getTransaction();
+        if (validateExistence && (transaction == null)){
+            throwCheckTransactionFailedException();
+        }
+        return transaction;
+    }
+
+    /**
+     * INTERNAL:
+     * Internal clear the underlying data structures that this transaction owns.
+     */
+    public void clear(){
+        if (txnKey != null && this.entityManager.shouldPropagatePersistenceContext()){
+            this.txnController.getUnitsOfWork().remove(txnKey);
+        }      
+        localUOW.release();
+        localUOW = null;
+    }
     
-  /**
-   *  An ENtityTransaction cannot be used at the same time as a JTA transaction
-   *  throw an exception
-   */
+    /**
+     *  An ENtityTransaction cannot be used at the same time as a JTA transaction
+     *  throw an exception
+     */
     public EntityTransaction getTransaction(){
-        throw new IllegalStateException(TransactionException.entityTransactionWithJTANotAllowed().getMessage());
+      throw new IllegalStateException(TransactionException.entityTransactionWithJTANotAllowed().getMessage());
     }
+      
+    /**
+    * INTERNAL:
+    * Mark the current transaction so that the only possible
+    * outcome of the transaction is for the transaction to be
+    * rolled back.
+    * This is an internal method and if the txn is not active will do nothing
+    */
+    public void setRollbackOnlyInternal() {
+        if(txnController.getTransaction() != null) {
+            txnController.markTransactionForRollback();
+        }
+    }
 
+    /**
+     * INTERNAL:
+     * THis method is used to get the active UnitOfWork.  It is special in that it will
+     * return the required RepeatableWriteUnitOfWork required by the EntityManager.  Once 
+     * RepeatableWrite is merged into existing UnitOfWork this code can go away.
+     */
+    public RepeatableWriteUnitOfWork getTransactionalUnitOfWork(Object transaction){
+        if (transaction == null){
+            return null;
+        }
+        if (this.entityManager.shouldPropagatePersistenceContext()){
+            Object newTxnKey = this.txnController.getTransactionKey(transaction);
+            if (this.txnKey == newTxnKey){
+                return (RepeatableWriteUnitOfWork)this.localUOW;
+            }
+            this.txnKey = newTxnKey;
+            this.localUOW = (RepeatableWriteUnitOfWork)this.txnController.lookupActiveUnitOfWork(transaction);
+            if (this.localUOW == null){
+                this.localUOW = new RepeatableWriteUnitOfWork(entityManager.getServerSession().acquireClientSession());
+                this.localUOW.registerWithTransactionIfRequired();
+                this.localUOW.setShouldCascadeCloneToJoinedRelationship(true);
+                this.txnController.getUnitsOfWork().put(newTxnKey, this.localUOW);
+            }
+        }else if (this.localUOW == null){
+            this.localUOW = new RepeatableWriteUnitOfWork(entityManager.getServerSession().acquireClientSession());
+            this.localUOW.registerWithTransactionIfRequired();
+            this.localUOW.setShouldCascadeCloneToJoinedRelationship(true);
+        }
+        return (RepeatableWriteUnitOfWork)this.localUOW;
+    }
+    
+    protected void throwUserTransactionException() {
+        throw TransactionException.entityTransactionWithJTANotAllowed();
+    }
+
     protected void throwCheckTransactionFailedException() {
         throw new TransactionRequiredException(TransactionException.externalTransactionNotActive().getMessage());
     }
+    
+    // From old parent.
+    //protected void throwCheckTransactionFailedException() {
+      //  throw TransactionException.externalTransactionNotActive();
+    //}
+
+    public void registerUnitOfWorkWithTxn(UnitOfWorkImpl uow){
+        uow.registerWithTransactionIfRequired();
+    }
+    
+    /**
+     * We should only flush the entity manager before the query if the query is
+     * joined to a transaction
+     */
+    public boolean shouldFlushBeforeQuery(UnitOfWorkImpl uow){
+        return uow.isSynchronized();
+    }
 }
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/TransactionImpl.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/TransactionImpl.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/TransactionImpl.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.transaction.base;
+package org.eclipse.persistence.internal.jpa.transaction;
 
 import java.lang.reflect.Proxy;
 import java.lang.reflect.InvocationHandler;
@@ -16,9 +16,9 @@
 import javax.transaction.xa.XAResource;
 import javax.transaction.*;
 import org.eclipse.persistence.exceptions.TransactionException;
-import org.eclipse.persistence.internal.jpa.base.ExceptionFactory;
-import org.eclipse.persistence.internal.jpa.jdbc.base.ConnectionProxyHandler;
-import org.eclipse.persistence.internal.jpa.jdbc.base.DataSourceImpl;
+import org.eclipse.persistence.internal.jpa.ExceptionFactory;
+import org.eclipse.persistence.internal.jpa.jdbc.ConnectionProxyHandler;
+import org.eclipse.persistence.internal.jpa.jdbc.DataSourceImpl;
 
 /**
  * Implementation of JTA Transaction class. The guts of the tx logic
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/TransactionWrapperImpl.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/TransactionWrapperImpl.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/TransactionWrapperImpl.java	(working copy)
@@ -7,10 +7,10 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.transaction.base;
+package org.eclipse.persistence.internal.jpa.transaction;
 
 import org.eclipse.persistence.exceptions.TransactionException;
-import org.eclipse.persistence.internal.jpa.base.*;
+import org.eclipse.persistence.internal.jpa.*;
 import org.eclipse.persistence.internal.sessions.UnitOfWorkImpl;
 
 public abstract class TransactionWrapperImpl  {
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/base/TransactionManagerImpl.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/base/TransactionManagerImpl.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/base/TransactionManagerImpl.java	(working copy)
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.transaction.base;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import javax.transaction.*;
-import org.eclipse.persistence.internal.jpa.base.ExceptionFactory;
-import org.eclipse.persistence.internal.jpa.jdbc.base.DataSourceImpl;
-
-/**
- * Implementation of JTA Transaction manager class.
- *
- * Currently support is limited to enlisting a single tx data source
- */
-public class TransactionManagerImpl implements TransactionManager, UserTransaction {
-    // Not null when a transaction is active
-    TransactionImpl tx;
-
-    /************************/
-    /***** Internal API *****/
-    /************************/
-    private void debug(String s) {
-        System.out.println(s);
-    }
-
-    /*
-     * Used to create the single instance
-     */
-    public TransactionManagerImpl() {
-        this.tx = null;
-    }
-
-    /*
-     * Return true if a transaction has been explicitly begun
-     */
-    public boolean isTransactionActive() {
-        return tx != null;
-    }
-
-    /*
-     * Return a Connection if a transaction is active, otherwise return null
-     */
-    public Connection getConnection(DataSourceImpl ds, String user, String password) throws SQLException {
-        return (tx == null) ? null : tx.getConnection(ds, user, password);
-    }
-
-    /************************************************************/
-    /***** Supported TransactionManager/UserTransaction API *****/
-    /************************************************************/
-    public void begin() throws NotSupportedException, SystemException {
-        debug("Tx - begin");
-
-        if (isTransactionActive()) {
-            throw new ExceptionFactory().txActiveException();
-        }
-
-        // New transaction created by virtue of Transaction existence
-        tx = new TransactionImpl();
-    }
-
-    public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException {
-        debug("Tx - commit");
-
-        if (!isTransactionActive()) {
-            throw new ExceptionFactory().txNotActiveException();
-        }
-        try{
-            tx.commit();
-        }finally{
-            tx = null;
-        }
-    }
-
-    public int getStatus() throws SystemException {
-        return (!isTransactionActive()) ? Status.STATUS_NO_TRANSACTION : tx.getStatus();
-    }
-
-    public Transaction getTransaction() throws SystemException {
-        return tx;
-
-    }
-
-    public void rollback() throws IllegalStateException, SecurityException, SystemException {
-        debug("Tx - rollback");
-
-        if (!isTransactionActive()) {
-            throw new ExceptionFactory().txNotActiveException();
-        }
-        try{
-            tx.rollback();
-        }finally{
-            tx = null;
-        }
-    }
-
-    public void setRollbackOnly() throws IllegalStateException, SystemException {
-        debug("Tx - rollback");
-
-        if (!isTransactionActive()) {
-            throw new ExceptionFactory().txNotActiveException();
-        }
-        tx.setRollbackOnly();
-    }
-
-    /****************************************************************/
-    /***** NOT supported TransactionManager/UserTransaction API *****/
-    /****************************************************************/
-    public Transaction suspend() throws SystemException {
-        return null;
-    }
-
-    public void resume(Transaction transaction) throws InvalidTransactionException, IllegalStateException, SystemException {
-        // Do nothing
-    }
-
-    public void setTransactionTimeout(int i) throws SystemException {
-        // Do nothing
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/base/EntityTransactionWrapper.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/base/EntityTransactionWrapper.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/base/EntityTransactionWrapper.java	(working copy)
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.transaction.base;
-
-import javax.persistence.TransactionRequiredException;
-
-import org.eclipse.persistence.internal.jpa.base.*;
-import org.eclipse.persistence.exceptions.TransactionException;
-import org.eclipse.persistence.internal.localization.ExceptionLocalization;
-import org.eclipse.persistence.internal.sessions.UnitOfWorkImpl;
-
-/**
- * INTERNAL:
- * Base EntityTransactionWrapper
- * The EntityTransactionWrapper is used to make in transparent to an EntityManager
- * what kind of transaction is being used.  Transaction type can either be JTATransaction
- * or EntityTransaciton and they are mutually exclusive.  This is the implementation for
- * EntityTransaction
- * 
- * @see org.eclipse.persistence.internal.jpa.transaction.EntityTransactionWrapper
- * @see org.eclipse.persistence.internal.jpa.transaction.jdk14.EntityTransactionWrapper
- */
-public class EntityTransactionWrapper extends TransactionWrapperImpl {
-
-    protected EntityTransactionImpl entityTransaction;
-
-    public EntityTransactionWrapper(EntityManagerImpl entityManager) {
-        super(entityManager);
-    }
-    
-
-    /**
-     * INTERNAL:
-     * This method will be used to check for a transaction and throws exception if none exists.
-     * If this methiod returns without exception then a transaction exists.
-     * This method must be called before accessing the localUOW.
-     */
-    public Object checkForTransaction(boolean validateExistence){
-        if (entityTransaction != null && entityTransaction.isActive()) {
-            return entityTransaction;
-        }
-        if (validateExistence){
-            throwCheckTransactionFailedException();
-        }
-        return null;
-    }
-
-    /**
-     * INTERNAL:
-     * THis method is used to get the active UnitOfWork.  It is special in that it will
-     * return the required RepeatableWriteUnitOfWork required by the EntityManager.  Once 
-     * RepeatableWrite is merged into existing UnitOfWork this code can go away.
-     */
-    public RepeatableWriteUnitOfWork getTransactionalUnitOfWork(Object transaction){
-        if (transaction == null){
-            return null;
-        }
-        if (this.localUOW == null){
-            this.localUOW = new RepeatableWriteUnitOfWork(entityManager.getServerSession().acquireClientSession());
-            this.localUOW.setShouldCascadeCloneToJoinedRelationship(true);
-        }
-        return (RepeatableWriteUnitOfWork)this.localUOW;
-    }
-    
-    public EntityManagerImpl getEntityManager(){
-        return entityManager;
-    }
-
-    public void registerUnitOfWorkWithTxn(UnitOfWorkImpl uow){
-        throw new TransactionRequiredException(ExceptionLocalization.buildMessage("join_trans_called_on_entity_trans"));// no JTA transactions availab
-    }
-    
-    /**
-    * Mark the current transaction so that the only possible
-    * outcome of the transaction is for the transaction to be
-    * rolled back.
-    * This is an internal method and if the txn is not active will do nothing
-    */
-    public void setRollbackOnlyInternal(){
-        if (entityTransaction != null && entityTransaction.isActive()){
-            entityTransaction.setRollbackOnly();
-        }
-    }
-        
-    public boolean shouldFlushBeforeQuery(UnitOfWorkImpl uow){
-        return true;
-    }
-    
-    protected void throwCheckTransactionFailedException() {
-        throw TransactionException.transactionNotActive();
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/base/EntityTransactionImpl.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/base/EntityTransactionImpl.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/base/EntityTransactionImpl.java	(working copy)
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.transaction.base;
-
-import javax.persistence.RollbackException;
-
-import org.eclipse.persistence.exceptions.TransactionException;
-import org.eclipse.persistence.internal.jpa.base.RepeatableWriteUnitOfWork;
-import org.eclipse.persistence.internal.localization.ExceptionLocalization;
-
-/**
- * INTERNAL:
- * Base EntityTransactionImpl
- * This is a thin wrapper around a UnitOfWork that implements functionality required
- * by the EntityTransaction interface.  The actual interface is implemented by two subclasses:
- *
- * @see org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl
- * @see org.eclipse.persistence.internal.jpa.transaction.jdk14.EntityTransactionImpl
- *
- * The EntityTransaction is a thin wrapper around a UnitOFWork.
- */
-public class EntityTransactionImpl {
-
-        protected EntityTransactionWrapper wrapper;
-        
-        protected boolean active = false;
-        
-        protected boolean rollbackOnly = false;
-
-        public EntityTransactionImpl(EntityTransactionWrapper wrapper) {
-            this.wrapper = wrapper;
-        }
-      /**
-       * Start the current transaction. This can only be invoked if {@link #isActive()} returns
-       * <code>false</code>.
-       * @throws IllegalStateException if isActive() is true.
-       */
-      public void begin(){
-        if (isActive()){
-          throw new IllegalStateException(TransactionException.transactionIsActive().getMessage());
-        }
-        if (this.wrapper.getEntityManager().isExtended()){
-            // so we have a resource local extended em so get the PC from the entity manager
-            this.wrapper.localUOW = this.wrapper.getEntityManager().getActivePersistenceContext(null);
-            this.wrapper.localUOW.setShouldTerminateTransaction(false);
-        }else{
-            this.wrapper.localUOW = new RepeatableWriteUnitOfWork(this.wrapper.getEntityManager().getServerSession().acquireClientSession());
-            this.wrapper.localUOW.setShouldTerminateTransaction(false);
-            this.wrapper.localUOW.setShouldCascadeCloneToJoinedRelationship(true);
-        }
-        this.active = true;
-      }
- 
-      /**
-       * Commit the current transaction, writing any un-flushed changes to the database.
-       * This can only be invoked if {@link #isActive()} returns <code>true</code>.
-       * @throws IllegalStateException if isActive() is false.
-       */
-      public void commit(){
-        if (!isActive()){
-          throw new IllegalStateException(TransactionException.transactionNotActive().getMessage());
-        }
-        try {
-            if (this.wrapper.localUOW != null){
-                this.wrapper.localUOW.setShouldTerminateTransaction(true);
-                if (! this.rollbackOnly){
-                    if (this.wrapper.localUOW.shouldResumeUnitOfWorkOnTransactionCompletion()){
-                        this.wrapper.localUOW.commitAndResume();
-                        return;
-                    }else{
-                      this.wrapper.localUOW.commit();
-                      // all change sets and are cleared, but the cache is kept
-                      this.wrapper.localUOW.clearForClose(false);
-                    }
-                } else {
-                    throw new RollbackException(ExceptionLocalization.buildMessage("rollback_because_of_rollback_only"));
-                }
-            }
-        }catch (RuntimeException ex){
-            if (this.wrapper.localUOW != null){
-                wrapper.getEntityManager().removeExtendedPersistenceContext();
-                this.wrapper.localUOW.release();
-                this.wrapper.localUOW.getParent().release();
-            }
-            if(! this.rollbackOnly) {
-                throw new RollbackException(ex);
-            } else {
-                // it's a RollbackException
-                throw ex;
-            }
-        } finally {
-            this.active = false;
-            this.rollbackOnly = false;
-            wrapper.setLocalUnitOfWork(null);            
-        }
-      }
- 
-      /**
-       * Roll back the current transaction, discarding any changes that have happened
-       * in this transaction. This can only be invoked if {@link #isActive()} returns
-       * <code>true</code>.
-       * @throws IllegalStateException if isActive() is false.
-       */
-      public void rollback(){
-        if (!isActive()){
-          throw new IllegalStateException(TransactionException.transactionNotActive().getMessage());
-        }
-        try{
-            if (wrapper.getLocalUnitOfWork() != null){
-                this.wrapper.localUOW.setShouldTerminateTransaction(true);
-                this.wrapper.localUOW.release();
-                this.wrapper.localUOW.getParent().release();
-            }
-        }finally{
-            this.active = false;
-            this.rollbackOnly = false;
-            wrapper.getEntityManager().removeExtendedPersistenceContext();
-            wrapper.setLocalUnitOfWork(null);            
-        }
-      }
- 
-    /**
-    * Mark the current transaction so that the only possible
-    * outcome of the transaction is for the transaction to be
-    * rolled back.
-    * @throws IllegalStateException if isActive() is false.
-    */
-    public void setRollbackOnly(){
-        if (!isActive()){
-            throw new IllegalStateException(TransactionException.transactionNotActive().getMessage());
-        }
-        this.rollbackOnly = true;
-    }
-    
-    /**
-     * Here incase a user does not commit or rollback an enityTransaction but just
-     * throws it away.  If we do not rollback the txn the connection will go
-     * back into the pool.
-     */
-    protected void finalize() throws Throwable{
-        try{
-            if (isActive())
-                this.rollback();
-        }finally{
-            super.finalize();
-        }
-    }
-    /**
-    * Determine whether the current transaction has been marked
-    * for rollback.
-    * @throws IllegalStateException if isActive() is false.
-    */
-    public boolean getRollbackOnly(){
-        if (!isActive()){
-            throw new IllegalStateException(TransactionException.transactionNotActive().getMessage());
-        }
-        return this.rollbackOnly;
-    }
-    
-    /**
-       * Check to see if the current transaction is in progress.
-       */
-      public boolean isActive(){
-          return this.active;
-      }      
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/base/JTATransactionWrapper.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/base/JTATransactionWrapper.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/base/JTATransactionWrapper.java	(working copy)
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.transaction.base;
-
-import org.eclipse.persistence.transaction.AbstractTransactionController;
-import org.eclipse.persistence.exceptions.TransactionException;
-import org.eclipse.persistence.internal.jpa.base.*;
-import org.eclipse.persistence.internal.sessions.UnitOfWorkImpl;
-
-/**
- * INTERNAL:
- * Base JTATransactionWrapper
- * The JTATransactionWrapper is used to make in transparent to an EntityManager
- * what kind of transaction is being used.  Transaction type can either be JTATransaction
- * or EntityTransaciton and they are mutually exclusive.  This is the implementation for JTA
- * Transaction
- * 
- * @see org.eclipse.persistence.internal.jpa.transaction.JTATransactionWrapper
- * @see org.eclipse.persistence.internal.jpa.transaction.jdk14.JTATransactionWrapper
- */
-public class JTATransactionWrapper extends TransactionWrapperImpl {
-
-    //This is a quick reference for the external Transaction Controller
-    protected AbstractTransactionController txnController;
-    
-    public JTATransactionWrapper(EntityManagerImpl entityManager) {
-        super(entityManager);
-        this.txnController = (AbstractTransactionController)entityManager.getServerSession().getExternalTransactionController();
-    }
-
-    /**
-     * INTERNAL:
-     * This method will be used to check for a transaction and throws exception if none exists.
-     * If this methiod returns without exception then a transaction exists.
-     * This method must be called before accessing the localUOW.
-     */
-    public Object checkForTransaction(boolean validateExistence){
-        Object transaction = this.txnController.getTransaction();
-        if (validateExistence && (transaction == null)){
-            throwCheckTransactionFailedException();
-        }
-        return transaction;
-    }
-
-    /**
-     * INTERNAL:
-     * Internal clear the underlying data structures that this transaction owns.
-     */
-    public void clear(){
-        if (txnKey != null && this.entityManager.shouldPropagatePersistenceContext()){
-            this.txnController.getUnitsOfWork().remove(txnKey);
-        }      
-        localUOW.release();
-        localUOW = null;
-    }
-    
-    /**
-    * INTERNAL:
-    * Mark the current transaction so that the only possible
-    * outcome of the transaction is for the transaction to be
-    * rolled back.
-    * This is an internal method and if the txn is not active will do nothing
-    */
-    public void setRollbackOnlyInternal() {
-        if(txnController.getTransaction() != null) {
-            txnController.markTransactionForRollback();
-        }
-    }
-
-    /**
-     * INTERNAL:
-     * THis method is used to get the active UnitOfWork.  It is special in that it will
-     * return the required RepeatableWriteUnitOfWork required by the EntityManager.  Once 
-     * RepeatableWrite is merged into existing UnitOfWork this code can go away.
-     */
-    public RepeatableWriteUnitOfWork getTransactionalUnitOfWork(Object transaction){
-        if (transaction == null){
-            return null;
-        }
-        if (this.entityManager.shouldPropagatePersistenceContext()){
-            Object newTxnKey = this.txnController.getTransactionKey(transaction);
-            if (this.txnKey == newTxnKey){
-                return (RepeatableWriteUnitOfWork)this.localUOW;
-            }
-            this.txnKey = newTxnKey;
-            this.localUOW = (RepeatableWriteUnitOfWork)this.txnController.lookupActiveUnitOfWork(transaction);
-            if (this.localUOW == null){
-                this.localUOW = new RepeatableWriteUnitOfWork(entityManager.getServerSession().acquireClientSession());
-                this.localUOW.registerWithTransactionIfRequired();
-                this.localUOW.setShouldCascadeCloneToJoinedRelationship(true);
-                this.txnController.getUnitsOfWork().put(newTxnKey, this.localUOW);
-            }
-        }else if (this.localUOW == null){
-            this.localUOW = new RepeatableWriteUnitOfWork(entityManager.getServerSession().acquireClientSession());
-            this.localUOW.registerWithTransactionIfRequired();
-            this.localUOW.setShouldCascadeCloneToJoinedRelationship(true);
-        }
-        return (RepeatableWriteUnitOfWork)this.localUOW;
-    }
-    
-    protected void throwUserTransactionException() {
-        throw TransactionException.entityTransactionWithJTANotAllowed();
-    }
-
-    protected void throwCheckTransactionFailedException() {
-        throw TransactionException.externalTransactionNotActive();
-    }
-
-    public void registerUnitOfWorkWithTxn(UnitOfWorkImpl uow){
-        uow.registerWithTransactionIfRequired();
-    }
-    
-    /**
-     * We should only flush the entity manager before the query if the query is
-     * joined to a transaction
-     */
-    public boolean shouldFlushBeforeQuery(UnitOfWorkImpl uow){
-        return uow.isSynchronized();
-    }    
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/base/TransactionImpl.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/base/TransactionImpl.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/base/TransactionImpl.java	(working copy)
@@ -1,280 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.transaction.base;
-
-import java.lang.reflect.Proxy;
-import java.lang.reflect.InvocationHandler;
-import java.util.Vector;
-import java.sql.*;
-import javax.transaction.xa.XAResource;
-import javax.transaction.*;
-import org.eclipse.persistence.exceptions.TransactionException;
-import org.eclipse.persistence.internal.jpa.base.ExceptionFactory;
-import org.eclipse.persistence.internal.jpa.jdbc.base.ConnectionProxyHandler;
-import org.eclipse.persistence.internal.jpa.jdbc.base.DataSourceImpl;
-
-/**
- * Implementation of JTA Transaction class. The guts of the tx logic
- * is contained in this class.
- *
- * Currently support is limited to enlisting only a single tx data source
- */
-public class TransactionImpl implements Transaction {
-    // Set by client-induced rollback marking
-    boolean markedForRollback;
-
-    // Used to maintain the tx status 
-    int status;
-
-    // Collection of Synchronization listeners
-    Vector listeners;
-
-    // The transactional connection we use
-    Connection connection;
-    static Class proxyClass = Proxy.getProxyClass(Connection.class.getClassLoader(), new Class[] { Connection.class });
-
-    // The enlisted data source
-    DataSourceImpl dataSource;
-
-    /***** Static constants *****/
-
-    // Cribbed from java.transaction.Status
-    public static final int STATUS_ACTIVE = 0;
-    public static final int STATUS_MARKED_ROLLBACK = 1;
-    public static final int STATUS_PREPARED = 2;
-    public static final int STATUS_COMMITTED = 3;
-    public static final int STATUS_ROLLEDBACK = 4;
-    public static final int STATUS_UNKNOWN = 5;
-    public static final int STATUS_NO_TRANSACTION = 6;
-    public static final int STATUS_PREPARING = 7;
-    public static final int STATUS_COMMITTING = 8;
-    public static final int STATUS_ROLLING_BACK = 9;
-
-    // Set this to true for debugging of afterCompletion exceptions
-    public static boolean DUMP_AFTER_COMPLETION_ERRORS = true;
-
-    /************************/
-    /***** Internal API *****/
-    /************************/
-    private void debug(String s) {
-        System.out.println(s);
-    }
-
-    /*
-     * Constructor invoked and new instance created on tx begin
-     */
-    public TransactionImpl() {
-        markedForRollback = false;
-        status = STATUS_ACTIVE;
-        listeners = new Vector();
-    }
-
-    /*
-     * Lazily allocate the connection. This will be used
-     * by the data source if in a transaction.
-     */
-    public Connection getConnection(DataSourceImpl ds, String user, String password) throws SQLException {
-        // We don't have a datasource connection yet, so allocate one
-        if (connection == null) {
-            debug("TxImpl - allocating new connection");
-            dataSource = ds;
-            connection = ds.internalGetConnection(user, password);
-            connection.setAutoCommit(false);
-        } else {
-            // We already have a connection. Make sure the data sources are the same.
-            if (ds.getName() != dataSource.getName()) {
-                throw TransactionException.multipleResourceException();
-            }
-        }
-
-        //  return connection;
-        // Allocate and return a proxy for the connection
-        debug("TxImpl - creating connection proxy");
-        Connection proxyConnection = null;
-        try {
-            InvocationHandler handler = new ConnectionProxyHandler(connection);
-            proxyConnection = (Connection)proxyClass.getConstructor(new Class[] { InvocationHandler.class }).newInstance(new Object[] { handler });
-        } catch (Exception ex) {
-            throw TransactionException.internalProxyException(ex);
-        }
-        return proxyConnection;
-    }
-
-    /*
-     * Invoke afterCompletion callbacks.
-     * If DUMP_AFTER_COMPLETION_ERRORS flag is set then dump
-     * the exceptions to System.out, otherwise swallow them.
-     *
-     * NOTE: In either case it will not affect the outcome
-     * of the transaction.
-     */
-    public void invokeAfterCompletion() {
-        // Call all of the afterCompletion callbacks
-        debug("TxImpl - invoking afterCompletion");
-        int i;
-        int j;
-        for (i = 0, j = listeners.size(); i < j; i++) {
-            try {
-                ((Synchronization)listeners.elementAt(i)).afterCompletion(status);
-            } catch (Throwable t) {
-                if (DUMP_AFTER_COMPLETION_ERRORS) {
-                    t.printStackTrace(System.out);
-                }
-            }
-        }
-    }
-
-    /*
-     * Rollback the transaction on the connection.
-     */
-    public void rollbackConnection() throws SQLException {
-        if (connection != null) {
-            debug("TxImpl - rolling back connection");
-            status = STATUS_ROLLING_BACK;
-            connection.rollback();
-            status = STATUS_ROLLEDBACK;
-        }
-    }
-
-    /*
-     * Commit the transaction on the connection.
-     */
-    public void commitConnection() throws SQLException {
-        if (connection != null) {
-            debug("TxImpl - committing connection");
-            status = STATUS_COMMITTING;
-            connection.commit();
-            status = STATUS_COMMITTED;
-        }
-    }
-
-    /*
-     * Clean up after everything is over
-     */
-    public void cleanup() {
-        debug("TxImpl - cleanup");
-        if (connection != null) {
-            try {
-                connection.close();
-            } catch (Exception ex) {
-            }
-
-            // Ignore
-            connection = null;
-        }
-        status = STATUS_NO_TRANSACTION;
-    }
-
-    /*************************************/
-    /***** Supported Transaction API *****/
-    /*************************************/
-    public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException {
-        Exception error = null;
-
-        debug("TxImpl - commit");
-        // Make sure we are allowed to proceed
-        switch (status) {
-        case STATUS_ACTIVE:// This is the normal case - do nothing
-            break;
-        case STATUS_MARKED_ROLLBACK: {
-            // Tx was marked for rollback by the user, error
-            error = new ExceptionFactory().txMarkedForRollbackException();
-            break;
-        }
-        default:// Tx in some other state, error
-            throw new ExceptionFactory().invalidStateException(status);
-        }
-
-        // Call beforeCompletion callback. 
-        if (error == null) {
-            try {
-                debug("TxImpl - invoking beforeCompletion");
-                int i;
-                int j;
-                for (i = 0, j = listeners.size(); i < j; i++) {
-                    ((Synchronization)listeners.elementAt(i)).beforeCompletion();
-                }
-            } catch (Exception ex) {
-                error = ex;
-                status = STATUS_ROLLING_BACK;
-                debug("TxImpl - error in beforeCompletion: " + ex);
-            }
-        }
-
-        // Now if we didn't get any errors then commit the connection
-        if ((error == null) && (status == STATUS_ACTIVE)) {
-            try {
-                commitConnection();
-            } catch (Exception ex) {
-                error = ex;
-            }
-        } else {
-            try {
-                rollbackConnection();
-            } catch (Exception ex) {
-                error = ex;
-            }
-        }
-
-        // Whether we were successful or not, call afterCompletion and clean up
-        invokeAfterCompletion();
-        cleanup();
-
-        // Throw any error that may have occurred at any point in the commit
-        if (error != null) {
-            throw new ExceptionFactory().newSystemException(error);
-        }
-    }
-
-    public int getStatus() throws SystemException {
-        return status;
-    }
-
-    public void registerSynchronization(Synchronization synchronization) throws RollbackException, IllegalStateException, SystemException {
-        debug("TxImpl - registering sync listener: " + synchronization);
-        listeners.add(synchronization);
-    }
-
-    public void rollback() throws IllegalStateException, SystemException {
-        Exception error = null;
-
-        debug("TxImpl - rollback");
-        try {
-            rollbackConnection();
-        } catch (Exception ex) {
-            error = ex;
-        }
-
-        // Call afterCompletion callback and clean up
-        invokeAfterCompletion();
-        cleanup();
-
-        // Throw any error that may have occurred while rolling back
-        if (error != null) {
-            throw new ExceptionFactory().newSystemException(error);
-        }
-    }
-
-    public void setRollbackOnly() throws IllegalStateException, SystemException {
-        debug("TxImpl - setRollbackOnly");
-        status = STATUS_MARKED_ROLLBACK;
-    }
-
-    /*****************************************/
-    /***** NOT supported Transaction API *****/
-    /*****************************************/
-    public boolean enlistResource(XAResource xaresource) throws RollbackException, IllegalStateException, SystemException {
-        return false;
-    }
-
-    public boolean delistResource(XAResource xaresource, int i) throws IllegalStateException, SystemException {
-        return false;
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/base/TransactionWrapperImpl.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/base/TransactionWrapperImpl.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/transaction/base/TransactionWrapperImpl.java	(working copy)
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.transaction.base;
-
-import org.eclipse.persistence.exceptions.TransactionException;
-import org.eclipse.persistence.internal.jpa.base.*;
-import org.eclipse.persistence.internal.sessions.UnitOfWorkImpl;
-
-public abstract class TransactionWrapperImpl  {
-
-    protected EntityManagerImpl entityManager = null;
-        
-    //This attribute will store a reference to the non transactional UnitOfWork used
-    // for queries outside of a transaction
-    protected RepeatableWriteUnitOfWork localUOW;
-        
-    //used to cache the transactional UnitOfWork so that we do not need to look it up each time.
-    protected Object txnKey;
-    
-    
-    public TransactionWrapperImpl(EntityManagerImpl entityManager){
-        this.entityManager = entityManager;
-    }
-        
-    /**
-     * INTERNAL:
-     * This method will be used to check for a transaction and throws exception if none exists.
-     * If this methiod returns without exception then a transaction exists.
-     * This method must be called before accessing the localUOW.
-     */
-    public abstract Object checkForTransaction(boolean validateExistence);
- 
-    /**
-     * INTERNAL:
-     * Clears the transactional UnitOfWork
-     */
-    public void clear(){
-        if (this.localUOW != null){
-            // all change sets and cache are cleared
-            this.localUOW.clear(true);
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     * THis method is used to get the active UnitOfWork.  It is special in that it will
-     * return the required RepeatableWriteUnitOfWork required by the EntityManager.  Once
-     * RepeatableWrite is merged into existing UnitOfWork this code can go away.
-     * @param transaction
-     * @return
-     */
-    public abstract RepeatableWriteUnitOfWork getTransactionalUnitOfWork(Object transaction);
-
-    public abstract void registerUnitOfWorkWithTxn(UnitOfWorkImpl uow);
-    
-    public UnitOfWorkImpl getLocalUnitOfWork(){
-        return localUOW;
-    }
-
-    public void setLocalUnitOfWork(RepeatableWriteUnitOfWork uow){
-        this.localUOW = uow;
-    }
-
-    /**
-    * Mark the current transaction so that the only possible
-    * outcome of the transaction is for the transaction to be
-    * rolled back.
-    * This is an internal method and if the txn is not active will do nothing
-    */
-    public abstract void setRollbackOnlyInternal();
-    
-    /**
-     * This method will be called when a query is executed.  If changes in the entity manager
-     * should be flushed this method should return true
-     */
-    public abstract boolean shouldFlushBeforeQuery(UnitOfWorkImpl uow);
-    
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/EJBQueryImpl.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/EJBQueryImpl.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/EJBQueryImpl.java	(working copy)
@@ -10,14 +10,25 @@
 package org.eclipse.persistence.internal.jpa;
 
 import java.util.*;
+
 import javax.persistence.Query;
 import javax.persistence.TemporalType;
 import javax.persistence.FlushModeType;
 import javax.persistence.NoResultException;
 import javax.persistence.NonUniqueResultException;
 import org.eclipse.persistence.queries.*;
-import org.eclipse.persistence.jpa.*;
+import org.eclipse.persistence.sessions.DatabaseRecord;
+import org.eclipse.persistence.sessions.Session;
+import org.eclipse.persistence.jpa.JpaEntityManager;
+import org.eclipse.persistence.exceptions.QueryException;
 import org.eclipse.persistence.internal.helper.*;
+import org.eclipse.persistence.internal.jpa.EntityManagerImpl;
+import org.eclipse.persistence.internal.jpa.QueryHintsHandler;
+import org.eclipse.persistence.internal.jpa.parsing.JPQLParseTree;
+import org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser;
+import org.eclipse.persistence.internal.localization.ExceptionLocalization;
+import org.eclipse.persistence.internal.queries.JPQLCallQueryMechanism;
+import org.eclipse.persistence.internal.sessions.AbstractSession;
 
 /**
 * Concrete EJB 3.0 query class
@@ -31,23 +42,30 @@
 * temporal type parameters
 * Change single result to use ReadObjectQuery
 **/
-public class EJBQueryImpl extends org.eclipse.persistence.internal.jpa.base.EJBQueryImpl implements EJBQuery {
+public class EJBQueryImpl implements org.eclipse.persistence.jpa.JpaQuery {
+	protected DatabaseQuery databaseQuery = null;
+    protected EntityManagerImpl entityManager = null;
+    protected String queryName = null;
+    protected Map parameters = null;
+    protected int firstResultIndex = -1; // -1 indicates undefined
+    protected int maxResults = -1; // -1 indicates undefined
+    protected int maxRows = -1; // -1 indicates undefined    
 
     /**
      * Base constructor for EJBQueryImpl.  Initializes basic variables.
-     * An EJBQLQueryImpl may only ever be tied to one entityManager.
      */
     protected EJBQueryImpl(EntityManagerImpl entityManager) {
-        super(entityManager);
+        parameters = new HashMap();
+        this.entityManager = entityManager;
     }
 
     /**
      * Create an EJBQueryImpl with a TopLink query.
      * @param query
-     * @param entityManager
      */
     public EJBQueryImpl(DatabaseQuery query, EntityManagerImpl entityManager) {
-        super(query, entityManager);
+        this(entityManager);
+        this.databaseQuery = query;
     }
 
     /**
@@ -56,7 +74,7 @@
      * @param entityManager
      */
     public EJBQueryImpl(String ejbql, EntityManagerImpl entityManager) {
-        super(ejbql, entityManager);
+        this(ejbql, entityManager, false);
     }
 
     /**
@@ -66,82 +84,343 @@
      * @param isNamedQuery determines whether to treat the query description as ejbql or a query name
      */
     public EJBQueryImpl(String queryDescription, EntityManagerImpl entityManager, boolean isNamedQuery) {
-        super(queryDescription, entityManager, isNamedQuery);
+        this(entityManager);
+        if (isNamedQuery) {
+            this.queryName = queryDescription;
+        } else {
+            if (databaseQuery == null) {
+                databaseQuery = buildEJBQLDatabaseQuery(queryDescription, getActiveSession());
+            }
+        }
     }
 
     /**
-     *  Convert the given object to the class represented by the given temporal type.
-     *  @return an object represting the given TemporalType
+     * Internal method to change the wrapped query to a DataModifyQuery if neccessary
      */
-    protected Object convertTemporalType(Object value, TemporalType type) {
-        ConversionManager conversionManager = ((org.eclipse.persistence.internal.sessions.AbstractSession)getEntityManager().getActiveSession()).getDatasourcePlatform().getConversionManager();
-        if (type == TemporalType.TIME) {
-            return conversionManager.convertObject(value, ClassConstants.TIME);
-        } else if (type == TemporalType.TIMESTAMP) {
-            return conversionManager.convertObject(value, ClassConstants.TIMESTAMP);
-        } else if (type == TemporalType.DATE) {
-            return conversionManager.convertObject(value, ClassConstants.SQLDATE);
+    protected void setAsSQLModifyQuery(){
+        if (getDatabaseQuery().isDataReadQuery()){
+            DataModifyQuery query = new DataModifyQuery();
+            query.setSQLString(databaseQuery.getSQLString());
+            query.setIsUserDefined(databaseQuery.isUserDefined());
+            query.setFlushOnExecute(databaseQuery.getFlushOnExecute());
+            databaseQuery = query;
         }
-        return value;
     }
 
     /**
-     * Return the entityManager this query is tied to.
+     * Internal method to change the wrapped query to a DataReadQuery if neccessary
      */
-    public EntityManager getEntityManager() {
-        return (EntityManager)entityManager;
+    protected void setAsSQLReadQuery(){
+        if(getDatabaseQuery().isDataModifyQuery()){
+            DataReadQuery query = new DataReadQuery();
+            query.setUseAbstractRecord(false);
+            query.setSQLString(databaseQuery.getSQLString());
+            query.setIsUserDefined(databaseQuery.isUserDefined());
+            query.setFlushOnExecute(databaseQuery.getFlushOnExecute());
+            databaseQuery = query;
+        }
     }
 
     /**
-    * Set the position of the first result to retrieve.
-    * @param start position of the first result, numbered from 0
-    * @return the same query instance
-    */
-    public Query setFirstResult(int startPosition) {
-        try {
-            entityManager.verifyOpen();
-            setFirstResultInternal(startPosition);
-            return this;
-        } catch (RuntimeException e) {
-            setRollbackOnly();
-            throw e;
+     * Build a DatabaseQuery from an EJBQL string.
+     * @param ejbql
+     * @param session the session to get the descriptors for this query for.
+     * @return a DatabaseQuery representing the given ejbql
+     */
+    public static DatabaseQuery buildEJBQLDatabaseQuery(String ejbql, Session session) {
+        return buildEJBQLDatabaseQuery(ejbql, null, session);
+    }
+    
+    /**
+     * Build a DatabaseQuery from an EJBQL string.
+     * 
+     * @param ejbql
+     * @param session the session to get the descriptors for this query for.
+     * @param hints a list of hints to be applied to the query
+     * @return a DatabaseQuery representing the given ejbql
+     */
+    public static DatabaseQuery buildEJBQLDatabaseQuery(String ejbql, Session session, HashMap hints) {
+        return buildEJBQLDatabaseQuery(null, ejbql, null, session, hints, null);
+    }
+    
+    /**
+     * Build a DatabaseQuery from an EJBQL string.
+     * 
+     * @param ejbql
+     * @param session the session to get the descriptors for this query for.
+     * @param hints a list of hints to be applied to the query
+     * @param classLoader the class loader to build the query with
+     * @return a DatabaseQuery representing the given ejbql
+     */
+    public static DatabaseQuery buildEJBQLDatabaseQuery(String ejbql, Session session, HashMap hints, ClassLoader classLoader) {
+        return buildEJBQLDatabaseQuery(null, ejbql, null, session, hints, classLoader);
+    }
+    
+    /**
+     * Build a DatabaseQuery from an EJBQL string.
+     * @param ejbql
+     * @parem flushOnExecute
+     * @param session the session to get the descriptors for this query for.
+     * @return a DatabaseQuery representing the given ejbql
+     */
+    public static DatabaseQuery buildEJBQLDatabaseQuery(String ejbql,  Boolean flushOnExecute, Session session) {
+        return buildEJBQLDatabaseQuery(null, ejbql, flushOnExecute, session, null, null);
+    }
+    
+    /**
+     * Build a DatabaseQuery from an EJBQL string.
+     * @param ejbql
+     * @parem flushOnExecute
+     * @param session the session to get the descriptors for this query for.
+     * @return a DatabaseQuery representing the given ejbql
+     */
+    public static DatabaseQuery buildEJBQLDatabaseQuery(String ejbql,  Boolean flushOnExecute, Session session, ClassLoader classLoader) {
+        return buildEJBQLDatabaseQuery(null, ejbql, flushOnExecute, session, null, classLoader);
+    }
+    
+    /**
+     * Build a DatabaseQuery from an JPQL string.
+     * 
+     * @param jpql the JPQL string.
+     * @param flushOnExecute flush the unit of work before executing the query.
+     * @param session the session to get the descriptors for this query for.
+     * @param hints a list of hints to be applied to the query.
+     * @return a DatabaseQuery representing the given jpql.
+     */
+    public static DatabaseQuery buildEJBQLDatabaseQuery(String queryName, String jpql, 
+            Boolean flushOnExecute, Session session, HashMap hints, ClassLoader classLoader) {            
+        // PERF: Check if the JPQL has already been parsed.
+        // Only allow queries with default properties to be parse cached.
+        boolean isCacheable = (queryName == null) && (hints == null) && (flushOnExecute == null);
+        DatabaseQuery databaseQuery = null;
+        if (isCacheable) {
+            databaseQuery = (DatabaseQuery)session.getProject().getJPQLParseCache().get(jpql);            
         }
+        if ((databaseQuery == null) || (!databaseQuery.isPrepared())) {
+            JPQLParseTree parseTree = JPQLParser.buildParseTree(queryName, jpql);
+            parseTree.setClassLoader(classLoader);
+            databaseQuery = parseTree.createDatabaseQuery();
+            databaseQuery.setJPQLString(jpql);
+            parseTree.populateQuery(databaseQuery, (AbstractSession)session);            
+            // If the query uses fetch joins, need to use JPA default of not filtering duplicates.
+            if (databaseQuery.isReadAllQuery()) {
+                ReadAllQuery readAllQuery = (ReadAllQuery)databaseQuery;
+                if (readAllQuery.hasJoining() && (readAllQuery.getDistinctState() == ReadAllQuery.DONT_USE_DISTINCT)) {
+                    readAllQuery.setShouldFilterDuplicates(false);
+                }
+            }
+            // Bug#4646580  Add arguments to query.
+            parseTree.addParametersToQuery(databaseQuery);
+            ((JPQLCallQueryMechanism)databaseQuery.getQueryMechanism()).getJPQLCall().setIsParsed(true);
+            databaseQuery.setFlushOnExecute(flushOnExecute);            
+
+            //GF#1324 eclipselink.refresh query hint does not cascade
+            //cascade by mapping as default for read query
+            if(databaseQuery.isReadQuery ()) {
+                databaseQuery.cascadeByMapping();
+            }
+
+            // Apply any query hints.
+            databaseQuery = applyHints(hints, databaseQuery);
+            if (isCacheable) {
+                // Prepare query as hint may cause cloning (but not un-prepare as in read-only).
+                databaseQuery.prepareCall(session, new DatabaseRecord());
+                databaseQuery.setIsFromParseCache(true);
+                session.getProject().getJPQLParseCache().put(jpql, databaseQuery);
+            }
+        }
+        
+        return databaseQuery;
     }
+    
+    /**
+     * Build a ReadAllQuery from a class and sql string.
+     */
+    public static DatabaseQuery buildSQLDatabaseQuery(Class resultClass, String sqlString) {
+        return buildSQLDatabaseQuery(resultClass, sqlString, null);
+    }
+    
+    /**
+     * Build a ReadAllQuery for class and sql string.
+     * 
+     * @param hints a list of hints to be applied to the query.
+     */
+    public static DatabaseQuery buildSQLDatabaseQuery(Class resultClass, String sqlString, HashMap hints) {
+        ReadAllQuery query = new ReadAllQuery(resultClass);
+        query.setSQLString(sqlString);
+        query.setIsUserDefined(true);
+        
+        // apply any query hints
+        return applyHints(hints, query);
+    }
+    /**
+     * Build a ResultSetMappingQuery from a sql result set mapping name and sql string.
+     */
+    public static DatabaseQuery buildSQLDatabaseQuery(String sqlResultSetMappingName, String sqlString) {
+        return buildSQLDatabaseQuery(sqlResultSetMappingName, sqlString, null);
+    }
+    
+    /**
+     * Build a ResultSetMappingQuery from a sql result set mapping name and sql string.
+     * @param hints a list of hints to be applied to the query.
+     */
+    public static DatabaseQuery buildSQLDatabaseQuery(String sqlResultSetMappingName, String sqlString, HashMap hints) {
+        ResultSetMappingQuery query = new ResultSetMappingQuery();
+        query.setSQLResultSetMappingName(sqlResultSetMappingName);
+        query.setSQLString(sqlString);
+        query.setIsUserDefined(true);
+        
+        // apply any query hints
+        return applyHints(hints, query);
+    }
+    
+    /**
+     * Build a ReadAllQuery from a class and stored procedure call.
+     */
+    public static DatabaseQuery buildStoredProcedureQuery(Class resultClass, StoredProcedureCall call, List<String> arguments, HashMap hints) {
+        DatabaseQuery query = new ReadAllQuery(resultClass);
+        query.setCall(call);
+        query.setIsUserDefined(true);
+        
+        // apply any query hints
+        query = applyHints(hints, query);
+        
+        // apply any query arguments
+        applyArguments(arguments, query);
 
+        return query;
+    }
+
     /**
-    * Set the flush mode type to be used for the query execution.
-    * @param flushMode
-    */
-    public Query setFlushMode(FlushModeType flushMode) {
+     * Build a ResultSetMappingQuery from a sql result set mapping name and a 
+     * stored procedure call.
+     */
+    public static DatabaseQuery buildStoredProcedureQuery(StoredProcedureCall call, List<String> arguments, HashMap hints) {
+        DatabaseQuery query = new ResultSetMappingQuery();
+        query.setCall(call);
+        query.setIsUserDefined(true);
+        
+        // apply any query hints
+        query = applyHints(hints, query);
+        
+        // apply any query arguments
+        applyArguments(arguments, query);
+
+        return query;
+    }
+    
+    /**
+     * Build a ResultSetMappingQuery from a sql result set mapping name and a
+     * stored procedure call.
+     */
+    public static DatabaseQuery buildStoredProcedureQuery(String sqlResultSetMappingName, StoredProcedureCall call, List<String> arguments, HashMap hints) {
+        ResultSetMappingQuery query = new ResultSetMappingQuery();
+        query.setSQLResultSetMappingName(sqlResultSetMappingName);
+        query.setCall(call);
+        query.setIsUserDefined(true);
+        
+        // apply any query hints
+        DatabaseQuery hintQuery = applyHints(hints, query);
+        
+        // apply any query arguments
+        applyArguments(arguments, hintQuery);
+
+        return hintQuery;
+    }
+
+    /**
+     * Build a DataReadQuery from a sql string.
+     */
+    public static DatabaseQuery buildSQLDatabaseQuery(String sqlString, Boolean flushOnExecute) {
+        return buildSQLDatabaseQuery(sqlString, new HashMap());
+    }
+    
+    /**
+     * Build a DataReadQuery from a sql string.
+     */
+    public static DatabaseQuery buildSQLDatabaseQuery(String sqlString, HashMap hints) {
+        DataReadQuery query = new DataReadQuery();
+        query.setUseAbstractRecord(false);
+        query.setSQLString(sqlString);
+        query.setIsUserDefined(true);
+
+        // apply any query hints
+        return applyHints(hints, query);
+    }
+
+    /**
+     * Execute a ReadQuery by assigning the stored parameter values and running it
+     * in the database
+     * @return the results of the query execution
+     */
+    protected Object executeReadQuery() {
+        Vector parameterValues = processParameters();
+        //TODO: the following performFlush() call is a temporary workaround for bug 4752493:
+        // CTS: INMEMORY QUERYING IN EJBQUERY BROKEN DUE TO CHANGE TO USE REPORTQUERY.
+        // Ideally we should only flush in case the selectionExpression can't be conformed in memory.
+        // There are two alternative ways to implement that:
+        // 1. Try running the query with conformInUOW flag first - if it fails with 
+        //    QueryException.cannotConformExpression then flush and run the query again -
+        //    now without conforming.
+        // 2. Implement a new isComformable method on Expression which would determine whether the expression
+        //    could be conformed in memory, flush only in case it returns false.
+        //    Note that doesConform method currently implemented on Expression
+        //    requires object(s) to be confirmed as parameter(s).
+        //    The new isComformable method should not take any objects as parameters,
+        //    it should return false if there could be such an object that
+        //    passed to doesConform causes it to throw QueryException.cannotConformExpression -
+        //    and true otherwise.
+        boolean shouldResetConformResultsInUnitOfWork = false;
+        if (isFlushModeAUTO()) {
+            performPreQueryFlush();
+            if (getDatabaseQuery().isObjectLevelReadQuery()) {
+                if (((ObjectLevelReadQuery)getDatabaseQuery()).shouldConformResultsInUnitOfWork()) {
+                    cloneIfParseCachedQuery();
+                    ((ObjectLevelReadQuery)getDatabaseQuery()).setCacheUsage(ObjectLevelReadQuery.UseDescriptorSetting);
+                    shouldResetConformResultsInUnitOfWork = true;
+                }
+            }
+        }
         try {
-            entityManager.verifyOpen();
-            if (flushMode == null) {
-                getDatabaseQuery().setFlushOnExecute(null);
-            } else {
-                cloneIfParseCachedQuery();
-                getDatabaseQuery().setFlushOnExecute(flushMode == FlushModeType.AUTO);
+            // in case it's a user-defined query
+            if (getDatabaseQuery().isUserDefined()) {
+                // and there is an active transaction
+                if (this.entityManager.checkForTransaction(false) != null) {
+                    // verify whether uow has begun early transaction
+                    if (!((org.eclipse.persistence.internal.sessions.UnitOfWorkImpl)getActiveSession()).wasTransactionBegunPrematurely()) {
+                        // uow begins early transaction in case it hasn't already begun.
+                        ((org.eclipse.persistence.internal.sessions.UnitOfWorkImpl)getActiveSession()).beginEarlyTransaction();
+                    }
+                }
             }
-            return this;
-        } catch (RuntimeException e) {
-            setRollbackOnly();
-            throw e;
+            return getActiveSession().executeQuery(getDatabaseQuery(), parameterValues);
+        } finally {
+            if (shouldResetConformResultsInUnitOfWork) {
+                ((ObjectLevelReadQuery)getDatabaseQuery()).conformResultsInUnitOfWork();
+            }
         }
     }
 
     /**
-    * Set an implementation-specific hint.
-    * If the hint name is not recognized, it is silently ignored.
-    * @param hintName
-    * @param value
-    * @return the same query instance
-    * @throws IllegalArgumentException if the second argument is not
-    * valid for the implementation
-    */
-    public Query setHint(String hintName, Object value) {
+     * Execute an update or delete statement.
+     * @return the number of entities updated or deleted
+     */
+    public int executeUpdate() {
         try {
+            //bug51411440: need to throw IllegalStateException if query executed on closed em
             entityManager.verifyOpen();
-            setHintInternal(hintName, value);
-            return this;
+            setAsSQLModifyQuery();
+            //bug:4294241, only allow modify queries - UpdateAllQuery prefered
+            if (!(getDatabaseQuery() instanceof ModifyQuery)){
+                throw new IllegalStateException(ExceptionLocalization.buildMessage("incorrect_query_for_execute_update"));
+            }
+            //fix for bug:4288845, did not add the parameters to the query
+            Vector parameterValues = processParameters();
+            if(isFlushModeAUTO()) {
+                performPreQueryFlush();
+            }
+            Integer changedRows = (Integer)getActiveSession().executeQuery(databaseQuery, parameterValues);
+            return changedRows.intValue();
         } catch (RuntimeException e) {
             setRollbackOnly();
             throw e;
@@ -149,15 +428,87 @@
     }
 
     /**
-    * Set the maximum number of results to retrieve.
-    * @param maxResult
-    * @return the same query instance
+     * Return the cached database query for this EJBQueryImpl.  If the query is
+     * a named query and it has not yet been looked up, the query will be looked up
+     * and stored as the cached query.
+     */
+    public DatabaseQuery getDatabaseQuery() {
+        if ((queryName != null) && (databaseQuery == null)) {
+            // need error checking and appropriate exception for non-existing query
+            databaseQuery = getActiveSession().getQuery(queryName);
+            if (databaseQuery != null) {
+                if (!databaseQuery.isPrepared()){
+                    //prepare the query before cloning, this ensures we do not have to continually prepare on each usage
+                    databaseQuery.prepareCall(getActiveSession(), new DatabaseRecord());
+                }
+                //Bug5040609  Make a clone of the original DatabaseQuery for this EJBQuery
+                databaseQuery = (DatabaseQuery)databaseQuery.clone();
+            } else {
+                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("unable_to_find_named_query", new Object[] {queryName}));
+            }
+            
+        }
+        return databaseQuery;
+    }
+    
+    /**
+     * Return the entityManager this query is tied to.
+     */
+    public JpaEntityManager getEntityManager() {
+        return (JpaEntityManager)entityManager;
+    }
+
+    /**
+     * Non-standard method to return results of a ReadQuery that has a containerPoliry
+     * that returns objects as a collection rather than a List
+     * @return Collection of results
+     */
+    public Collection getResultCollection() {
+        //bug51411440: need to throw IllegalStateException if query executed on closed em
+        entityManager.verifyOpen();
+        setAsSQLReadQuery();
+        propagateResultProperties();
+        //bug:4297903, check container policy class and throw exception if its not the right type 
+        if (getDatabaseQuery() instanceof ReadAllQuery){
+          Class containerClass = ((ReadAllQuery)getDatabaseQuery()).getContainerPolicy().getContainerClass();
+          if (! Helper.classImplementsInterface(containerClass, ClassConstants.Collection_Class)){
+            throw QueryException.invalidContainerClass( containerClass, ClassConstants.Collection_Class );
+          }
+        } else if (getDatabaseQuery() instanceof ReadObjectQuery){
+            //bug:4300879, no support for ReadObjectQuery if a collection is required
+            throw QueryException.incorrectQueryObjectFound( getDatabaseQuery(), ReadAllQuery.class );
+        } else if (!(getDatabaseQuery() instanceof ReadQuery)){
+            throw new IllegalStateException(ExceptionLocalization.buildMessage("incorrect_query_for_get_result_collection"));
+        }
+        Object result = executeReadQuery();
+        return (Collection)result;
+    }
+
+    /**
+    * Execute the query and return the query results
+    * as a List.
+    * @return a list of the results
     */
-    public Query setMaxResults(int maxResult) {
+    public List getResultList() {
         try {
+            //bug51411440: need to throw IllegalStateException if query executed on closed em
             entityManager.verifyOpen();
-            setMaxResultsInternal(maxResult);
-            return this;
+            setAsSQLReadQuery();
+            propagateResultProperties();
+            //bug:4297903, check container policy class and throw exception if its not the right type 
+            if (getDatabaseQuery() instanceof ReadAllQuery){
+              Class containerClass = ((ReadAllQuery)getDatabaseQuery()).getContainerPolicy().getContainerClass();
+              if (! Helper.classImplementsInterface(containerClass, ClassConstants.List_Class)){
+                throw QueryException.invalidContainerClass( containerClass, ClassConstants.List_Class );
+              }
+            } else if (getDatabaseQuery() instanceof ReadObjectQuery){
+                //bug:4300879, handle ReadObjectQuery returning null
+                throw QueryException.incorrectQueryObjectFound( getDatabaseQuery(), ReadAllQuery.class );
+            } else if (!(getDatabaseQuery() instanceof ReadQuery)){
+                throw new IllegalStateException(ExceptionLocalization.buildMessage("incorrect_query_for_get_result_list"));
+            }
+            Object result = executeReadQuery();
+            return (List)result;
         } catch (RuntimeException e) {
             setRollbackOnly();
             throw e;
@@ -165,83 +516,424 @@
     }
 
     /**
-    * Bind an argument to a named parameter.
-    * @param name the parameter name
-    * @param value
-    * @return the same query instance
+    * Execute a query that returns a single result.
+    * @return the result
+    * @throws javax.persistence.EntityNotFoundException if there is no result
+    * @throws javax.persistence.NonUniqueResultException if more than one result
     */
-    public Query setParameter(String name, Object value) {
+    public Object getSingleResult() {
+        boolean rollbackOnException = true;
         try {
+            //bug51411440: need to throw IllegalStateException if query executed on closed em
             entityManager.verifyOpen();
-            setParameterInternal(name, value);
-            return this;
+            setAsSQLReadQuery();
+            propagateResultProperties();
+            //bug:4301674, requires lists to be returned from ReadAllQuery objects
+            if (getDatabaseQuery() instanceof ReadAllQuery){
+              Class containerClass = ((ReadAllQuery)getDatabaseQuery()).getContainerPolicy().getContainerClass();
+              if (! Helper.classImplementsInterface(containerClass, ClassConstants.List_Class)){
+                throw QueryException.invalidContainerClass( containerClass, ClassConstants.List_Class );
+              }
+            } else if (!(getDatabaseQuery() instanceof ReadQuery)){
+                throw new IllegalStateException(ExceptionLocalization.buildMessage("incorrect_query_for_get_single_result"));
+            }
+            Object result = executeReadQuery();
+            if (result instanceof List){
+                List results = (List)result;
+                if (results.isEmpty()) {
+                    rollbackOnException = false;
+                    throwNoResultException(ExceptionLocalization.buildMessage("no_entities_retrieved_for_get_single_result", (Object[])null));                
+                } else if (results.size() > 1) {
+                    rollbackOnException = false;
+                    throwNonUniqueResultException(ExceptionLocalization.buildMessage("too_many_results_for_get_single_result", (Object[])null));
+                }
+                return results.get(0);
+            }else{
+                if (result == null) {
+                    rollbackOnException = false;
+                    throwNoResultException(ExceptionLocalization.buildMessage("no_entities_retrieved_for_get_single_result", (Object[])null));
+                }
+                return result;
+            }
         } catch (RuntimeException e) {
-            setRollbackOnly();
+            if(rollbackOnException) {
+                setRollbackOnly();
+            }
             throw e;
         }
     }
 
     /**
-    * Bind an instance of java.util.Date to a named parameter.
-    * @param name
-    * @param value
-    * @param temporalType
-    * @return the same query instance
-    */
-    public Query setParameter(String name, Date value, TemporalType temporalType) {
-        return setParameter(name, convertTemporalType(value, temporalType));
+     * Internal method to add the parameters values to the query prior to execution. 
+     * Returns a list of parameter values in the order the parameters are
+     * defined for the databaseQuery.
+     */
+    protected Vector processParameters() {
+        if (databaseQuery == null) {
+            getDatabaseQuery();
+        }
+        List arguments = databaseQuery.getArguments();
+        if (arguments.isEmpty()) {
+            Iterator params = parameters.keySet().iterator();
+            while (params.hasNext()) {
+                databaseQuery.addArgument((String)params.next());
+            }
+            arguments = databaseQuery.getArguments();
+        }
+        // now create parameterValues in the same order as the argument list
+        Vector parameterValues = new Vector(arguments.size());
+        for (Iterator i = arguments.iterator(); i.hasNext();) {
+            String name = (String)i.next();
+            if (parameters.containsKey(name)) {
+                parameterValues.add(parameters.get(name));
+            } else {
+                // Error: missing actual parameter value
+                throw new IllegalStateException(ExceptionLocalization.buildMessage("missing_parameter_value", new Object[]{name}));
+            }
+        }
+        return parameterValues;
     }
 
     /**
-    * Bind an instance of java.util.Calendar to a named parameter.
-    * @param name
-    * @param value
-    * @param temporalType
-    * @return the same query instance
-    */
-    public Query setParameter(String name, Calendar value, TemporalType temporalType) {
-        return setParameter(name, convertTemporalType(value, temporalType));
+     * Replace the cached query with the given query.
+     */
+    public void setDatabaseQuery(DatabaseQuery query) {
+        databaseQuery = query;
     }
 
     /**
-    * Bind an argument to a positional parameter.
-    * @param position
-    * @param value
-    * @return the same query instance
+     * Set the position of the first result to retrieve.
+     * @param start position of the first result, numbered from 0
+     * @return the same query instance
+     */
+     public Query setFirstResult(int startPosition) {
+         try {
+             entityManager.verifyOpen();
+             setFirstResultInternal(startPosition);
+             return this;
+         } catch (RuntimeException e) {
+             setRollbackOnly();
+             throw e;
+         }
+     }
+     
+    /**
+     * Set the position of the first result to retrieve.
+     * @param startPosition position of the first result, numbered from 0.
+     */
+    protected void setFirstResultInternal(int startPosition) {
+        if (startPosition < 0) {
+            throw new IllegalArgumentException(ExceptionLocalization.buildMessage("negative_start_position", (Object[])null));
+        }
+        firstResultIndex = startPosition;
+    }
+
+    /**
+     * Set the flush mode type to be used for the query execution.
+     * @param flushMode
+     */
+     public Query setFlushMode(FlushModeType flushMode) {
+         try {
+             entityManager.verifyOpen();
+             if (flushMode == null) {
+                 getDatabaseQuery().setFlushOnExecute(null);
+             } else {
+                 cloneIfParseCachedQuery();
+                 getDatabaseQuery().setFlushOnExecute(flushMode == FlushModeType.AUTO);
+             }
+             return this;
+         } catch (RuntimeException e) {
+             setRollbackOnly();
+             throw e;
+         }
+     }
+     
+     /**
+      * Set implementation-specific query arguments.
+      */
+     protected static void applyArguments(List<String> arguments, DatabaseQuery query) {
+    	 for (String argument : arguments) {
+            query.addArgument(argument);
+         }
+     }
+    
+    /**
+     * Set implementation-specific hints.
+     * 
+     * @param hints a list of hints to be applied to the query
+     * @param query the query to apply the hints to
+     */
+    protected static DatabaseQuery applyHints(HashMap hints, DatabaseQuery query) {
+        return QueryHintsHandler.apply(hints, query);
+    }
+
+    /**
+     * Spec. 3.5.2:
+     * "FlushMode.AUTO is set on the Query object, or if
+     * the flush mode setting for the persistence context is AUTO (the default) 
+     * and a flush mode setting has not been specified for the Query object,
+     * the persistence provider is responsible for ensuring that all updates
+     * to the state of all entities in the persistence context which could potentially 
+     * affect the result of the query are visible to the processing of the query."
+     */
+    protected boolean isFlushModeAUTO() {
+        if(getDatabaseQuery().getFlushOnExecute() != null) {
+            return getDatabaseQuery().getFlushOnExecute().booleanValue();
+        } else {
+            return entityManager.isFlushModeAUTO();
+        }
+    }
+
+    /**
+     * Set an implementation-specific hint.
+     * If the hint name is not recognized, it is silently ignored.
+     * @param hintName
+     * @param value
+     * @return the same query instance
+     * @throws IllegalArgumentException if the second argument is not
+     * valid for the implementation
+     */
+     public Query setHint(String hintName, Object value) {
+         try {
+             entityManager.verifyOpen();
+             setHintInternal(hintName, value);
+             return this;
+         } catch (RuntimeException e) {
+             setRollbackOnly();
+             throw e;
+         }
+     }
+     
+    /**
+     * Set an implementation-specific hint.
+     * If the hint name is not recognized, it is silently ignored.
+     * @throws IllegalArgumentException if the second argument is not
+     * valid for the implementation.
+     */
+    protected void setHintInternal(String hintName, Object value) {
+        cloneIfParseCachedQuery();
+        DatabaseQuery hintQuery = QueryHintsHandler.apply(hintName, value, getDatabaseQuery());
+        if (hintQuery != null) {
+            setDatabaseQuery(hintQuery);
+        }
+    }
+    
+    /**
+     * If the query was from the jpql parse cache it must be cloned before being modified.
+     */
+    protected void cloneIfParseCachedQuery() {
+        DatabaseQuery query = getDatabaseQuery();
+        if (query.isFromParseCache()) {
+            // Clone to allow setting of hints or other properties without corrupting original query.
+            query = (DatabaseQuery)databaseQuery.clone();
+            query.setIsFromParseCache(false);
+            setDatabaseQuery(query);
+        }
+    }
+    
+    /**
+     *  Convert the given object to the class represented by the given temporal type.
+     *  @return an object represting the given TemporalType
+     */
+    protected Object convertTemporalType(Object value, TemporalType type) {
+        ConversionManager conversionManager = ((org.eclipse.persistence.internal.sessions.AbstractSession)getEntityManager().getActiveSession()).getDatasourcePlatform().getConversionManager();
+        if (type == TemporalType.TIME) {
+            return conversionManager.convertObject(value, ClassConstants.TIME);
+        } else if (type == TemporalType.TIMESTAMP) {
+            return conversionManager.convertObject(value, ClassConstants.TIMESTAMP);
+        } else if (type == TemporalType.DATE) {
+            return conversionManager.convertObject(value, ClassConstants.SQLDATE);
+        }
+        return value;
+    }
+
+    /**
+     * Set the maximum number of results to retrieve.
+     * @param maxResult
+     * @return the same query instance
+     */
+     public Query setMaxResults(int maxResult) {
+         try {
+             entityManager.verifyOpen();
+             setMaxResultsInternal(maxResult);
+             return this;
+         } catch (RuntimeException e) {
+             setRollbackOnly();
+             throw e;
+         }
+     }
+     
+    /**
+    * Set the maximum number of results to retrieve.
+    * @param maxResult
     */
-    public Query setParameter(int position, Object value) {
-        try {
-            entityManager.verifyOpen();
-            setParameterInternal(position, value);
-            return this;
-        } catch (RuntimeException e) {
-            setRollbackOnly();
-            throw e;
+    public void setMaxResultsInternal(int maxResult) {
+        if (maxResult < 0) {
+            throw new IllegalArgumentException(ExceptionLocalization.buildMessage("negative_max_result", (Object[])null));
         }
+        this.maxResults = maxResult;
     }
 
     /**
-    * Bind an instance of java.util.Date to a positional parameter.
-    * @param position
+     * Bind an argument to a named parameter.
+     * @param name the parameter name
+     * @param value
+     * @return the same query instance
+     */
+     public Query setParameter(String name, Object value) {
+         try {
+             entityManager.verifyOpen();
+             setParameterInternal(name, value);
+             return this;
+         } catch (RuntimeException e) {
+             setRollbackOnly();
+             throw e;
+         }
+     }
+
+     /**
+     * Bind an instance of java.util.Date to a named parameter.
+     * @param name
+     * @param value
+     * @param temporalType
+     * @return the same query instance
+     */
+     public Query setParameter(String name, Date value, TemporalType temporalType) {
+         return setParameter(name, convertTemporalType(value, temporalType));
+     }
+
+     /**
+     * Bind an instance of java.util.Calendar to a named parameter.
+     * @param name
+     * @param value
+     * @param temporalType
+     * @return the same query instance
+     */
+     public Query setParameter(String name, Calendar value, TemporalType temporalType) {
+         return setParameter(name, convertTemporalType(value, temporalType));
+     }
+
+     /**
+     * Bind an argument to a positional parameter.
+     * @param position
+     * @param value
+     * @return the same query instance
+     */
+     public Query setParameter(int position, Object value) {
+         try {
+             entityManager.verifyOpen();
+             setParameterInternal(position, value);
+             return this;
+         } catch (RuntimeException e) {
+             setRollbackOnly();
+             throw e;
+         }
+     }
+
+     /**
+     * Bind an instance of java.util.Date to a positional parameter.
+     * @param position
+     * @param value
+     * @param temporalType
+     * @return the same query instance
+     */
+     public Query setParameter(int position, Date value, TemporalType temporalType) {
+         return setParameter(position, convertTemporalType(value, temporalType));
+     }
+
+     /**
+     * Bind an instance of java.util.Calendar to a positional parameter.
+     * @param position
+     * @param value
+     * @param temporalType
+     * @return the same query instance
+     */
+     public Query setParameter(int position, Calendar value, TemporalType temporalType) {
+         return setParameter(position, convertTemporalType(value, temporalType));
+     }
+     
+    /**
+     * Configure the firstResult and maxRows in the TopLink ReadQuery.
+     */
+    protected void propagateResultProperties() {
+        DatabaseQuery databaseQuery = getDatabaseQuery();
+        if (databaseQuery.isReadQuery()) {
+            ReadQuery readQuery = (ReadQuery)databaseQuery;
+            if (maxResults >= 0) {
+                cloneIfParseCachedQuery();
+                readQuery = (ReadQuery)getDatabaseQuery();
+                maxRows = maxResults + ((firstResultIndex >= 0) ? firstResultIndex : 0);
+                readQuery.setMaxRows(maxRows);
+                maxResults = -1;
+            }
+            if (firstResultIndex > -1) {
+                cloneIfParseCachedQuery();
+                readQuery = (ReadQuery)getDatabaseQuery();
+                readQuery.setFirstResult(firstResultIndex);
+                firstResultIndex = -1;
+            }
+        }
+    }
+
+    /**
+    * Bind an argument to a named parameter.
+    * @param name the parameter name
     * @param value
-    * @param temporalType
-    * @return the same query instance
     */
-    public Query setParameter(int position, Date value, TemporalType temporalType) {
-        return setParameter(position, convertTemporalType(value, temporalType));
+    protected void setParameterInternal(String name, Object value) {
+        int index  = getDatabaseQuery().getArguments().indexOf(name);
+        if (getDatabaseQuery().getEJBQLString() != null){  //only non native queries
+            if (index == -1){
+                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-wrong-argument-name",new Object[]{name, getDatabaseQuery().getEJBQLString()}));
+            }
+            if (!isValidActualParameter(value, getDatabaseQuery().getArgumentTypes().get(index))) {
+                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-incorrect-parameter-type", new Object[] {name, value.getClass(), getDatabaseQuery().getArgumentTypes().get(index), getDatabaseQuery().getEJBQLString()}));
+            }
+        }
+        parameters.put(name, value);
     }
 
     /**
-    * Bind an instance of java.util.Calendar to a positional parameter.
+    * Bind an argument to a positional parameter.
     * @param position
     * @param value
-    * @param temporalType
-    * @return the same query instance
     */
-    public Query setParameter(int position, Calendar value, TemporalType temporalType) {
-        return setParameter(position, convertTemporalType(value, temporalType));
+    protected void setParameterInternal(int position, Object value) {
+        String pos = (new Integer(position)).toString();
+        int index = getDatabaseQuery().getArguments().indexOf(pos);
+        if (getDatabaseQuery().getEJBQLString() != null){  //only non native queries
+            if (index == -1) {
+                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-wrong-argument-index", new Object[]{position, getDatabaseQuery().getEJBQLString()}));
+            }
+            if (!isValidActualParameter(value, getDatabaseQuery().getArgumentTypes().get(index))) {
+                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-incorrect-parameter-type", new Object[] {position, value.getClass(), getDatabaseQuery().getArgumentTypes().get(index), getDatabaseQuery().getEJBQLString()}));
+            }
+        }
+        parameters.put(pos, value);
     }
 
+    protected boolean isValidActualParameter(Object value, Object parameterType) {
+        if (value == null) {
+            return true;
+        } else {
+            return BasicTypeHelperImpl.getInstance().isAssignableFrom(parameterType, value.getClass());
+        }
+    }
+
+    protected Session getActiveSession() {
+        return entityManager.getActiveSession();
+    }    
+    
+    protected void performPreQueryFlush(){
+        if (this.entityManager.shouldFlushBeforeQuery()){
+            this.entityManager.flush();
+        }
+    }
+
+    protected void setRollbackOnly() {
+        entityManager.setRollbackOnly();
+    }
+
     protected void throwNoResultException(String message) {
         throw new NoResultException(message);
     }
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/QueryHintsHandler.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/QueryHintsHandler.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/QueryHintsHandler.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.base;
+package org.eclipse.persistence.internal.jpa;
 
 import java.security.AccessController;
 import java.security.PrivilegedActionException;
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/EntityManagerFactoryProvider.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/EntityManagerFactoryProvider.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/EntityManagerFactoryProvider.java	(working copy)
@@ -7,69 +7,27 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.jpa;
+package org.eclipse.persistence.internal.jpa;
 
 import java.io.File;
-import java.net.URL;
-import java.util.Enumeration;
 import java.util.Map;
 import java.util.HashMap;
-import javax.persistence.*;
-import javax.persistence.spi.*;
 
 import org.eclipse.persistence.jpa.config.TargetDatabase;
 import org.eclipse.persistence.jpa.config.PersistenceUnitProperties;
-import org.eclipse.persistence.exceptions.PersistenceUnitLoadingException;
-import org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl;
-import org.eclipse.persistence.internal.jpa.JavaSECMPInitializer;
-import org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl;
-import org.eclipse.persistence.internal.jpa.PersistenceInitializationActivator;
 import org.eclipse.persistence.internal.sessions.AbstractSession;
 import org.eclipse.persistence.logging.SessionLog;
 import org.eclipse.persistence.sessions.server.ServerSession;
-
 import org.eclipse.persistence.tools.schemaframework.SchemaManager;
-import org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor;
-import org.eclipse.persistence.internal.jpa.deployment.SEPersistenceUnitInfo;
 
 /**
- * This is the TopLink EJB 3.0 provider
+ * This is a helper/impl class for the TopLink EJB 3.0 provider
  * The default constructor can be used to build the provider by reflection, after which it can
  * be used to create EntityManagerFactories
  */
-
-public class EntityManagerFactoryProvider implements javax.persistence.spi.PersistenceProvider, PersistenceInitializationActivator {
-
-    // The following constants are used in persistence xml or in createSessionManagerFactory methods to specify properties.
-    // Many property declarations were moved to org.eclipse.persistence.jpa.config.PersistenceUnitProperties class.
-
-    public static final String TOPLINK_ORM_THROW_EXCEPTIONS = "eclipselink.orm.throw.exceptions";
-    public static final String TOPLINK_VALIDATION_ONLY_PROPERTY = "eclipselink.validation-only";
-
-    public static final String DDL_GENERATION   = "eclipselink.ddl-generation";
+public class EntityManagerFactoryProvider { 
+    public static final HashMap<String, EntityManagerSetupImpl> emSetupImpls = new HashMap<String, EntityManagerSetupImpl>();
     
-    public static final String CREATE_ONLY      = "create-tables";
-    public static final String DROP_AND_CREATE  = "drop-and-create-tables";
-    public static final String NONE             = "none";
-    
-    public static final String APP_LOCATION     = "eclipselink.application-location";
-    
-    public static final String CREATE_JDBC_DDL_FILE = "eclipselink.create-ddl-jdbc-file-name";
-    public static final String DROP_JDBC_DDL_FILE   = "eclipselink.drop-ddl-jdbc-file-name";
-    
-    public static final String DEFAULT_APP_LOCATION = "." + File.separator;
-    public static final String DEFAULT_CREATE_JDBC_FILE_NAME = "createDDL.jdbc";
-    public static final String DEFAULT_DROP_JDBC_FILE_NAME = "dropDDL.jdbc";
-    public static final String JAVASE_DB_INTERACTION = "INTERACT_WITH_DB";    
-    
-    public static final String DDL_GENERATION_MODE = "eclipselink.ddl-generation.output-mode";
-    public static final String DDL_SQL_SCRIPT_GENERATION = "sql-script";
-    public static final String DDL_DATABASE_GENERATION = "database";
-    public static final String DDL_BOTH_GENERATION = "both";
-    // This is the default for now to ensure we still play nicely with Glassfish.
-    public static final String DEFAULT_DDL_GENERATION_MODE = DDL_SQL_SCRIPT_GENERATION;
-    
-    protected static final HashMap<String, EntityManagerSetupImpl> emSetupImpls = new HashMap<String, EntityManagerSetupImpl>();
     // TEMPORARY - WILL BE REMOVED.
     // Used to warn users about deprecated property name and suggest the valid name.
     // TEMPORARY the old property names will be translated to the new ones and processed.
@@ -85,258 +43,91 @@
     };
 
     /**
-     * A default constructor is required by all Providers according the the EJB 3.0 specification
+     * Add an EntityManagerSetupImpl to the cached list
+     * These are used to ensure all persistence units that are the same get the same underlying session
+     * @param name
+     * @param setup
      */
-    public EntityManagerFactoryProvider() {      
+    public static void addEntityManagerSetupImpl(String name, EntityManagerSetupImpl setup){
+    	if (name == null){
+    		emSetupImpls.put("", setup);
+    	}
+        emSetupImpls.put(name, setup);
     }
 
-    /**
-    * Called by Persistence class when an EntityManagerFactory
-    * is to be created.
-    *
-    * @param emName The name of the persistence unit
-    * @param map A Map of properties for use by the
-    * persistence provider. These properties may be used to
-    * override the values of the corresponding elements in
-    * the persistence.xml file or specify values for
-    * properties not specified in the persistence.xml.
-    * @return EntityManagerFactory for the persistence unit,
-    * or null if the provider is not the right provider
-    */
-	public EntityManagerFactory createEntityManagerFactory(String emName, Map properties){
-        Map nonNullProperties = (properties == null) ? new HashMap() : properties;
-        String name = emName;
-        if (name == null){
-            name = "";
+    protected static String addFileSeperator(String appLocation) {
+        int strLength = appLocation.length();
+        if (appLocation.substring(strLength -1, strLength).equals(File.separator)) {
+            return appLocation;
+        } else {
+            return appLocation + File.separator;
         }
-
-        JavaSECMPInitializer initializer = JavaSECMPInitializer.getJavaSECMPInitializer();
-        EntityManagerSetupImpl emSetupImpl = null;
-        ClassLoader currentLoader = Thread.currentThread().getContextClassLoader();
-
-        try {
-            Enumeration<URL> resources = currentLoader.getResources("META-INF/persistence.xml");
-            boolean initialized = false;
-            while (resources.hasMoreElements()) {
-                URL url = PersistenceUnitProcessor.computePURootURL(resources.nextElement());
-                String urlAndName = url + name;
-            
-                synchronized (EntityManagerFactoryProvider.emSetupImpls){
-                    emSetupImpl = EntityManagerFactoryProvider.getEntityManagerSetupImpl(urlAndName);
-                    if (emSetupImpl == null || emSetupImpl.isUndeployed()){
-                        if (!initialized) {
-                            initializer.initialize(nonNullProperties, this);
-                            initialized = true;
-                        }
-                        
-                        emSetupImpl = EntityManagerFactoryProvider.getEntityManagerSetupImpl(urlAndName);
-                    }
-                }
-
-                // We found a match, stop looking.
-                if (emSetupImpl != null) {
-                    break;
-                }
-            }
-        } catch (Exception e){
-            throw PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(currentLoader, e);
-        }
-
-        //gf bug 854  Returns null if EntityManagerSetupImpl for the name doesn't exist (e.g. a non-existant PU)
-        if (emSetupImpl == null) {
-            return null;
-        }
-        
-        if (!isPersistenceProviderSupported(emSetupImpl.getPersistenceUnitInfo().getPersistenceProviderClassName())){
-            return null;
-        }
-
-
-        // synchronized to prevent overriding of the class loader
-        // and also calls to predeploy and undeploy by other threads -
-        // the latter may alter result of shouldRedeploy method.
-        synchronized(emSetupImpl) {
-            if(emSetupImpl.shouldRedeploy()) {
-                SEPersistenceUnitInfo persistenceInfo = (SEPersistenceUnitInfo)emSetupImpl.getPersistenceUnitInfo();
-                persistenceInfo.setClassLoader(JavaSECMPInitializer.getMainLoader());
-                if (emSetupImpl.isUndeployed()){
-                    persistenceInfo.setNewTempClassLoader(JavaSECMPInitializer.getMainLoader());
-                }
-            }
-            // call predeploy
-            // this will just increment the factory count since we should already be deployed
-            emSetupImpl.predeploy(emSetupImpl.getPersistenceUnitInfo(), nonNullProperties);
-        }
-        
-        EntityManagerFactoryImpl factory = null;
-        try {
-            factory = new EntityManagerFactoryImpl(emSetupImpl, nonNullProperties);
-    
-            // This code has been added to allow validation to occur without actually calling createEntityManager
-            if (emSetupImpl.shouldGetSessionOnCreateFactory(nonNullProperties)) {
-                factory.getServerSession();
-            }
-            return factory;
-        } catch (RuntimeException ex) {
-            if(factory != null) {
-                factory.close();
-            } else {
-                emSetupImpl.undeploy();
-            }
-            throw ex;
-        }
     }
-
-    /**
-    * Called by the container when an EntityManagerFactory
-    * is to be created.
-    *
-    * @param info Metadata for use by the persistence provider
-    * @return EntityManagerFactory for the persistence unit
-    * specified by the metadata
-    * @param map A Map of integration-level properties for use
-    * by the persistence provider.
-    */
-    public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info, Map properties){
-        Map nonNullProperties = (properties == null) ? new HashMap() : properties;
-        EntityManagerSetupImpl emSetupImpl = null;
-        synchronized (EntityManagerFactoryProvider.emSetupImpls) {
-            String urlAndName = info.getPersistenceUnitRootUrl() + info.getPersistenceUnitName();
-            emSetupImpl = EntityManagerFactoryProvider.getEntityManagerSetupImpl(urlAndName);
-            if (emSetupImpl == null){
-                emSetupImpl = new EntityManagerSetupImpl();
-                emSetupImpl.setIsInContainerMode(true);        
-                EntityManagerFactoryProvider.addEntityManagerSetupImpl(urlAndName, emSetupImpl);
-            }
-        }
-        
-        ClassTransformer transformer = null;
-        if(!emSetupImpl.isDeployed()) {
-            transformer = emSetupImpl.predeploy(info, nonNullProperties);
-        }
-        if (transformer != null){
-            info.addTransformer(transformer);
-        }
-        // When EntityManagerFactory is created, the session is only partially created
-        // When the factory is actually accessed, the emSetupImpl will be used to complete the session construction
-        EntityManagerFactoryImpl factory = new EntityManagerFactoryImpl(emSetupImpl, nonNullProperties);
-
-        // This code has been added to allow validation to occur without actually calling createEntityManager
-        if (emSetupImpl.shouldGetSessionOnCreateFactory(nonNullProperties)) {
-        	factory.getServerSession();
-        }
-        return factory;
-    }
-
-    /**
-     * Returns whether the given persistence provider class is supported by this implementation
-     * @param providerClassName
-     * @return
-     */
-    public boolean isPersistenceProviderSupported(String providerClassName){
-        return (providerClassName == null) || providerClassName.equals("") || providerClassName.equals(EntityManagerFactoryProvider.class.getName());
-    }
     
-    /**
-     * Logs in to given session. If user has not specified  <codeTARGET_DATABASE</code>
-     * the plaform would be auto detected
-     * @param session The session to login to.
-     * @param properties User specified properties for the persistence unit
-     */
-    public static void login(ServerSession session, Map properties) {
-        String toplinkPlatform = (String)properties.get(PersistenceUnitProperties.TARGET_DATABASE);
-        if (!session.isConnected()) {
-            if (toplinkPlatform == null || toplinkPlatform.equals(TargetDatabase.Auto)) {
-                // if user has not specified a database platform, try to detect
-                session.loginAndDetectDatasource();
-            } else {
-                session.login();
-            }
-        }
+    protected static void createOrReplaceDefaultTables(SchemaManager mgr, boolean shouldDropFirst) {          
+    	if (shouldDropFirst){
+    		mgr.replaceDefaultTables(true, true); 
+    	} else { 
+    		mgr.createDefaultTables(true); 
+    	}
     }
 
-    public static void generateDDLFiles(ServerSession session, Map props,
-            boolean inSEmode) {
+    protected static void generateDDLFiles(ServerSession session, Map props, boolean inSEmode) {
         boolean createTables = false, shouldDropFirst = false;
         String appLocation; 
         String createDDLJdbc;
         String dropDDLJdbc;
-        String ddlGeneration = NONE;
+        String ddlGeneration = PersistenceUnitProperties.NONE;
         
         if(null == props){
             return;
         }
 
-        ddlGeneration = (String)getConfigPropertyAsString(DDL_GENERATION, props, NONE);
+        ddlGeneration = (String)getConfigPropertyAsString(PersistenceUnitProperties.DDL_GENERATION, props, PersistenceUnitProperties.NONE);
         ddlGeneration = ddlGeneration.toLowerCase();
-        if(ddlGeneration.equals(NONE)) {
+        if(ddlGeneration.equals(PersistenceUnitProperties.NONE)) {
             return;
         }
 
-        if(ddlGeneration.equals(CREATE_ONLY) || 
-            ddlGeneration.equals(DROP_AND_CREATE)) {
+        if(ddlGeneration.equals(PersistenceUnitProperties.CREATE_ONLY) || 
+            ddlGeneration.equals(PersistenceUnitProperties.DROP_AND_CREATE)) {
             createTables = true;
-            if(ddlGeneration.equals(DROP_AND_CREATE)) {
+            if(ddlGeneration.equals(PersistenceUnitProperties.DROP_AND_CREATE)) {
                 shouldDropFirst = true;
             }
         } 
         
         if (createTables) {
-            String ddlGenerationMode = (String) getConfigPropertyAsString(DDL_GENERATION_MODE, props, DEFAULT_DDL_GENERATION_MODE);
+            String ddlGenerationMode = (String) getConfigPropertyAsString(PersistenceUnitProperties.DDL_GENERATION_MODE, props, PersistenceUnitProperties.DEFAULT_DDL_GENERATION_MODE);
             // Optimize for cases where the value is explicitly set to NONE 
-            if (ddlGenerationMode.equals(NONE)) {                
+            if (ddlGenerationMode.equals(PersistenceUnitProperties.NONE)) {                
                 return;
             }
             
-            appLocation = (String)getConfigPropertyAsString( APP_LOCATION, props, DEFAULT_APP_LOCATION);
-            createDDLJdbc = (String)getConfigPropertyAsString( CREATE_JDBC_DDL_FILE, props, DEFAULT_CREATE_JDBC_FILE_NAME);
-            dropDDLJdbc = (String)getConfigPropertyAsString( DROP_JDBC_DDL_FILE, props,  DEFAULT_DROP_JDBC_FILE_NAME);
+            appLocation = (String)getConfigPropertyAsString(PersistenceUnitProperties.APP_LOCATION, props, PersistenceUnitProperties.DEFAULT_APP_LOCATION);
+            createDDLJdbc = (String)getConfigPropertyAsString(PersistenceUnitProperties.CREATE_JDBC_DDL_FILE, props, PersistenceUnitProperties.DEFAULT_CREATE_JDBC_FILE_NAME);
+            dropDDLJdbc = (String)getConfigPropertyAsString(PersistenceUnitProperties.DROP_JDBC_DDL_FILE, props,  PersistenceUnitProperties.DEFAULT_DROP_JDBC_FILE_NAME);
             
             SchemaManager mgr = new SchemaManager(session);
             
             // The inSEmode checks here are only temporary to ensure we still 
             // play nicely with Glassfish.
-            if (ddlGenerationMode.equals(DDL_DATABASE_GENERATION) || inSEmode) {
+            if (ddlGenerationMode.equals(PersistenceUnitProperties.DDL_DATABASE_GENERATION) || inSEmode) {
                 runInSEMode(mgr, shouldDropFirst);                
                 
                 if (inSEmode) {
                     writeDDLsToFiles(mgr, appLocation,  createDDLJdbc,  dropDDLJdbc);      
                 }
-            } else if (ddlGenerationMode.equals(DDL_SQL_SCRIPT_GENERATION)) {
+            } else if (ddlGenerationMode.equals(PersistenceUnitProperties.DDL_SQL_SCRIPT_GENERATION)) {
                 writeDDLsToFiles(mgr, appLocation,  createDDLJdbc,  dropDDLJdbc);                
-            } else if (ddlGenerationMode.equals(DDL_BOTH_GENERATION)) {
+            } else if (ddlGenerationMode.equals(PersistenceUnitProperties.DDL_BOTH_GENERATION)) {
                 runInSEMode(mgr, shouldDropFirst);
                 writeDDLsToFiles(mgr, appLocation,  createDDLJdbc,  dropDDLJdbc);
             }
         }
     }
-   
-    public static void runInSEMode(SchemaManager mgr, boolean shouldDropFirst) {
-        String str = getConfigPropertyAsString(JAVASE_DB_INTERACTION, null ,"true");
-        boolean interactWithDB = Boolean.valueOf(str.toLowerCase()).booleanValue();
-        if (!interactWithDB){
-            return;
-        }
-        createOrReplaceDefaultTables(mgr, shouldDropFirst);
-    }
     
-  /**
-   * Check the provided map for an object with the given key.  If that object is not available, check the
-   * System properties.  If it is not available from either location, return the default value.
-   * @param propertyKey 
-   * @param map 
-   * @param defaultValue 
-   * @return 
-   */
-    public static String getConfigPropertyAsString(String propertyKey, Map overrides, String defaultValue){
-        String value = getConfigPropertyAsString(propertyKey, overrides);
-        if (value == null){
-            value = defaultValue;
-        }
-        return value;
-    }
-    
-    public static String getConfigPropertyAsString(String propertyKey, Map overrides){
+    protected static String getConfigPropertyAsString(String propertyKey, Map overrides){
         String value = null;
         if (overrides != null){
             value = (String)overrides.get(propertyKey);
@@ -347,17 +138,24 @@
         
         return value;
     }
-
-    public static String getConfigPropertyAsStringLogDebug(String propertyKey, Map overrides, String defaultValue, AbstractSession session){
-        String value = getConfigPropertyAsStringLogDebug(propertyKey, overrides, session);
+    
+    /**
+     * Check the provided map for an object with the given key.  If that object is not available, check the
+     * System properties.  If it is not available from either location, return the default value.
+     * @param propertyKey 
+     * @param map 
+     * @param defaultValue 
+     * @return 
+     */
+    protected static String getConfigPropertyAsString(String propertyKey, Map overrides, String defaultValue){
+    	String value = getConfigPropertyAsString(propertyKey, overrides);
         if (value == null){
             value = defaultValue;
-            session.log(SessionLog.FINEST, SessionLog.PROPERTIES, "property_value_default", new Object[]{propertyKey, value});
         }
         return value;
     }
-    
-    public static String getConfigPropertyAsStringLogDebug(String propertyKey, Map overrides, AbstractSession session){
+
+    protected static String getConfigPropertyAsStringLogDebug(String propertyKey, Map overrides, AbstractSession session){
         String value = null;
         if (overrides != null){
             value = (String)overrides.get(propertyKey);
@@ -374,7 +172,16 @@
         return value;
     }
     
-    public static Object getConfigPropertyLogDebug(String propertyKey, Map overrides, AbstractSession session){
+    protected static String getConfigPropertyAsStringLogDebug(String propertyKey, Map overrides, String defaultValue, AbstractSession session){
+        String value = getConfigPropertyAsStringLogDebug(propertyKey, overrides, session);
+        if (value == null){
+            value = defaultValue;
+            session.log(SessionLog.FINEST, SessionLog.PROPERTIES, "property_value_default", new Object[]{propertyKey, value});
+        }
+        return value;
+    }
+    
+    protected static Object getConfigPropertyLogDebug(String propertyKey, Map overrides, AbstractSession session){
         Object value = null;
         if (overrides != null){
             value = overrides.get(propertyKey);
@@ -390,54 +197,44 @@
         
         return value;
     }
-
-    public static void createOrReplaceDefaultTables(
-        SchemaManager mgr, boolean shouldDropFirst) {          
-        if (shouldDropFirst){
-            mgr.replaceDefaultTables(true, true); 
-        } else { 
-            mgr.createDefaultTables(true); 
-        }
+    
+    /**
+     * Return the setup class for a given entity manager name 
+     * @param emName 
+     */
+    public static EntityManagerSetupImpl getEntityManagerSetupImpl(String emName){
+    	if (emName == null){
+    		return (EntityManagerSetupImpl)emSetupImpls.get("");
+    	}
+        return (EntityManagerSetupImpl)emSetupImpls.get(emName);
     }
 
-    public static void writeDDLsToFiles(SchemaManager mgr,  String appLocation,
-        String createDDLJdbc, String dropDDLJdbc) {
-        // Ensure that the appLocation string ends with  File.seperator 
-        appLocation = addFileSeperator(appLocation);
-        if (null != createDDLJdbc) {
-            String createJdbcFileName = appLocation + createDDLJdbc;
-            mgr.outputCreateDDLToFile(createJdbcFileName);
+    /**
+     * Logs in to given session. If user has not specified  <codeTARGET_DATABASE</code>
+     * the plaform would be auto detected
+     * @param session The session to login to.
+     * @param properties User specified properties for the persistence unit
+     */
+    protected static void login(ServerSession session, Map properties) {
+        String toplinkPlatform = (String)properties.get(PersistenceUnitProperties.TARGET_DATABASE);
+        if (!session.isConnected()) {
+            if (toplinkPlatform == null || toplinkPlatform.equals(TargetDatabase.Auto)) {
+                // if user has not specified a database platform, try to detect
+                session.loginAndDetectDatasource();
+            } else {
+                session.login();
+            }
         }
-
-        if (null != dropDDLJdbc) {
-            String dropJdbcFileName = appLocation + dropDDLJdbc;              
-            mgr.outputDropDDLToFile(dropJdbcFileName);
-        }
-
-        mgr.setCreateSQLFiles(false);
-        // When running in the application server environment always ensure that
-        // we write out both the drop and create table files.
-        createOrReplaceDefaultTables(mgr, true);
-        mgr.closeDDLWriter();
     }
     
-    public static String addFileSeperator(String appLocation) {
-        int strLength = appLocation.length();
-        if (appLocation.substring(strLength -1, strLength).equals(File.separator)) {
-            return appLocation;
-        } else {
-            return appLocation + File.separator;
-        }
-    }
-
-  /**
-   * Merge the properties from the source object into the target object.  If the property
-   * exists in both objects, use the one from the target
-   * @param target 
-   * @param source 
-   * @return the target object
-   */
-    public static Map mergeMaps(Map target, Map source){
+    /**
+     * Merge the properties from the source object into the target object.  If the property
+     * exists in both objects, use the one from the target
+     * @param target 
+     * @param source 
+     * @return the target object
+     */
+    protected static Map mergeMaps(Map target, Map source){
         Map map = new HashMap();
         if (source != null){
             map.putAll(source);
@@ -448,14 +245,23 @@
         }
         return map;
     }
-
-  /**
-   * This is a TEMPORARY method that will be removed.
-   * DON'T USE THIS METHOD - for internal use only.
-   * @param Map m
-   * @param AbstractSession session
-   */
-    public static void translateOldProperties(Map m, AbstractSession session) {
+    
+    protected static void runInSEMode(SchemaManager mgr, boolean shouldDropFirst) {
+        String str = getConfigPropertyAsString(PersistenceUnitProperties.JAVASE_DB_INTERACTION, null ,"true");
+        boolean interactWithDB = Boolean.valueOf(str.toLowerCase()).booleanValue();
+        if (!interactWithDB){
+            return;
+        }
+        createOrReplaceDefaultTables(mgr, shouldDropFirst);
+    }
+    
+    /**
+     * This is a TEMPORARY method that will be removed.
+     * DON'T USE THIS METHOD - for internal use only.
+     * @param Map m
+     * @param AbstractSession session
+     */
+    protected static void translateOldProperties(Map m, AbstractSession session) {
         for(int i=0; i < oldPropertyNames.length; i++) {
             Object value = getConfigPropertyAsString(oldPropertyNames[i][1], m);
             if(value != null) {
@@ -466,37 +272,33 @@
             }
         }
     }
-
-    public static void warnOldProperties(Map m, AbstractSession session) {
-        for(int i=0; i < oldPropertyNames.length; i++) {
-            Object value = m.get(oldPropertyNames[i][1]);
+    
+    protected static void warnOldProperties(Map m, AbstractSession session) {
+    	for(int i=0; i < oldPropertyNames.length; i++) {
+    		Object value = m.get(oldPropertyNames[i][1]);
             if(value != null) {
                 session.log(SessionLog.INFO, SessionLog.TRANSACTION, "deprecated_property", oldPropertyNames[i]);
             }
         }
     }
-    
-    /**
-     * Return the setup class for a given entity manager name 
-     * @param emName 
-     */
-      public static EntityManagerSetupImpl getEntityManagerSetupImpl(String emName){
-          if (emName == null){
-              return (EntityManagerSetupImpl)emSetupImpls.get("");
-          }
-          return (EntityManagerSetupImpl)emSetupImpls.get(emName);
-      }
-      
-      /**
-       * Add an EntityManagerSetupImpl to the cached list
-       * These are used to ensure all persistence units that are the same get the same underlying session
-       * @param name
-       * @param setup
-       */
-      public static void addEntityManagerSetupImpl(String name, EntityManagerSetupImpl setup){
-          if (name == null){
-              emSetupImpls.put("", setup);
-          }
-          emSetupImpls.put(name, setup);
-      }
+
+    protected static void writeDDLsToFiles(SchemaManager mgr,  String appLocation, String createDDLJdbc, String dropDDLJdbc) {
+    	// Ensure that the appLocation string ends with  File.seperator 
+        appLocation = addFileSeperator(appLocation);
+        if (null != createDDLJdbc) {
+        	String createJdbcFileName = appLocation + createDDLJdbc;
+            mgr.outputCreateDDLToFile(createJdbcFileName);
+        }
+
+        if (null != dropDDLJdbc) {
+        	String dropJdbcFileName = appLocation + dropDDLJdbc;              
+            mgr.outputDropDDLToFile(dropJdbcFileName);
+        }
+
+        mgr.setCreateSQLFiles(false);
+        // When running in the application server environment always ensure that
+        // we write out both the drop and create table files.
+        createOrReplaceDefaultTables(mgr, true);
+        mgr.closeDDLWriter();
+    }    
 }
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/EntityManagerSetupImpl.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/EntityManagerSetupImpl.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/EntityManagerSetupImpl.java	(working copy)
@@ -23,9 +23,7 @@
 
 import org.eclipse.persistence.jpa.config.PersistenceUnitProperties;
 import org.eclipse.persistence.jpa.config.BatchWriting;
-import org.eclipse.persistence.jpa.EntityManagerFactoryProvider;
 import org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform;
-import org.eclipse.persistence.internal.jpa.base.PropertiesHandler;
 import org.eclipse.persistence.internal.weaving.TransformerFactory;
 import org.eclipse.persistence.sessions.JNDIConnector;
 import org.eclipse.persistence.logging.AbstractSessionLog;
@@ -40,7 +38,6 @@
 import org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor;
 import org.eclipse.persistence.sessions.factories.SessionManager;
 import org.eclipse.persistence.descriptors.ClassDescriptor;
-import org.eclipse.persistence.internal.jpa.base.CMP3Policy;
 import org.eclipse.persistence.platform.server.CustomServerPlatform;
 import org.eclipse.persistence.platform.server.ServerPlatform;
 import org.eclipse.persistence.exceptions.*;
@@ -51,7 +48,7 @@
 import org.eclipse.persistence.internal.security.PrivilegedNewInstanceFromClass;
 import org.eclipse.persistence.internal.sessions.factories.XMLSessionConfigLoader;
 import org.eclipse.persistence.jpa.config.LoggerType;
-import org.eclipse.persistence.internal.jpa.jdbc.base.DataSourceImpl;
+import org.eclipse.persistence.internal.jpa.jdbc.DataSourceImpl;
 import org.eclipse.persistence.internal.sessions.factories.DescriptorCustomizer;
 import org.eclipse.persistence.internal.sessions.factories.SessionCustomizer;
 import org.eclipse.persistence.internal.security.SecurableObjectHolder;
@@ -59,7 +56,7 @@
 import org.eclipse.persistence.queries.DatabaseQuery;
 import org.eclipse.persistence.platform.database.converters.StructConverter;
 
-import static org.eclipse.persistence.jpa.EntityManagerFactoryProvider.*;
+import static org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.*;
 
 /**
  * INTERNAL:
@@ -692,7 +689,7 @@
             }
             
             boolean throwExceptionOnFail = "true".equalsIgnoreCase(
-                    EntityManagerFactoryProvider.getConfigPropertyAsStringLogDebug(EntityManagerFactoryProvider.TOPLINK_ORM_THROW_EXCEPTIONS, predeployProperties, "true", session));                
+                    EntityManagerFactoryProvider.getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.TOPLINK_ORM_THROW_EXCEPTIONS, predeployProperties, "true", session));                
     
             ClassTransformer transformer = null;
             if (!isSessionLoadedFromSessionsXML ) {
@@ -786,7 +783,7 @@
         if (shouldMergeMap) {
             m = mergeWithExistingMap(m);
         }
-        String validationOnlyString = getConfigPropertyAsStringLogDebug(TOPLINK_VALIDATION_ONLY_PROPERTY, m, session);
+        String validationOnlyString = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.TOPLINK_VALIDATION_ONLY_PROPERTY, m, session);
         if (validationOnlyString != null) {
             return Boolean.parseBoolean(validationOnlyString);
         } else {
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/JavaSECMPInitializer.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/JavaSECMPInitializer.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/JavaSECMPInitializer.java	(working copy)
@@ -25,7 +25,6 @@
 import org.eclipse.persistence.internal.jpa.deployment.Archive;
 import org.eclipse.persistence.exceptions.*;
 import org.eclipse.persistence.logging.SessionLog;
-import org.eclipse.persistence.jpa.EntityManagerFactoryProvider;
 import org.eclipse.persistence.jpa.PersistenceProvider;
 
 import javax.persistence.PersistenceException;
@@ -40,7 +39,7 @@
  *
  * It is called internally by our Provider
  *
- * @see org.eclipse.persistence.jpa.EntityManagerFactoryProvider
+ * @see org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider
  */
 public class JavaSECMPInitializer implements PersistenceInitializationActivator {
 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/columns/XMLJoinColumns.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/columns/XMLJoinColumns.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/columns/XMLJoinColumns.java	(working copy)
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.columns;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
-import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataJoinColumns;
-
-/**
- * Object to hold onto xml join column metadata.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLJoinColumns extends MetadataJoinColumns {
-    /**
-     * INTERNAL:
-     */
-    public XMLJoinColumns(Node node, XMLHelper helper) {
-        this(helper.getNodes(node, XMLConstants.JOIN_COLUMN), helper);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public XMLJoinColumns(NodeList nodes, XMLHelper helper) {
-        for (int i = 0; i < nodes.getLength(); i++) {
-            m_joinColumns.add(new XMLJoinColumn(nodes.item(i), helper));
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public boolean loadedFromXML() {
-        return true;
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/columns/XMLDiscriminatorColumn.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/columns/XMLDiscriminatorColumn.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/columns/XMLDiscriminatorColumn.java	(working copy)
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.columns;
-
-import org.w3c.dom.Node;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
-import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataDiscriminatorColumn;
-
-/**
- * Object to hold onto an xml discriminator column metadata.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLDiscriminatorColumn extends MetadataDiscriminatorColumn {
-    protected Node m_node;
-    protected XMLHelper m_helper;
-    
-    /**
-     * INTERNAL:
-     */
-    public XMLDiscriminatorColumn(Node node, XMLHelper helper) {
-        m_node = node;
-        m_helper = helper;
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getColumnDefinition() {
-        return m_helper.getNodeValue(m_node, XMLConstants.ATT_COLUMN_DEFINITION, DEFAULT_COLUMN_DEFINITION);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getDiscriminatorType() {
-        return m_helper.getNodeValue(m_node, XMLConstants.ATT_DISCRIMINATOR_TYPE, DEFAULT_DISCRIMINATOR_TYPE);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public int getLength() {
-        return m_helper.getNodeValue(m_node, XMLConstants.ATT_LENGTH, DEFAULT_LENGTH);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getName() {
-        return m_helper.getNodeValue(m_node, XMLConstants.ATT_NAME);
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/columns/XMLPrimaryKeyJoinColumn.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/columns/XMLPrimaryKeyJoinColumn.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/columns/XMLPrimaryKeyJoinColumn.java	(working copy)
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.columns;
-
-import org.w3c.dom.Node;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
-import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataPrimaryKeyJoinColumn;
-
-import org.eclipse.persistence.internal.helper.DatabaseTable;
-
-/**
- * Object to hold onto XML primary key join column metadata in TopLink database 
- * fields.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLPrimaryKeyJoinColumn extends MetadataPrimaryKeyJoinColumn {
-    /**
-     * INTERNAL:
-     */
-    public XMLPrimaryKeyJoinColumn(DatabaseTable sourceTable, DatabaseTable targetTable) {
-        super(sourceTable, targetTable);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public XMLPrimaryKeyJoinColumn(Node node, XMLHelper helper, DatabaseTable sourceTable, DatabaseTable targetTable) {
-        super(sourceTable, targetTable);
-
-        if (node != null) {
-            // Process the primary key field metadata.
-            m_pkField.setName(helper.getNodeValue(node, XMLConstants.ATT_REFERENCED_COLUMN_NAME, DEFAULT_REFERENCED_COLUMN_NAME));
-        
-            // Process the foreign key field metadata.
-            m_fkField.setName(helper.getNodeValue(node, XMLConstants.ATT_NAME, DEFAULT_NAME));
-            m_fkField.setColumnDefinition(helper.getNodeValue(node, XMLConstants.ATT_COLUMN_DEFINITION, DEFAULT_COLUMN_DEFINITION));
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public boolean loadedFromXML() {
-        return true;
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/columns/XMLColumn.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/columns/XMLColumn.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/columns/XMLColumn.java	(working copy)
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.columns;
-
-import java.lang.reflect.AnnotatedElement;
-
-import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataColumn;
-
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLBasicAccessor;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-
-import org.w3c.dom.Node;
-
-/**
- * Object to hold onto an xml column metadata in a TopLink database field.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLColumn extends MetadataColumn {
-    /**
-     * INTERNAL:
-     * Called for attribute overrides from a class accessor or embedded 
-     * accessor. If there is no column node, the database field values will 
-     * default.
-     */
-    public XMLColumn(Node node, XMLHelper helper, AnnotatedElement annotatedElement) {
-        super(helper.getNodeValue(node, XMLConstants.ATT_NAME), annotatedElement);
-        
-        processColumnNode(helper.getNode(node, XMLConstants.COLUMN), helper);
-    }
-    
-    /**
-     * INTERNAL:
-     * Called for basic accessors. If there is no column node, the database 
-     * field values will default.
-     */
-    public XMLColumn(Node node, XMLHelper helper, XMLBasicAccessor accessor) {
-        super(accessor.getAttributeName(), accessor.getAnnotatedElement());
-        
-        processColumnNode(node, helper);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public boolean loadedFromXML() {
-        return true;
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    protected void processColumnNode(Node node, XMLHelper helper) {
-        if (node != null) {
-            // Process the name attribute node.
-            m_databaseField.setName(helper.getNodeValue(node, XMLConstants.ATT_NAME, DEFAULT_NAME));
-        
-            // Process the table attribute node.
-            m_databaseField.setTableName(helper.getNodeValue(node, XMLConstants.ATT_TABLE, DEFAULT_TABLE));
-        
-            // Process the insertable attribute node.
-            m_databaseField.setInsertable(helper.getNodeValue(node, XMLConstants.ATT_INSERTABLE, DEFAULT_INSERTABLE));
-        
-            // Process the updatable attribute node.
-            m_databaseField.setUpdatable(helper.getNodeValue(node, XMLConstants.ATT_UPDATABLE, DEFAULT_UPDATABLE));
-        
-            // Process the unique attribute node.
-            m_databaseField.setUnique(helper.getNodeValue(node, XMLConstants.ATT_UNIQUE, DEFAULT_UNIQUE));
-        
-            // Process the nullable attribute node.
-            m_databaseField.setNullable(helper.getNodeValue(node, XMLConstants.ATT_NULLABLE, DEFAULT_NULLABLE));
-        
-            // Process the column-definition attribute node.
-            m_databaseField.setColumnDefinition(helper.getNodeValue(node, XMLConstants.ATT_COLUMN_DEFINITION, DEFAULT_COLUMN_DEFINITION));
-        
-            // Process the length attribute node.
-            m_databaseField.setLength(helper.getNodeValue(node, XMLConstants.ATT_LENGTH, DEFAULT_LENGTH));
-        
-            // Process the precision attribute node.
-            m_databaseField.setPrecision(helper.getNodeValue(node, XMLConstants.ATT_PRECISION, DEFAULT_PRECISION));
-        
-            // Process the scale attribute node.
-            m_databaseField.setScale(helper.getNodeValue(node, XMLConstants.ATT_SCALE, DEFAULT_SCALE));
-        }
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/columns/XMLJoinColumn.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/columns/XMLJoinColumn.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/columns/XMLJoinColumn.java	(working copy)
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.columns;
-
-import org.w3c.dom.Node;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
-import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataJoinColumn;
-
-/**
- * Object to hold onto xml join column metadata in a TopLink database fields.
- * 
- * @author Guy Pelletier
- * @since TopLink 10.1.3/EJB 3.0 Preview
- */
-public class XMLJoinColumn extends MetadataJoinColumn {
-    /**
-     * INTERNAL:
-     * Called for association override.
-     */
-    public XMLJoinColumn(Node node, XMLHelper helper) {
-        // Process the primary key field metadata.
-        m_pkField.setName(helper.getNodeValue(node, XMLConstants.ATT_REFERENCED_COLUMN_NAME, DEFAULT_REFERENCED_COLUMN_NAME));
-        
-        // Process the foreign key field metadata.
-        m_fkField.setName(helper.getNodeValue(node, XMLConstants.ATT_NAME, DEFAULT_NAME));
-        m_fkField.setTableName(helper.getNodeValue(node, XMLConstants.ATT_TABLE, DEFAULT_TABLE));
-        m_fkField.setUnique(helper.getNodeValue(node, XMLConstants.ATT_UNIQUE, DEFAULT_UNIQUE));
-        m_fkField.setNullable(helper.getNodeValue(node, XMLConstants.ATT_NULLABLE, DEFAULT_NULLABLE));
-        m_fkField.setUpdatable(helper.getNodeValue(node, XMLConstants.ATT_UPDATABLE, DEFAULT_UPDATABLE));
-        m_fkField.setInsertable(helper.getNodeValue(node, XMLConstants.ATT_INSERTABLE, DEFAULT_INSERTABLE));
-        m_fkField.setColumnDefinition(helper.getNodeValue(node, XMLConstants.ATT_COLUMN_DEFINITION, DEFAULT_COLUMN_DEFINITION));
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public boolean loadedFromXML() {
-        return true;
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/columns/XMLPrimaryKeyJoinColumns.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/columns/XMLPrimaryKeyJoinColumns.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/columns/XMLPrimaryKeyJoinColumns.java	(working copy)
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.columns;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
-import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataPrimaryKeyJoinColumns;
-
-import org.eclipse.persistence.internal.helper.DatabaseTable;
-
-/**
- * Object to hold onto XML primary key join column metadata.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLPrimaryKeyJoinColumns extends MetadataPrimaryKeyJoinColumns {    
-    /**
-     * INTERNAL:
-     */
-    public XMLPrimaryKeyJoinColumns(Node node, XMLHelper helper, DatabaseTable sourceTable, DatabaseTable targetTable) {
-        super(sourceTable, targetTable);
-
-        // Process the primary-key-join-column nodes.        
-        NodeList nodes = helper.getNodes(node, XMLConstants.PK_JOIN_COLUMN);
-
-        if (nodes != null) {
-            for (int i = 0; i < nodes.getLength(); i++) {
-                m_pkJoinColumns.add(new XMLPrimaryKeyJoinColumn(nodes.item(i), helper, sourceTable, targetTable));
-            }
-		}
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public boolean loadedFromXML() {
-        return true;
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/XMLHelper.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/XMLHelper.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/XMLHelper.java	(working copy)
@@ -1,662 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml;
-
-import java.io.InputStream;
-import java.io.IOException;
-
-import java.net.URL;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import org.xml.sax.SAXException;
-
-import org.eclipse.persistence.exceptions.XMLParseException;
-import org.eclipse.persistence.exceptions.ValidationException;
-
-import org.eclipse.persistence.internal.jpa.metadata.MetadataConstants;
-import org.eclipse.persistence.internal.jpa.metadata.MetadataHelper;
-import org.eclipse.persistence.internal.jpa.metadata.MetadataLogger;
-
-import org.eclipse.persistence.internal.jpa.xml.parser.XPathEngine;
-import org.eclipse.persistence.internal.jpa.xml.parser.XMLException;
-import org.eclipse.persistence.internal.jpa.xml.parser.XMLExceptionHandler;
-
-/**
- * Utility class used for handling element inspection.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLHelper {
-	private Document m_document;
-    private ClassLoader m_loader;
-    private String m_documentName;
-    private String m_defaultPackage;
-	private XPathEngine m_xPathEngine;
-	
-	/**
-	 * INTERNAL:
-	 */
-	protected XMLHelper(Document document, ClassLoader loader) {
-		m_xPathEngine = XPathEngine.getInstance();
-		m_loader = loader;
-		m_document = document;
-		
-		Node node = getNode(document, new String[] {XMLConstants.ENTITY_MAPPINGS, XMLConstants.PACKAGE, XMLConstants.TEXT});
-        
-        if (node != null && node.getNodeValue() != null) {
-        	m_defaultPackage = node.getNodeValue();
-        } else {
-        	m_defaultPackage = "";
-        }
-	}
-    
-    /**
-     * INTERNAL:
-     */
-    public XMLHelper(Document document, String fileName, ClassLoader loader) {
-        this(document, loader);
-        m_documentName = fileName;
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public List<String> getCascadeTypes(Node node) {
-        ArrayList<String> cTypes = new ArrayList<String>();
-        
-        NodeList cascadeTypes = getNodes(node, XMLConstants.CASCADE, XMLConstants.ALL_CHILDREN);
-		for (int i = 0; i < cascadeTypes.getLength(); i++) {
-            cTypes.add(cascadeTypes.item(i).getLocalName());
-        }
-        
-        return cTypes;
-    }
-    
-    /**
-     * INTERNAL:
-     */
-	public Class getClassForName(String className) {
-		return MetadataHelper.getClassForName(getFullyQualifiedClassName(className), m_loader);
-	}
-
-    /**
-	 * INTERNAL:
-	 * Return the Class for a given node. This method assumes that the node 
-     * requires a class attribute, i.e. entity or mapped-superclass.
-	 */
-	public Class getClassForNode(Node node) {
-		return MetadataHelper.getClassForName(getClassNameForNode(node), m_loader);
-	}
-	
-	/**
-	 * INTERNAL:
-	 * Return the fully qualified class name for a given node. This method 
-     * assumes that the node requires a class attribute, i.e. entity or 
-     * mapped-superclass.
-	 */
-	public String getClassNameForNode(Node node) {
-        return getFullyQualifiedClassName(getNodeValue(node, XMLConstants.ATT_CLASS));
-	}
-    
-	/**
-	 * INTERNAL:
-	 * Return the instance document associated with this helper.
-	 */
-	public Document getDocument() {
-		return m_document;
-	}
-    
-    /**
-	 * INTERNAL:
-	 * Return the instance document name associated with this helper.
-	 */
-	public String getDocumentName() {
-		return m_documentName;
-	}
-
-    /**
-     * INTERNAL:
-     */
-    public String getFetchTypeDefaultEAGER(Node node) {
-        return getNodeValue(node, XMLConstants.ATT_FETCH, MetadataConstants.EAGER);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getFetchTypeDefaultLAZY(Node node) {
-        return getNodeValue(node, XMLConstants.ATT_FETCH, MetadataConstants.LAZY);
-    }
-    
-    /**
-     * INTERNAL:
-     * This convenience method will attempt to fully qualify a class name if 
-     * required. This assumes that the className value is non-null, and a 
-     * "qualified" class name contains at least one '.'
-     */
-	public String getFullyQualifiedClassName(String className) {
-        return getFullyQualifiedClassName(className, m_defaultPackage);
-    }
-    
-    /**
-     * INTERNAL:
-     * This convenience method will attempt to fully qualify a class name if 
-     * required. This assumes that the className value is non-null, and a 
-     * "qualified" class name contains at least one '.'
-     */
-    public static String getFullyQualifiedClassName(String className, String packageName) {
-        // if there is no global package defined or the class name is qualified, return className
-        if (packageName.equals("") || className.indexOf(".") != -1) {
-            return className;
-        }
-        
-        // prepend the package to the class name
-        // format of global package is "foo.bar."
-        if (packageName.endsWith(".")) {
-            return (packageName + className);
-        }
-        
-        // format of global package is "foo.bar"
-        return (packageName + "." + className);
-    }
-    
-    /**
-     * INTERNAL:
-     * This convenience method determines the type of relationship mapping the
-     * node represents, and returns the appropriate logging context.
-     */
-    public String getLoggingContextForDefaultMappingReferenceClass(Node mappingNode) {
-        if (mappingNode.getLocalName().equals(XMLConstants.ONE_TO_ONE)) {
-            return MetadataLogger.ONE_TO_ONE_MAPPING_REFERENCE_CLASS;
-        }
-        if (mappingNode.getLocalName().equals(XMLConstants.ONE_TO_MANY)) {
-            return MetadataLogger.ONE_TO_MANY_MAPPING_REFERENCE_CLASS;
-        }
-        if (mappingNode.getLocalName().equals(XMLConstants.MANY_TO_ONE)) {
-            return MetadataLogger.MANY_TO_ONE_MAPPING_REFERENCE_CLASS;
-        }
-        // assume many-to-many
-        return MetadataLogger.MANY_TO_MANY_MAPPING_REFERENCE_CLASS;
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getMappedBy(Node node) {
-        return getNodeValue(node, XMLConstants.ATT_MAPPED_BY, "");
-    }
-    
-    /**
-     * INTERNAL:
-     * Get a node off the given node.
-     */
-    public Node getNode(Node node, String xPath) {
-        return getNode(node, new String[] {xPath});
-    }
-    
-    /**
-     * INTERNAL:
-     * Get a node off the given node.
-     */
-    public Node getNode(Node node, String[] xPath) {
-        return m_xPathEngine.selectSingleNode(node, xPath);
-    }
-    
-    /**
-     * INTERNAL:
-     * Get a node off the document node.
-     */
-    public Node getNode(String[] xPath) {
-        return getNode(m_document, xPath);
-    }
-    
-    /**
-     * INTERNAL:
-     * Get the nodes off the given node.
-     */
-    public NodeList getNodes(String xPath1, String xPath2) {
-        return getNodes(m_document, new String[] {xPath1, xPath2});
-    }
-    
-    /**
-     * INTERNAL:
-     * Get the nodes off the given node.
-     */
-    public NodeList getNodes(String[] xPath) {
-        return getNodes(m_document, xPath);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getNodeTextValue(Node node, String xPath) {
-        return getNodeValue(node, new String[] {xPath, XMLConstants.TEXT});
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getNodeTextValue(String xPath1, String xPath2) {
-        return getNodeValue(m_document, new String[] {xPath1, xPath2, XMLConstants.TEXT});
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getNodeTextValue(String xPath1, String xPath2, String defaultValue) {
-        return getNodeValue(m_document, new String[] {xPath1, xPath2, XMLConstants.TEXT}, defaultValue);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getNodeValue(Node node, String xPath) {
-        return getNodeValue(node, new String[] {xPath});
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public boolean getNodeValue(Node node, String xPath, boolean defaultValue) {
-        return getNodeValue(node, new String[] {xPath}, defaultValue);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public Class getNodeValue(Node node, String xPath, Class defaultValue) {
-        return getNodeValue(node, new String[] {xPath}, defaultValue);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public int getNodeValue(Node node, String xPath, int defaultValue) {
-        return getNodeValue(node, new String[] {xPath}, defaultValue);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getNodeValue(Node node, String xPath, String defaultValue) {
-        return getNodeValue(node, new String[] {xPath}, defaultValue);
-    }
-
-    /**
-     * INTERNAL:
-     */
-    public NodeList getNodes(Node node, String xPath) {
-        return getNodes(node, new String[] {xPath});
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public NodeList getNodes(Node node, String xPath1, String xPath2) {
-        return getNodes(node, new String[] {xPath1, xPath2});
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public NodeList getNodes(Node node, String[] xPath) {
-        return m_xPathEngine.selectNodes(node, xPath);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public boolean getNodeValue(Node node, String[] xPath, boolean defaultValue) {
-        return getValue(getNode(node, xPath), defaultValue);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public Class getNodeValue(Node node, String[] xPath, Class defaultValue) {
-        return getValue(getNode(node, xPath), defaultValue);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public int getNodeValue(Node node, String[] xPath, int defaultValue) {
-        return getValue(getNode(node, xPath), defaultValue);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getNodeValue(Node node, String[] xPath, String defaultValue) {
-        return getValue(getNode(node, xPath), defaultValue);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getNodeValue(Node node, String[] xPath) {
-        return getNodeValue(node, xPath, "");
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getNodeValue(String[] xPath) {
-        return getNodeValue(xPath, "");
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public int getNodeValue(String[] xPath, int defaultValue) {
-        return getValue(getNode(xPath), defaultValue);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getNodeValue(String[] xPath, String defaultValue) {
-        return getValue(getNode(xPath), defaultValue);
-    }
-
-	/**
-	 * INTERNAL:
-	 */
-	public String getPackage() {
-		return m_defaultPackage;
-	}
-    
-    /**
-     * INTERNAL:
-     */    
-    public Class getTargetEntity(Node node) {
-        return getNodeValue(node, XMLConstants.ATT_TARGET_ENTITY, void.class);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public NodeList getTextColumnNodes(Node node) {
-        return getNodes(node, new String[] {XMLConstants.COLUMN_NAME, XMLConstants.TEXT});
-    }
-
-    /**
-     * INTERNAL:
-     */
-    private boolean getValue(Node node, boolean defaultValue) {
-        if (node == null) {
-            return defaultValue;
-        } else {
-            return Boolean.parseBoolean(node.getNodeValue());
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    private Class getValue(Node node, Class defaultValue) {
-        if (node == null) {
-            return defaultValue;
-        } else {
-            return getClassForName(node.getNodeValue());
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    private int getValue(Node node, int defaultValue) {
-        if (node == null) {
-            return defaultValue;
-        } else {
-            return Integer.parseInt(node.getNodeValue());
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    private String getValue(Node node, String defaultValue) {
-        if (node == null) {
-            return defaultValue;
-        } else {
-            String value = node.getNodeValue();
-            if (value == null) {
-                return defaultValue;
-            } else {
-                return value;
-            }
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public boolean hasNode(Node node, String xPath) {
-        return getNode(node, xPath) != null;
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public boolean isOptional(Node node) {
-        return getNodeValue(node, XMLConstants.ATT_OPTIONAL, true);
-    }
-    
-    /**
-     * INTERNAL:
-     * Locate a node in the DOM tree for a given class.  
-     */
-    public Node locateEmbeddableNode(Class cls) {
-        return locateNode(cls, XMLConstants.EMBEDDABLE);
-    }
-    
-    /**
-     * INTERNAL:
-     * Locate a node in the DOM tree for a given class.
-     */
-    public Node locateEntityNode(Class cls) {
-        return locateNode(cls, XMLConstants.ENTITY);
-    }
-    
-    /**
-     * INTERNAL:
-     * Locate a node in the DOM tree for a given class.
-     */
-    public Node locateMappedSuperclassNode(Class cls) {
-        return locateNode(cls, XMLConstants.MAPPED_SUPERCLASS);
-    }
-    
-    /**
-     * INTERNAL:
-     * Locate a node in the DOM tree for the given class. Will look for
-     * an entity, embeddable, or mapped-superclass node with @class matching
-     * the class name.
-     */
-    public Node locateNode(Class cls) {
-    	Node result = null;
-        result = locateEntityNode(cls);
-    	
-        if (result == null) {
-        	result = locateMappedSuperclassNode(cls);
-    	}
-        
-    	if (result == null) {
-    		result = locateEmbeddableNode(cls);
-    	}
-        
-    	return result;
-    }
-    
-    /**
-     * INTERNAL:
-     * Locate a node in the DOM tree for a given class.
-     * The search string should be used as follows:
-     *  - For an entity: XMLConstants.ENTITY 
-     *  - For an embeddable: XMLConstants.EMBEDDABLE
-     *  - For a mapped superclass: XMLConstants.MAPPED_SUPERCLASS
-     *  Or call locateNode which will check them all. For efficiency, it looks
-     *  for an entity first.
-     */
-    private Node locateNode(Class cls, String searchString) {
-        NodeList nodes = getNodes(m_document, XMLConstants.ENTITY_MAPPINGS, searchString);
-
-        if (nodes != null) {
-            for (int i = 0; i < nodes.getLength(); i++) {
-                Node node = nodes.item(i);
-                // process @class (required)
-                if (getClassNameForNode(node).equals(cls.getName())) {
-                    return node;
-                }
-            }
-        }
-        
-        return null;
-    }
-
-    /**
-     * INTERNAL:
-     * Locate a node in the DOM tree for a given attribute name.  
-     */
-     // WIP - method may go away.
-    public Node locateNodeForAttribute(Node node, String attributeName) {
-        NodeList attributeNodes = getNodes(node, XMLConstants.ATTRIBUTES, XMLConstants.ALL_CHILDREN);
-
-        if (attributeNodes != null) {
-            Node attributeNode;
-            for (int i = 0; i < attributeNodes.getLength(); i++) {
-            	attributeNode = attributeNodes.item(i);
-                // process @name (required)
-                if (getNodeValue(attributeNode, XMLConstants.ATT_NAME).equals(attributeName)) {
-                    return attributeNode;
-                }
-            }
-        }
-        
-        return null;
-    }
-
-    /**
-     * INTERNAL:
-     * Return the root entity in an entity class hierarchy
-     */
-    public Class locateRootEntity(Class entityClass) {    
-    	Class superclass = entityClass.getSuperclass();
-        if (superclass != null) {
-            Node entityNode = locateEntityNode(superclass);
-            
-            if (entityNode != null) {
-                return locateRootEntity(superclass);
-            }
-        }
-        
-        return entityClass;
-    }
-
-    /**
-     * INTERNAL:
-     * Indicates if a given node has a primary-key-join-column sub-element.
-     */
-    public boolean nodeHasPrimaryKeyJoinColumns(Node node) {
-    	if (node == null) {
-    		return false;
-    	}
-
-    	NodeList nodes = getNodes(node, XMLConstants.PK_JOIN_COLUMN);
-    	return (nodes != null && nodes.getLength() > 0);
-    }
-    
-    /**
-     * INTERNAL:
-     * Indicates if a given node has a primary-key-join-column sub-element.
-     */
-    public boolean nodeHasJoinColumns(Node node) {
-    	if (node == null) {
-    		return false;
-    	}
-
-    	NodeList nodes = getNodes(node, XMLConstants.JOIN_COLUMN);
-    	return (nodes != null && nodes.getLength() > 0);
-    }
-    
-    /**
-     * INTERNAL:
-     * Build a DOM from an instance document using the provided URL.
-     */
-    public static Document parseDocument(InputStream xmlDocumentInputStream, String documentName, ClassLoader loader) {
-        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-        dbf.setNamespaceAware(true);
-        dbf.setAttribute(XMLConstants.SCHEMA_LANGUAGE, XMLConstants.XML_SCHEMA);
-        dbf.setValidating(true);
-        
-        // attempt to load the schema from the classpath
-        URL schemaURL = loader.getResource(XMLConstants.ORM_SCHEMA_NAME);
-        if (schemaURL != null) {
-        	dbf.setAttribute(XMLConstants.JAXP_SCHEMA_SOURCE, schemaURL.toString());
-        }
-        
-        // create a document builder
-        DocumentBuilder db;
-        try {
-            db = dbf.newDocumentBuilder();
-        } catch (ParserConfigurationException pex) {
-            throw XMLParseException.exceptionCreatingDocumentBuilder(documentName, pex);
-        }
-        
-        // set the parse exception handler
-        XMLExceptionHandler xmlExceptionHandler = new XMLExceptionHandler();
-        db.setErrorHandler(xmlExceptionHandler);
-        
-        // parse the document
-        Document doc = null;
-        try {
-            doc = db.parse(xmlDocumentInputStream);
-        } catch (IOException ioex) {
-            throw XMLParseException.exceptionReadingXMLDocument(documentName, ioex);
-        } catch (SAXException saxex) {
-        	// XMLExceptionHandler will handle parse exceptions
-        }
-        
-        XMLException xmlEx = xmlExceptionHandler.getXMLException();
-        if (xmlEx != null) {
-        	throw ValidationException.invalidEntityMappingsDocument(documentName, xmlEx);
-        }
-        
-        return doc;
-    }
-    
-    /**
-     * INTERNAL:
-     * Update the loader after it changes.
-     */
-    public void setLoader(ClassLoader loader) {
-        m_loader = loader;
-    }
-    
-    /**
-     * INTERNAL:
-     * Get the class loader.
-     */
-    public ClassLoader getClassLoader() {
-        return m_loader;
-    }
-
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/sequencing/XMLTableGenerator.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/sequencing/XMLTableGenerator.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/sequencing/XMLTableGenerator.java	(working copy)
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.sequencing;
-
-import java.util.List;
-import java.util.ArrayList;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLAccessor;
-
-import org.eclipse.persistence.internal.jpa.metadata.sequencing.MetadataTableGenerator;
-
-/**
- * Object to hold onto an xml table generator metadata.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLTableGenerator extends MetadataTableGenerator {
-    protected Node m_node;
-    protected XMLAccessor m_accessor;
-    
-    /**
-     * INTERNAL:
-     */
-    public XMLTableGenerator(Node node, XMLAccessor accessor) {
-        super(accessor.getDocumentName());
-        
-        m_node = node;
-        m_accessor = accessor;
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public int getAllocationSize() {
-        return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_ALLOCATION_SIZE, 50);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getCatalog() {
-        return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_CATALOG, m_accessor.getCatalog());
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public int getInitialValue() {
-        return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_INITIAL_VALUE, 0);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getName() {
-        return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_NAME);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getPkColumnName() {
-        return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_PK_COLUMN_NAME);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getPkColumnValue() {
-        return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_PK_COLUMN_VALUE);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getSchema() {
-        return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_SCHEMA, m_accessor.getSchema());
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getTable() {
-        return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_TABLE);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public List<String[]> getUniqueConstraints() {
-        if (m_uniqueConstraints == null) {
-            m_uniqueConstraints = new ArrayList<String[]>();
-            NodeList uniqueConstraintNodes = m_accessor.getHelper().getNodes(m_node, XMLConstants.UNIQUE_CONSTRAINTS);
-        
-            if (uniqueConstraintNodes != null) {
-                for (int i = 0; i < uniqueConstraintNodes.getLength(); i++) {
-                    NodeList columnNameNodes = m_accessor.getHelper().getTextColumnNodes(uniqueConstraintNodes.item(i));
-                
-                    if (columnNameNodes != null) {
-                        List<String> columnNames = new ArrayList<String>(columnNameNodes.getLength());
-                        for (int k = 0; k < columnNameNodes.getLength(); k++) {
-                            String columnName = columnNameNodes.item(k).getNodeValue();
-                        
-                            if (columnName != null && !columnName.equals("")) {
-                                columnNames.add(columnName);
-                            }
-                        }
-                        if (columnNames.size() > 0) {
-                            m_uniqueConstraints.add(columnNames.toArray(new String[0]));
-                        }
-                    }
-                }
-            }
-        }
-        
-        return m_uniqueConstraints;
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getValueColumnName() {
-        return m_accessor.getHelper().getNodeValue(m_node, XMLConstants.ATT_VALUE_COLUMN_NAME);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public boolean loadedFromAnnotations() {
-       return false; 
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public boolean loadedFromXML() {
-       return true; 
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/sequencing/XMLSequenceGenerator.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/sequencing/XMLSequenceGenerator.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/sequencing/XMLSequenceGenerator.java	(working copy)
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.sequencing;
-
-import org.w3c.dom.Node;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
-import org.eclipse.persistence.internal.jpa.metadata.sequencing.MetadataSequenceGenerator;
-
-/**
- * Object to hold onto an XML sequence generator metadata.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLSequenceGenerator extends MetadataSequenceGenerator {
-    private Node m_node;
-    private XMLHelper m_helper;
-    
-    /**
-     * INTERNAL:
-     */
-    public XMLSequenceGenerator(Node node, XMLHelper helper) {
-        super(helper.getDocumentName());
-        
-        m_node = node;
-        m_helper = helper;
-    }
-
-    /**
-     * INTERNAL:
-     */
-    public int getAllocationSize() {
-        return m_helper.getNodeValue(m_node, XMLConstants.ATT_ALLOCATION_SIZE, 50);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public int getInitialValue() {
-        return m_helper.getNodeValue(m_node, XMLConstants.ATT_INITIAL_VALUE, 0);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getName() {
-        return m_helper.getNodeValue(m_node, XMLConstants.ATT_NAME);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getSequenceName() {
-        return m_helper.getNodeValue(m_node, XMLConstants.ATT_SEQUENCE_NAME, getName());
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public boolean loadedFromAnnotations() {
-       return false; 
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public boolean loadedFromXML() {
-       return true; 
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/sequencing/XMLGeneratedValue.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/sequencing/XMLGeneratedValue.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/sequencing/XMLGeneratedValue.java	(working copy)
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.sequencing;
-
-import org.eclipse.persistence.internal.jpa.metadata.sequencing.MetadataGeneratedValue;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
-import org.w3c.dom.Node;
-
-/**
- * Metadata object to hold generated value information.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLGeneratedValue extends MetadataGeneratedValue {
-    protected Node m_node;
-    protected XMLHelper m_helper;
-    
-    /**
-     * INTERNAL:
-     */
-    public XMLGeneratedValue(Node node, XMLHelper helper) {
-        m_node = node;
-        m_helper = helper;
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-     */
-    public String getGenerator() {
-        return m_helper.getNodeValue(m_node, XMLConstants.ATT_GENERATOR);
-    }
-        
-    /**
-     * INTERNAL: (OVERRIDE)
-     */
-    public String getStrategy() {
-        return m_helper.getNodeValue(m_node, XMLConstants.ATT_STRATEGY, DEFAULT_STRATEGY);
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLMappedSuperclassAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLMappedSuperclassAccessor.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLMappedSuperclassAccessor.java	(working copy)
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.accessors;
-
-import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject;
-
-import org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor;
-import org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-
-import org.w3c.dom.Node;
-
-/**
- * An XML extended mapped superclass accessor.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLMappedSuperclassAccessor extends XMLClassAccessor {
-    /**
-     * INTERNAL:
-     */
-    public XMLMappedSuperclassAccessor(MetadataAccessibleObject accessibleObject, Node node, XMLHelper helper, MetadataProcessor processor, MetadataDescriptor descriptor) {
-        super(accessibleObject, node, helper, processor, descriptor);
-    }
-    
-    /**
-     * INTERNAL:
-     * Process the items of interest on a mapped superclass.
-     */
-    public void process() {
-        processMappedSuperclass();
-    }
-}
-    
\ No newline at end of file
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLManyToManyAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLManyToManyAccessor.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLManyToManyAccessor.java	(working copy)
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.accessors;
-
-import java.util.List;
-
-import org.eclipse.persistence.internal.jpa.metadata.accessors.ManyToManyAccessor;
-import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject;
-
-import org.eclipse.persistence.internal.jpa.metadata.tables.MetadataJoinTable;
-
-import org.eclipse.persistence.internal.jpa.xml.tables.XMLJoinTable;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-
-import org.w3c.dom.Node;
-
-/**
- * A an extended many to many relationship accessor.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLManyToManyAccessor extends ManyToManyAccessor {    
-    protected Node m_node;
-    protected XMLHelper m_helper;
-    
-    /**
-     * INTERNAL:
-     */
-    public XMLManyToManyAccessor(MetadataAccessibleObject accessibleObject, Node node, XMLClassAccessor classAccessor) {
-        super(accessibleObject, classAccessor);
-        m_node = node;
-        m_helper = classAccessor.getHelper();
-    }
-    
-    /**
-     * INTERNAL: (Override from ManyToManyAccessor)
-     */
-    public List<String> getCascadeTypes() {
-        return m_helper.getCascadeTypes(m_node);
-    }
-    
-    /**
-     * INTERNAL: (Override from ManyToManyAccessor)
-     */
-    public String getFetchType() {
-        return m_helper.getFetchTypeDefaultLAZY(m_node);
-    }
-    
-    /**
-     * INTERNAL: (Override from CollectionAccessor)
-     */
-    public MetadataJoinTable getJoinTable() {
-        Node node = m_helper.getNode(m_node, XMLConstants.JOIN_TABLE);
-        
-        if (node == null) {
-            return super.getJoinTable();
-        } else {
-            return new XMLJoinTable(node, m_helper, m_logger);
-        }
-    }
-    
-    /**
-     * INTERNAL: (Override from CollectionAccessor)
-     * 
-     * Checks for a map-key node and returns its value if there is one. 
-     * Otherwise, ask the parent to look for an annotation.
-     */
-    public String getMapKey() { 
-        Node mapKeyNode = m_helper.getNode(m_node, XMLConstants.MAPKEY);
-        String mapKeyValue = m_helper.getNodeValue(m_node, XMLConstants.MAPKEY);
-        
-        if (mapKeyNode == null) {
-            return super.getMapKey();
-        } else {
-            return mapKeyValue;
-        }
-    }
-    
-    /**
-     * INTERNAL: (Override from ManyToManyAccessor)
-     */
-    public String getMappedBy() {
-        return m_helper.getMappedBy(m_node);
-    }
-    
-    /**
-     * INTERNAL: (Override from CollectionAccessor)
-     * 
-     * If the order value is not specified, "" is returned.
-     */
-    public String getOrderBy() {
-        if (hasOrderBy()) {
-            return m_helper.getNodeTextValue(m_node, XMLConstants.ORDER_BY);
-        } else {
-            return super.getOrderBy();
-        }
-    } 
-    
-    /**
-     * INTERNAL: (Override from ManyToManyAccessor)
-     */
-    public Class getTargetEntity() {
-        return m_helper.getTargetEntity(m_node);
-    }
-    
-    /**
-     * INTERNAL: (Override from CollectionAccessor)
-	 * Checks for an order-by node. If one isn't found, as the parent to look
-     * for an annotation.
-     */
-	public boolean hasOrderBy() {
-		Node orderByNode = m_helper.getNode(m_node, XMLConstants.ORDER_BY);
-        
-        if (orderByNode == null) {
-            return super.hasOrderBy();
-        } else {
-            return true;
-        }
-	}
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLAccessor.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLAccessor.java	(working copy)
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.accessors;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-
-/**
- * An XMLAccessor should implement this interface.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public interface XMLAccessor {
-    /**
-     * INTERNAL:
-     */
-    public String getCatalog();
-    
-    /**
-     * INTERNAL:
-     */
-    public String getDocumentName();
-    
-    /**
-     * INTERNAL:
-     */
-    public String getSchema();
-    
-    /**
-     * INTERNAL:
-     */
-    public XMLHelper getHelper();
-}
-    
\ No newline at end of file
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLBasicAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLBasicAccessor.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLBasicAccessor.java	(working copy)
@@ -1,253 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.accessors;
-
-import org.eclipse.persistence.internal.jpa.metadata.accessors.BasicAccessor;
-import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject;
-import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataColumn;
-
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLClassAccessor;
-
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLColumn;
-
-import org.eclipse.persistence.internal.jpa.xml.sequencing.XMLGeneratedValue;
-import org.eclipse.persistence.internal.jpa.xml.sequencing.XMLTableGenerator;
-import org.eclipse.persistence.internal.jpa.xml.sequencing.XMLSequenceGenerator;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
-import org.eclipse.persistence.internal.helper.DatabaseField;
-
-import org.w3c.dom.Node;
-
-/**
- * An XML extended basic accessor.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLBasicAccessor extends BasicAccessor implements XMLAccessor {
-    private Node m_node;
-    private XMLHelper m_helper;
-    
-    /**
-     * INTERNAL:
-     */
-    public XMLBasicAccessor(MetadataAccessibleObject accessibleObject, Node node, XMLClassAccessor classAccessor) {
-        super(accessibleObject, classAccessor);
-        m_node = node;
-        m_helper = classAccessor.getHelper();
-    }
-
-    /**
-     * INTERNAL:
-     */
-    public String getCatalog() {
-        return m_descriptor.getCatalog();
-    }
-    
-    /**
-     * INTERNAL: (Override from BasicAccessor)
-     * Build a metadata column. If one isn't found in XML then look for an
-     * annotation.
-     */
-    protected MetadataColumn getColumn(String loggingCtx) {
-        Node node = m_helper.getNode(m_node, XMLConstants.COLUMN);
-        
-        if (node != null) {
-            return new XMLColumn(node, m_helper, this);
-        } else {
-            return super.getColumn(loggingCtx);
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getDocumentName() {
-        return m_helper.getDocumentName();
-    }
-    
-    /**
-     * INTERNAL: (Override from DirectAccessor)
-     */
-    public String getEnumeratedType() {
-        if (hasEnumerated()) {
-            return m_helper.getNodeTextValue(m_node, XMLConstants.ENUMERATED);
-        } else {
-            return super.getEnumeratedType();
-        }
-    }
-    
-    /**
-     * INTERNAL: (Override from BasicAccessor)
-     */
-    public String getFetchType() {
-        return m_helper.getFetchTypeDefaultEAGER(m_node);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public XMLHelper getHelper() {
-        return m_helper;
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getSchema() {
-        return m_descriptor.getSchema();
-    }
-    
-    /**
-     * INTERNAL: (Override from DirectAccessor)
-     * 
-     * Return the temporal type for this accessor. Assumes there is a temporal
-     * node.
-     */
-    public String getTemporalType() {
-        if (hasTemporal()) {
-            return m_helper.getNodeTextValue(m_node, XMLConstants.TEMPORAL);
-        } else {
-            return super.getTemporalType();
-        }
-    }
-    
-    /**
-     * INTERNAL: (Override from DirectAccessor)
-     * 
-	 * Method to check if m_node has an enumerated sub-element.
-     */
-	public boolean hasEnumerated() {
-        Node node = m_helper.getNode(m_node, XMLConstants.ENUMERATED);
-        
-        if (node == null) {
-            return super.hasEnumerated();
-        } else {
-            return true;
-        }
-    }
-    
-    /**
-     * INTERNAL: (Override from DirectAccessor)
-     * 
-	 * Method to check if m_node has a temporal sub-element.
-     */
-	public boolean hasTemporal() {
-        Node node = m_helper.getNode(m_node, XMLConstants.TEMPORAL);
-        
-        if (node == null) {
-            return super.hasTemporal();
-        } else {
-            return true;
-        }
-    }
-    
-    /**
-     * INTERNAL: (Override from BasicAccessor)
-     * 
-	 * Method to check if m_node represents a primary key.
-	 */
-	public boolean isId() {
-        if (m_node.getLocalName().equals(XMLConstants.ID)) {
-            return true;
-        } else {
-            return super.isId();   
-        }
-    }
-    
-    /**
-     * INTERNAL: (Override from BasicAccessor)
-     */
-	public boolean isOptional() {
-        return m_helper.isOptional(m_node);
-    }
-    
-    /**
-     * INTERNAL: (Override from DirectAccessor)
-     * 
-     * Return true if this accessor represents an BLOB/CLOB mapping, i.e. has a 
-     * lob sub-element.
-     */
-	public boolean hasLob() {
-        Node node = m_helper.getNode(m_node, XMLConstants.LOB);
-        
-        if (node == null) {
-            return super.hasLob();
-        } else {
-            return true;
-        }
-    }
-    
-    /**
-     * INTERNAL: (Override from BasicAccessor)
-     * 
-	 * Return true if this accessor represents an optimistic locking field.
-     */
-	public boolean isVersion() {
-        if (m_node.getLocalName().equals(XMLConstants.VERSION)) {
-            return true;
-        } else {
-            return super.isVersion();   
-        }
-    }
-    
-    /**
-     * INTERNAL: (Override from BasicAccessor)
-     */
-    protected void processGeneratedValue(DatabaseField field) {
-        Node node = m_helper.getNode(m_node, XMLConstants.GENERATED_VALUE);
-
-        if (node == null) {
-            super.processGeneratedValue(field);
-        } else {
-            // Ask the common processor to process what we found.
-            processGeneratedValue(new XMLGeneratedValue(node, m_helper), field);
-        }
-    }
-    
-    /**
-     * INTERNAL: (Override from NonRelationshipAccessor)
-     * 
-	 * Process this accessor's sequence-generator node into a common metadata 
-     * sequence generator.
-     */
-    protected void processSequenceGenerator() {
-        Node node = m_helper.getNode(m_node, XMLConstants.SEQUENCE_GENERATOR);
-        
-        if (node != null) {
-            // Process the xml defined sequence generators first.
-            processSequenceGenerator(new XMLSequenceGenerator(node, m_helper));
-        }
-        
-        // Process the annotation defined sequence generators second.
-        super.processSequenceGenerator();
-    }
-    
-    /**
-     * INTERNAL: (Override from NonRelationshipAccessor)
-     * 
-	 * Process this accessor's table-generator node into a common metadata table 
-     * generator.
-     */
-    protected void processTableGenerator() {
-        Node node = m_helper.getNode(m_node, XMLConstants.TABLE_GENERATOR);
-        
-        if (node != null) {
-            // Process the xml defined table generators first.
-            processTableGenerator(new XMLTableGenerator(node, this));
-        }
-        
-        // Process the annotation defined sequence generators second.
-        super.processTableGenerator();
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLClassAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLClassAccessor.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLClassAccessor.java	(working copy)
@@ -1,747 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.accessors;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import java.net.URL;
-import java.util.Map;
-
-import org.eclipse.persistence.internal.jpa.metadata.accessors.ClassAccessor;
-import org.eclipse.persistence.internal.jpa.metadata.accessors.MetadataAccessor;
-
-import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject;
-import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataClass;
-import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataField;
-import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataMethod;
-
-import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataPrimaryKeyJoinColumns;
-
-import org.eclipse.persistence.internal.jpa.metadata.listeners.MetadataEntityListener;
-
-import org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor;
-import org.eclipse.persistence.internal.jpa.metadata.MetadataHelper;
-import org.eclipse.persistence.internal.jpa.metadata.MetadataPersistenceUnit;
-import org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor;
-
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLBasicAccessor;
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLEmbeddedAccessor;
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLManyToManyAccessor;
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLManyToOneAccessor;
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLOneToManyAccessor;
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLOneToOneAccessor;
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLTransientAccessor;
-
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLColumn;
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLDiscriminatorColumn;
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLJoinColumns;
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLPrimaryKeyJoinColumns;
-
-import org.eclipse.persistence.internal.jpa.xml.listeners.XMLEntityClassListener;
-import org.eclipse.persistence.internal.jpa.xml.listeners.XMLEntityListener;
-
-import org.eclipse.persistence.internal.jpa.xml.queries.XMLNamedNativeQuery;
-import org.eclipse.persistence.internal.jpa.xml.queries.XMLNamedQuery;
-import org.eclipse.persistence.internal.jpa.xml.queries.XMLSQLResultSetMapping;
-
-import org.eclipse.persistence.internal.jpa.xml.sequencing.XMLSequenceGenerator;
-import org.eclipse.persistence.internal.jpa.xml.sequencing.XMLTableGenerator;
-
-import org.eclipse.persistence.internal.jpa.xml.tables.XMLSecondaryTable;
-import org.eclipse.persistence.internal.jpa.xml.tables.XMLTable;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-
-import org.eclipse.persistence.internal.helper.DatabaseTable;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Document;
-
-/**
- * An XML extended class accessor.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLClassAccessor extends ClassAccessor implements XMLAccessor {
-    protected Node m_node;
-    protected XMLHelper m_helper;
-    
-    // These entity-mappings settings need to be available to all xml entities
-    // in the given xml file. The are processed by the first entity in the file.
-    protected static String m_entityMappingsAccess;
-    protected static String m_entityMappingsSchema;
-    protected static String m_entityMappingsCatalog;
-    
-    /**
-     * INTERNAL:
-     */
-    public XMLClassAccessor(MetadataAccessibleObject accessibleObject, Node node, XMLHelper helper, MetadataProcessor processor, MetadataDescriptor descriptor) {
-        super(accessibleObject, processor, descriptor);
-        m_node = node;
-        m_helper = helper;
-    }
-    
-    /**
-     * INTERNAL:
-     * Create and return the appropriate accessor based on the given node. 
-     */
-    protected MetadataAccessor buildAccessor(Node node) {
-        MetadataAccessibleObject accessibleObject;
-        
-        // Process the required name attribute.
-        String attributeName = m_helper.getNodeValue(node, XMLConstants.ATT_NAME);
-        
-        // WIP - left to do here is perform validation on the accessors just
-        // like the annotation processor does.
-        if (m_descriptor.usesPropertyAccess()) {
-            Method method = MetadataHelper.getMethodForPropertyName(attributeName, getJavaClass());
-            
-            if (method == null) {
-                m_validator.throwUnableToDetermineClassForProperty(attributeName, getJavaClass());
-            }
-            
-            accessibleObject = new MetadataMethod(method);
-        } else {
-            Field field = MetadataHelper.getFieldForName(attributeName, getJavaClass());
-            
-            if (field == null) {
-                m_validator.throwUnableToDetermineClassForField(attributeName, getJavaClass());
-            }
-            
-            accessibleObject = new MetadataField(field);
-        }
-        
-        String nodeName = node.getLocalName();
-        
-        if (nodeName.equals(XMLConstants.ONE_TO_ONE)) {
-            return new XMLOneToOneAccessor(accessibleObject, node, this);
-        } else if (nodeName.equals(XMLConstants.MANY_TO_ONE)) {
-            return new XMLManyToOneAccessor(accessibleObject, node, this);
-        } else if (nodeName.equals(XMLConstants.ONE_TO_MANY)) {
-            if (MetadataHelper.isSupportedCollectionClass(accessibleObject.getRawClass())) {
-                return new XMLOneToManyAccessor(accessibleObject, node, this);        
-            } else {
-                m_validator.throwInvalidCollectionTypeForRelationship(getJavaClass(), accessibleObject.getRawClass(), getAttributeName());
-                return null;
-            }
-        } else if (nodeName.equals(XMLConstants.MANY_TO_MANY)) {
-            if (MetadataHelper.isSupportedCollectionClass(accessibleObject.getRawClass())) {
-                return new XMLManyToManyAccessor(accessibleObject, node, this);
-            } else {
-                m_validator.throwInvalidCollectionTypeForRelationship(getJavaClass(), accessibleObject.getRawClass(), getAttributeName());
-                return null;
-            }
-        } else if (nodeName.equals(XMLConstants.EMBEDDED)) {
-            return new XMLEmbeddedAccessor(accessibleObject, node, this);
-        } else if (nodeName.equals(XMLConstants.EMBEDDED_ID)) {
-            return new XMLEmbeddedIdAccessor(accessibleObject, node, this);
-        } else if (nodeName.equals(XMLConstants.TRANSIENT)) {
-            return new XMLTransientAccessor(accessibleObject, node, this);
-        } else {
-            return new XMLBasicAccessor(accessibleObject, node, this);
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getCatalog() {
-        return XMLClassAccessor.m_entityMappingsCatalog;
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-     * Return the discriminator value for this accessor. If it is not defined 
-     * call the parent to check for an annotation.
-     */
-    public String getDiscriminatorValue() {
-        String discriminatorValue =  m_helper.getNodeTextValue(m_node, XMLConstants.DISCRIMINATOR_VALUE);
-        
-        if (discriminatorValue.equals("")) {
-            return super.getDiscriminatorValue();
-        } else {
-            return discriminatorValue;
-        }   
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getDocumentName() {
-        return m_helper.getDocumentName();
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-     * Return the name of this entity class. If it is not defined call the
-     * parent to check for an annotation.
-     */
-    public String getEntityName() {
-        String entityName = m_helper.getNodeValue(m_node, XMLConstants.ATT_NAME);
-        
-        if (entityName.equals("")) {
-            return super.getEntityName();
-        } else {
-            return entityName;
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public XMLHelper getHelper() {
-        return m_helper;
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-     * Return the inheritance strategy. This method should only be called
-     * on the root of the inheritance hierarchy.
-     */
-    protected String getInheritanceStrategy() {
-        Node inheritanceNode = m_helper.getNode(m_node, XMLConstants.INHERITANCE);
-        
-        if (inheritanceNode == null) {
-            return super.getInheritanceStrategy();
-        } else {
-            return m_helper.getNodeValue(inheritanceNode, XMLConstants.ATT_STRATEGY);
-        } 
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-     * Process the primary-key-join-column(s) elements.
-     */    
-    protected MetadataPrimaryKeyJoinColumns getPrimaryKeyJoinColumns(DatabaseTable sourceTable, DatabaseTable targetTable) {
-        if (m_helper.nodeHasPrimaryKeyJoinColumns(m_node)) {
-            return new XMLPrimaryKeyJoinColumns(m_node, m_helper, sourceTable, targetTable);
-        } else {
-            return super.getPrimaryKeyJoinColumns(sourceTable, targetTable);
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getSchema() {
-         return XMLClassAccessor.m_entityMappingsSchema;
-    }
-    
-    /**
-     * INTERNAL: (Override from ClassAccessor)
-     * 
-     * Return true if this class has an entity node.
-     */
-    protected boolean hasEntity(Class cls) {
-        Node node = m_helper.locateEntityNode(cls);
-        
-        if (node != null) {
-            return true;
-        } else {
-            return super.hasEntity(cls);
-        }
-    }
-    
-    /**
-     * INTERNAL: (Override from ClassAccessor)
-     * 
-     * Return true if this class has an inheritance node.
-     */
-    protected boolean hasInheritance(Class entityClass) {
-        Node node = m_helper.locateEntityNode(entityClass);
-        
-    	if (node != null && m_helper.hasNode(node, XMLConstants.INHERITANCE)) {
-            return true;
-    	} else {
-            return super.hasInheritance(entityClass);
-        }
-    }
-    
-    /**
-     * INTERNAL:
-	 * Return true if this is an XML processing accessor.
-     */
-	public boolean isXMLAccessor() {
-        return true;
-    }
-    
-    /**
-     * INTERNAL:
-     * Process any entity tag specifics then call the parent process.
-     */
-    public void process() {
-        // Process the metadata-complete attribute node.
-        m_descriptor.setIgnoreAnnotations(m_helper.getNodeValue(m_node, XMLConstants.ATT_METADATA_COMPLETE, m_descriptor.ignoreAnnotations()));
-            
-        // Process the access attribute.
-        m_descriptor.setAccess(m_helper.getNodeValue(m_node, XMLConstants.ATT_ACCESS, XMLClassAccessor.m_entityMappingsAccess));
-        
-        // Set the entity mapping schema value. The schema defaults to the
-        // persistence unit schema if it is not set.
-        m_descriptor.setSchema(XMLClassAccessor.m_entityMappingsSchema);
-            
-        // Set the entity mapping catalog value. The catalog defaults to the
-        // persistence unit catalog if it is not set.
-        m_descriptor.setCatalog(XMLClassAccessor.m_entityMappingsCatalog);
-        
-        super.process();
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-     * Fast track processing a ClassAccessor for the given descriptor. 
-     * Inheritance root classes and embeddables may be fast tracked.
-     */
-    protected ClassAccessor processAccessor(MetadataDescriptor descriptor) {
-        Node node = null;
-        XMLHelper xmlhelper = null;
-        
-        node = m_helper.locateEntityNode(descriptor.getJavaClass());
-        
-        if(node!=null){
-            xmlhelper = m_helper;
-        } else {
-            //Bug#5990636 Cover the case when the given descriptor defined in the separate mapping XML file rather than 
-            //the one referred by m_helper. 
-            for (Map.Entry<URL, Document> urlToDocPair : m_project.getMappingFiles().entrySet()) {
-                Document document = (Document)urlToDocPair.getValue();
-                xmlhelper = new XMLHelper(document, urlToDocPair.getKey().getFile(), m_helper.getClassLoader());
-                node = xmlhelper.locateEntityNode(descriptor.getJavaClass());
-                if(node!=null){
-                    break;
-                }
-            }
-        }
-        if (node != null) {
-            XMLClassAccessor accessor = new XMLClassAccessor(new MetadataClass(descriptor.getJavaClass()), node, xmlhelper, m_processor, descriptor);
-            descriptor.setClassAccessor(accessor);
-            accessor.process();
-            accessor.setIsProcessed();
-            return accessor;
-        } else {
-            return super.processAccessor(descriptor);
-        }
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-     * Process the accessors for the given class.
-     */
-    protected void processAccessors() {
-        NodeList nodes = m_helper.getNodes(m_node, XMLConstants.ATTRIBUTES, XMLConstants.ALL_CHILDREN);
-        
-        if (nodes != null) {
-            for (int i = 0; i < nodes.getLength(); i++) {
-                processAccessor(buildAccessor(nodes.item(i)));
-            }
-        }
-        
-        super.processAccessors();
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-     * Process the association overrides for a class that inherits from a
-     * mapped superclass. Once the association overrides are processed from
-     * XML process the association overrides from annotations.
-     */
-    protected void processAssociationOverrides() {
-        // Process the XML association override elements first.
-        NodeList nodes = m_helper.getNodes(m_node, XMLConstants.ASSOCIATION_OVERRIDE);
-        
-        if (nodes != null) {
-            for (int i = 0; i < nodes.getLength(); i++) {
-                Node node = nodes.item(i);
-                processAssociationOverride(m_helper.getNodeValue(node, XMLConstants.ATT_NAME), new XMLJoinColumns(node, m_helper));
-            }
-        }
-        
-        // Process the association override annotations second.
-        super.processAssociationOverrides();
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-	 * Process the attribute overrides for a class that inherits from a
-     * mapped superclass. Once the attribute overrides are processed from
-     * XML process the attribute overrides from annotations.
-	 */
-    protected void processAttributeOverrides() {
-        NodeList nodes = m_helper.getNodes(m_node, XMLConstants.ATTRIBUTE_OVERRIDE);
-        
-        if (nodes != null) {
-            for (int i = 0; i < nodes.getLength(); i++) {
-                processAttributeOverride(new XMLColumn(nodes.item(i), m_helper, getAnnotatedElement()));
-            }
-        }
-        
-        
-        // Now, Process the attribute override annotations second.
-        super.processAttributeOverrides();
-    }
-    
-    /**
-     * INTERNAL:
-     * Process an XML discriminator-column metadata. If we don't find a node
-     * here, check for an annotation by calling the parent. It will default if 
-     * no annotation is found.
-     */
-    protected void processDiscriminatorColumn() {
-        Node node = m_helper.getNode(m_node, XMLConstants.DISCRIMINATOR_COLUMN);
-        
-        if (node == null) {
-            super.processDiscriminatorColumn();
-        } else {
-            processDiscriminatorColumn(new XMLDiscriminatorColumn(node, m_helper));
-        }
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-     * Process the entity class for lifecycle callback event methods.
-     */
-    public MetadataEntityListener processEntityEventListener(ClassLoader loader) {
-        // Update the class loader.
-        m_helper.setLoader(loader);
-        
-        // Create the listener.
-        XMLEntityClassListener listener = new XMLEntityClassListener(getJavaClass());
-            
-        // Process the lifecycle callback events from XML.
-        Method[] candidateMethods = MetadataHelper.getCandidateCallbackMethodsForEntityClass(getJavaClass());
-        processLifecycleEvents(listener, m_node, m_helper, candidateMethods);
-            
-        // Check the entity class for lifecycle callback annotations.
-        processCallbackMethods(candidateMethods, listener);
-        
-        // WIP - at this point we should turn the override ignore off for 
-        // mapped superclasses ...
-        return listener;
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-     * Process the entity listeners for this class accessor. Entity listeners
-     * defined in XML will override those specified on the class.
-     */
-    public void processEntityListeners(Class entityClass, ClassLoader loader) {
-        // Update the class loader.
-        m_helper.setLoader(loader);
-        
-        NodeList nodes = m_helper.getNodes(m_node, new String[] {XMLConstants.ENTITY_LISTENERS, XMLConstants.ENTITY_LISTENER});
-        
-        if (nodes.getLength() > 0) {
-            for (int i = 0; i < nodes.getLength(); i++) {
-                Node node = nodes.item(i);
-                
-                // Build an xml entity listener.
-                XMLEntityListener listener = new XMLEntityListener(m_helper.getClassForNode(node), entityClass);
-                
-                // Process the lifecycle callback events from XML.
-                Method[] candidateMethods = MetadataHelper.getCandidateCallbackMethodsForEntityListener(listener);
-                processLifecycleEvents(listener, node, m_helper, candidateMethods);
-                
-                // Process the candidate callback methods on this listener for
-                // additional callback methods decorated with annotations.
-                processCallbackMethods(candidateMethods, listener);
-        
-                // Add the listener to the descriptor.
-                m_descriptor.addEntityListenerEventListener(listener);
-            }
-        } else {
-            super.processEntityListeners(entityClass, loader);
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     * Process the information contained in the entity-mappings node.
-     */
-    public void processEntityMappings() {
-        MetadataPersistenceUnit persistenceUnit = m_project.getPersistenceUnit();
-        
-        if (persistenceUnit != null) {
-            // Use the persistent unit defaults ..
-            XMLClassAccessor.m_entityMappingsAccess = m_helper.getNodeTextValue(XMLConstants.ENTITY_MAPPINGS, XMLConstants.ACCESS, persistenceUnit.getAccess());
-            XMLClassAccessor.m_entityMappingsSchema = m_helper.getNodeTextValue(XMLConstants.ENTITY_MAPPINGS, XMLConstants.SCHEMA, persistenceUnit.getSchema());
-            XMLClassAccessor.m_entityMappingsCatalog = m_helper.getNodeTextValue(XMLConstants.ENTITY_MAPPINGS, XMLConstants.CATALOG, persistenceUnit.getCatalog());
-        } else {
-            XMLClassAccessor.m_entityMappingsAccess = m_helper.getNodeTextValue(XMLConstants.ENTITY_MAPPINGS, XMLConstants.ACCESS);
-            XMLClassAccessor.m_entityMappingsSchema = m_helper.getNodeTextValue(XMLConstants.ENTITY_MAPPINGS, XMLConstants.SCHEMA);
-            XMLClassAccessor.m_entityMappingsCatalog = m_helper.getNodeTextValue(XMLConstants.ENTITY_MAPPINGS, XMLConstants.CATALOG);
-        }
-        
-        // Process the table-generator nodes.
-        NodeList tableGeneratorNodes = m_helper.getNodes(XMLConstants.ENTITY_MAPPINGS, XMLConstants.TABLE_GENERATOR);
-        
-        if (tableGeneratorNodes != null) {
-            for (int i = 0; i < tableGeneratorNodes.getLength(); i++) {
-                processTableGenerator(tableGeneratorNodes.item(i));
-            }
-        }
-        
-        // Process the sequence-generator nodes.
-        NodeList sequenceGeneratorNodes = m_helper.getNodes(XMLConstants.ENTITY_MAPPINGS, XMLConstants.SEQUENCE_GENERATOR);
-        
-        if (sequenceGeneratorNodes != null) {
-            for (int i = 0; i < sequenceGeneratorNodes.getLength(); i++) {
-                processSequenceGenerator(sequenceGeneratorNodes.item(i));
-            }
-        }
-        
-        // Process the named-query nodes.
-        processNamedQueries(m_helper.getNodes(XMLConstants.ENTITY_MAPPINGS, XMLConstants.NAMED_QUERY));
-
-        // Process the named-native-query nodes.
-        processNamedNativeQueries(m_helper.getNodes(XMLConstants.ENTITY_MAPPINGS, XMLConstants.NAMED_NATIVE_QUERY));
-
-        // Process the sql-result-set-mapping nodes.
-        processSqlResultSetMappings(m_helper.getNodes(XMLConstants.ENTITY_MAPPINGS, XMLConstants.SQL_RESULT_SET_MAPPING));
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-     * Process the exclude-default-listeners tag if one is specified, otherwise,
-     * ask the parent to look for an annotation.
-     */
-    protected void processExcludeDefaultListeners() {
-        if (m_helper.hasNode(m_node, XMLConstants.EXCLUDE_DEFAULT_LISTENERS)) {
-            m_descriptor.setExcludeDefaultListeners(true);
-        } else {
-            super.processExcludeDefaultListeners();
-        }
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-     * Process the exclude-superclass-listeners tag if one is specified, 
-     * otherwise, ask the parent to look for an annotation.
-     */
-    protected void processExcludeSuperclassListeners() {
-        if (m_helper.hasNode(m_node, XMLConstants.EXCLUDE_SUPERCLASS_LISTENERS)) {
-            m_descriptor.setExcludeSuperclassListeners(true);
-        } else {
-            super.processExcludeSuperclassListeners();
-        } 
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-     * 
-     * Process an id-class element
-     */
-    protected void processIdClass() {
-        Node result = m_helper.getNode(m_node, XMLConstants.ID_CLASS);
-        
-        if (result == null) {
-            // Check for an @IdClass annotation.
-            super.processIdClass();
-        } else {
-            processIdClass(m_helper.getClassForNode(result), m_logger.IGNORE_ID_CLASS_ELEMENT);
-        }
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-     * Process the mapped superclass class for lifecycle callback event methods.
-     */
-    public void processMappedSuperclassEventListener(MetadataEntityListener listener, Class entityClass, ClassLoader loader) {
-        // Update the class loader
-        m_helper.setLoader(loader);
-        
-        // Process the lifecycle callback events from XML.
-        Method[] candidateMethods = MetadataHelper.getCandidateCallbackMethodsForMappedSuperclass(getJavaClass(), entityClass);
-        processLifecycleEvents(listener, m_node, m_helper, candidateMethods);
-        
-        // Check for annotations on the mapped superclass now.
-        processCallbackMethods(candidateMethods, listener);
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-     * Process the named native queries for the given class which could be an 
-     * entity or a mapped superclass.
-     */
-    protected void processNamedNativeQueries() {
-        // Process the named native query elements first.
-        processNamedNativeQueries(m_helper.getNodes(m_node, XMLConstants.NAMED_NATIVE_QUERY));
-        
-        // Process the XML named native query annotations second.
-        super.processNamedNativeQueries();
-    }
-    
-    /**
-     * INTERNAL:
-     * Process named-queries at either the entity-mappings or entity level. The
-     * queries will be stored in a hashmap - EntityManagerSetupImpl will call 
-     * 'addNamedQueriesToSession()' after processing; this is when the queries
-     * will be added to the session.
-     */
-    protected void processNamedNativeQueries(NodeList queryNodes) {
-        if (queryNodes != null) {
-            for (int i = 0; i < queryNodes.getLength(); i++) {
-                // Ask the common processor to process what we found.
-                processNamedNativeQuery(new XMLNamedNativeQuery(queryNodes.item(i), m_helper));
-            }
-        }
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-     * Process the named queries for the given class which could be an entity
-     * or a mapped superclass.
-     */
-    protected void processNamedQueries() {
-        // Process the XML named query elements first.
-        processNamedQueries(m_helper.getNodes(m_node, XMLConstants.NAMED_QUERY));
-        
-        // Process the named query annotations second.
-        super.processNamedQueries();
-    }
-    
-    /**
-     * INTERNAL:
-     * Process named queries at either the entity-mapping or entity level. The 
-     * queries will be stored in a hashmap - EntityManagerSetupImpl will call 
-     * 'addNamedQueriesToSession()' after processing; this is when the queries
-     * will be added to the session.
-     */
-    protected void processNamedQueries(NodeList queryNodes) {
-        if (queryNodes != null) {
-            for (int i = 0; i < queryNodes.getLength(); i++) {
-                // Ask the common processor to process what we found.
-                processNamedQuery(new XMLNamedQuery(queryNodes.item(i), m_helper));
-            }
-        }
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-     * Process secondary-table(s) for a given entity.
-     */
-    protected void processSecondaryTables() {
-        NodeList secondaryTables = m_helper.getNodes(m_node, XMLConstants.SECONDARY_TABLE);
-        
-        if (secondaryTables == null) {
-            // Check for a secondary table annotation(s).
-            super.processSecondaryTables();
-        } else {
-            if (m_descriptor.ignoreTables()) {
-                m_logger.logWarningMessage(m_logger.IGNORE_SECONDARY_TABLE_ELEMENT, getJavaClass());
-            } else {
-                for (int i = 0; i < secondaryTables.getLength(); i++) {
-                    processSecondaryTable(new XMLSecondaryTable(secondaryTables.item(i), m_helper, m_logger));
-                }
-            }
-        }
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-	 * Process this accessor's sequence-generator node into a common metadata 
-     * sequence generator.
-     */
-    protected void processSequenceGenerator() {
-        // Process the xml defined sequence generators first.
-        processSequenceGenerator(m_helper.getNode(m_node, XMLConstants.SEQUENCE_GENERATOR));
-        
-        // Process the annotation defined sequence generators second.
-        super.processSequenceGenerator();
-    }
-    
-    /**
-     * INTERNAL:
-     * Process a sequence-generator node into a common metadata sequence 
-     * generator.
-     */
-    protected void processSequenceGenerator(Node node) {
-        if (node != null) {
-            // Ask the common processor to process what we found.
-            processSequenceGenerator(new XMLSequenceGenerator(node, m_helper));
-        }
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-     * Process the sql result set mappings for the given class which could be an 
-     * entity or a mapped superclass.
-     */
-    protected void processSqlResultSetMappings() {
-        // Process the XML sql result set mapping elements first.
-        processSqlResultSetMappings(m_helper.getNodes(m_node, XMLConstants.SQL_RESULT_SET_MAPPING));
-        
-        // Process the sql result set mapping query annotations second.
-        super.processSqlResultSetMappings();
-    }
-    
-    /**
-     * INTERNAL:
-     * Process sql-result-set-mappings and store them on the session.
-     */
-    protected void processSqlResultSetMappings(NodeList sqlResultSetNodes) {
-        if (sqlResultSetNodes != null) {
-        	int nodeCount = sqlResultSetNodes.getLength();
-        
-            for (int i = 0; i < nodeCount; i++) {
-                // Ask the common processor to process what we found.
-                processSqlResultSetMapping(new XMLSQLResultSetMapping(sqlResultSetNodes.item(i), m_helper));
-            }
-        }
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-     * Process table information for the given metadata descriptor.
-     */
-    protected void processTable() {
-	    Node tableNode = m_helper.getNode(m_node, XMLConstants.TABLE);
-            
-	    if (tableNode != null) {
-            if (m_descriptor.ignoreTables()) {
-                m_logger.logWarningMessage(m_logger.IGNORE_TABLE_ELEMENT, getJavaClass());
-            } else {
-                processTable(new XMLTable(tableNode, m_helper, m_logger));
-            }
-	    } else {
-            // Check for a table annotation. If no annotation is defined, the 
-            // table will default.
-            super.processTable();
-	    }
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-     * Process the table generator for the given class which could be an entity
-     * or a mapped superclass.
-     */
-    protected void processTableGenerator() {
-        // Process the xml defined table generators first.
-        processTableGenerator(m_helper.getNode(m_node, XMLConstants.TABLE_GENERATOR));
-        
-        // Process the annotation defined sequence generators second.
-        super.processTableGenerator();
-    }
-    
-    /**
-     * INTERNAL:
-     * Process a table-generator node into a common metadata table generator.
-     */
-    protected void processTableGenerator(Node node) {
-        if (node != null) {
-            // Ask the common processor to process what we found.
-            processTableGenerator(new XMLTableGenerator(node, this));
-        }
-    }
-}
-    
\ No newline at end of file
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLEmbeddedIdAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLEmbeddedIdAccessor.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLEmbeddedIdAccessor.java	(working copy)
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.accessors;
-
-import org.eclipse.persistence.internal.jpa.metadata.accessors.ClassAccessor;
-import org.eclipse.persistence.internal.jpa.metadata.accessors.EmbeddedIdAccessor;
-
-import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject;
-import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataClass;
-
-import org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLColumn;
-
-import org.eclipse.persistence.mappings.AggregateObjectMapping;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * An XML extended embedded id relationship accessor.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLEmbeddedIdAccessor extends EmbeddedIdAccessor {    
-    protected Node m_node;
-    protected XMLHelper m_helper;
-    
-    /**
-     * INTERNAL:
-     */
-    public XMLEmbeddedIdAccessor(MetadataAccessibleObject accessibleObject, Node node, XMLClassAccessor classAccessor) {
-        super(accessibleObject, classAccessor);
-        m_node = node;
-        m_helper = classAccessor.getHelper();
-    }
-    
-    /**
-     * INTERNAL: (Overrride from EmbeddedAccesor)
-     * 
-     * Currently if the embedded is specified in XML with no attribute
-     * overrides, we do NOT search the class for attribute overrides. It is
-     * assumed that they are to be defaulted.
-     */
-    protected void processAttributeOverrides(AggregateObjectMapping mapping) {
-        NodeList nodes = m_helper.getNodes(m_node, XMLConstants.ATTRIBUTE_OVERRIDE);
-        
-    	if (nodes != null) {
-    		for (int i = 0; i < nodes.getLength(); i++) {
-                processAttributeOverride(mapping, new XMLColumn(nodes.item(i), m_helper, getAnnotatedElement()));
-    		}
-    	}
-    }
-    
-    /**
-     * INTERNAL: (Overrride from EmbeddedAccesor)
-     * 
-     * Fast track processing a ClassAccessor for the given descriptor. 
-     * Inheritance root classes and embeddables may be fast tracked.
-     * 
-     * NOTE: The class passed in may not have any XML representation. If so,
-     * pass up to the parent.
-     */
-    protected ClassAccessor processAccessor(MetadataDescriptor descriptor) {
-        Node node = m_helper.locateEntityNode(descriptor.getJavaClass());
-        
-        if (node != null) {
-            XMLClassAccessor accessor = new XMLClassAccessor(new MetadataClass(descriptor.getJavaClass()), node, m_helper, m_processor, descriptor);
-            descriptor.setClassAccessor(accessor);
-            accessor.process();
-            accessor.setIsProcessed();
-            return accessor;
-        } else {
-            return super.processAccessor(descriptor);
-        }
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLOneToOneAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLOneToOneAccessor.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLOneToOneAccessor.java	(working copy)
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.accessors;
-
-import java.util.List;
-
-import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject;
-import org.eclipse.persistence.internal.jpa.metadata.accessors.OneToOneAccessor;
-
-import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataJoinColumns;
-import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataPrimaryKeyJoinColumns;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLJoinColumns;
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLPrimaryKeyJoinColumns;
-
-import org.eclipse.persistence.internal.helper.DatabaseTable;
-
-import org.w3c.dom.Node;
-
-/**
- * An extended one to one relationship accessor.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLOneToOneAccessor extends OneToOneAccessor {    
-    private Node m_node;
-    private XMLHelper m_helper;
-    
-    /**
-     * INTERNAL:
-     */
-    public XMLOneToOneAccessor(MetadataAccessibleObject accessibleObject, Node node, XMLClassAccessor classAccessor) {
-        super(accessibleObject, classAccessor);
-        
-        m_node = node;
-        m_helper = classAccessor.getHelper();
-    }
-    
-    /**
-     * INTERNAL: (Override from OneToOneAccessor)
-     */
-    public List<String> getCascadeTypes() {
-        return m_helper.getCascadeTypes(m_node);
-    }
-    
-    /**
-     * INTERNAL: (Override from OneToOneAccessor)
-     */
-    public String getFetchType() {
-        return m_helper.getFetchTypeDefaultEAGER(m_node);
-    }
-    
-    /**
-     * INTERNAL: (Override from RelationshipAccessor)
-     */    
-    protected MetadataJoinColumns getJoinColumns() {
-        if (m_helper.nodeHasJoinColumns(m_node)) {
-            return new XMLJoinColumns(m_node, m_helper);
-        } else {
-            return super.getJoinColumns();
-        }
-    }
-    
-    /**
-     * INTERNAL: (Override from OneToOneAccessor)
-     */
-    public String getMappedBy() {
-        return m_helper.getMappedBy(m_node);
-    }
-    
-    /**
-     * INTERNAL: (Override from MetadataAccessor)
-     */    
-    protected MetadataPrimaryKeyJoinColumns getPrimaryKeyJoinColumns(DatabaseTable sourceTable, DatabaseTable targetTable) {
-        if (m_helper.nodeHasPrimaryKeyJoinColumns(m_node)) {
-            return new XMLPrimaryKeyJoinColumns(m_node, m_helper, sourceTable, targetTable);
-        } else {
-            return super.getPrimaryKeyJoinColumns(sourceTable, targetTable);
-        }
-    }
-    
-    /**
-     * INTERNAL: (Override from OneToOneAccessor)
-     */
-    public Class getTargetEntity() {
-        return m_helper.getTargetEntity(m_node);
-    }
-    
-    /**
-     * INTERNAL: (Override from RelationshipAccessor)
-     * 
-     * Return true is this one-to-one has primary key join columns.
-     */    
-    public boolean hasPrimaryKeyJoinColumns() {
-        if (m_helper.nodeHasPrimaryKeyJoinColumns(m_node)) {
-            return true;
-        } else {
-            return super.hasPrimaryKeyJoinColumns();
-        }
-    }
-    
-    /**
-     * INTERNAL: (Override from OneToOneAccessor)
-     */
-    public boolean isOptional() {
-        return m_helper.isOptional(m_node);
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLTransientAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLTransientAccessor.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLTransientAccessor.java	(working copy)
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.accessors;
-
-import org.eclipse.persistence.internal.jpa.metadata.accessors.MetadataAccessor;
-import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject;
-
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLClassAccessor;
-
-import org.w3c.dom.Node;
-
-/**
- * An XML transient accessor ... which does nothing ... just a clever way to
- * make sure we don't process the accessible object for annotations.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLTransientAccessor extends MetadataAccessor {
-    /**
-     * INTERNAL:
-     */
-    public XMLTransientAccessor(MetadataAccessibleObject accessibleObject, Node node, XMLClassAccessor classAccessor) {
-        super(accessibleObject, classAccessor);
-    }
-    
-    /**
-     * INTERNAL:
-     * Does nothing ...
-     */
-     public void process() {}
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLEmbeddedAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLEmbeddedAccessor.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLEmbeddedAccessor.java	(working copy)
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.accessors;
-
-import org.eclipse.persistence.internal.jpa.metadata.accessors.ClassAccessor;
-import org.eclipse.persistence.internal.jpa.metadata.accessors.EmbeddedAccessor;
-
-import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject;
-import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataClass;
-
-import org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLColumn;
-
-import org.eclipse.persistence.mappings.AggregateObjectMapping;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * An XML extended embedded relationship accessor.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLEmbeddedAccessor extends EmbeddedAccessor {    
-    protected Node m_node;
-    protected XMLHelper m_helper;
-    
-    /**
-     * INTERNAL:
-     */
-    public XMLEmbeddedAccessor(MetadataAccessibleObject accessibleObject, Node node, XMLClassAccessor classAccessor) {
-        super(accessibleObject, classAccessor);
-        m_node = node;
-        m_helper = classAccessor.getHelper();
-    }
-    
-    /**
-     * INTERNAL: (Overrride from EmbeddedAccesor)
-     * 
-     * Currently if the embedded is specified in XML with no attribute
-     * overrides, we do NOT search the class for attribute overrides. It is
-     * assumed that they are to be defaulted.
-     */
-    protected void processAttributeOverrides(AggregateObjectMapping mapping) {
-        NodeList nodes = m_helper.getNodes(m_node, XMLConstants.ATTRIBUTE_OVERRIDE);
-        
-    	if (nodes != null) {
-    		for (int i = 0; i < nodes.getLength(); i++) {
-                processAttributeOverride(mapping, new XMLColumn(nodes.item(i), m_helper, getAnnotatedElement()));
-    		}
-    	}
-    }
-    
-    /**
-     * INTERNAL: (Overrride from EmbeddedAccesor)
-     * 
-     * Fast track processing a ClassAccessor for the given descriptor. 
-     * Inheritance root classes and embeddables may be fast tracked.
-     * 
-     * NOTE: The class passed in may not have any XML representation. If so,
-     * pass up to the parent.
-     */
-    protected ClassAccessor processAccessor(MetadataDescriptor descriptor) {
-        Node node = m_helper.locateEntityNode(descriptor.getJavaClass());
-        
-        if (node != null) {
-            XMLClassAccessor accessor = new XMLClassAccessor(new MetadataClass(descriptor.getJavaClass()), node, m_helper, m_processor, descriptor);
-            descriptor.setClassAccessor(accessor);
-            accessor.process();
-            accessor.setIsProcessed();
-            return accessor;
-        } else {
-            return super.processAccessor(descriptor);
-        }
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLManyToOneAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLManyToOneAccessor.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLManyToOneAccessor.java	(working copy)
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.accessors;
-
-import java.util.List;
-
-import org.eclipse.persistence.internal.jpa.metadata.accessors.ManyToOneAccessor;
-import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject;
-import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataJoinColumns;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.accessors.XMLClassAccessor;
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLJoinColumns;
-
-import org.w3c.dom.Node;
-
-/**
- * An xml extended many to one relationship accessor.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLManyToOneAccessor extends ManyToOneAccessor {    
-    protected Node m_node;
-    protected XMLHelper m_helper;
-    
-    /**
-     * INTERNAL:
-     */
-    public XMLManyToOneAccessor(MetadataAccessibleObject accessibleObject, Node node, XMLClassAccessor classAccessor) {
-        super(accessibleObject, classAccessor);
-        m_node = node;
-        m_helper = classAccessor.getHelper();
-    }
-    
-    /**
-     * INTERNAL: (Override from ManyToOneAccessor)
-     */
-    public List<String> getCascadeTypes() {
-        return m_helper.getCascadeTypes(m_node);
-    }
-    
-    /**
-     * INTERNAL: (Override from ManyToOneAccessor)
-     */
-    public String getFetchType() {
-        return m_helper.getFetchTypeDefaultEAGER(m_node);
-    }
-    
-    /**
-     * INTERNAL: (Override from RelationshipAccessor)
-     */    
-    protected MetadataJoinColumns getJoinColumns() {
-        if (m_helper.nodeHasJoinColumns(m_node)) {
-            return new XMLJoinColumns(m_node, m_helper);
-        } else {
-            return super.getJoinColumns();
-        }
-    }
-    
-    /**
-     * INTERNAL: (Override from ManyToOneAccessor)
-     */
-    public Class getTargetEntity() {
-        return m_helper.getTargetEntity(m_node);
-    }
-    
-    /**
-     * INTERNAL: (Override from ManyToOneAccessor)
-     */
-    public boolean isOptional() {
-        return m_helper.isOptional(m_node);
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLOneToManyAccessor.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLOneToManyAccessor.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/accessors/XMLOneToManyAccessor.java	(working copy)
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.accessors;
-
-import java.util.List;
-
-import org.eclipse.persistence.internal.jpa.metadata.accessors.OneToManyAccessor;
-import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject;
-
-import org.eclipse.persistence.internal.jpa.metadata.tables.MetadataJoinTable;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-
-import org.eclipse.persistence.internal.jpa.xml.tables.XMLJoinTable;
-
-import org.w3c.dom.Node;
-
-/**
- * A OneToMany relationship accessor.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLOneToManyAccessor extends OneToManyAccessor {
-    protected Node m_node;
-    protected XMLHelper m_helper;
-    
-    /**
-     * INTERNAL:
-     */
-    public XMLOneToManyAccessor(MetadataAccessibleObject accessibleObject, Node node, XMLClassAccessor classAccessor) {
-        super(accessibleObject, classAccessor);
-        m_node = node;
-        m_helper = classAccessor.getHelper();
-    }
-    
-    /**
-     * INTERNAL: (Override from OneToManyAccessor)
-     */
-    public List<String> getCascadeTypes() {
-        return m_helper.getCascadeTypes(m_node);
-    }
-    
-    /**
-     * INTERNAL: (Override from OneToManyAccessor)
-     */
-    public String getFetchType() {
-        return m_helper.getFetchTypeDefaultLAZY(m_node);
-    }
-    
-    /**
-     * INTERNAL: (Override from CollectionAccessor)
-     */
-    public MetadataJoinTable getJoinTable() {
-        Node node = m_helper.getNode(m_node, XMLConstants.JOIN_TABLE);
-        
-        if (node == null) {
-            return super.getJoinTable();
-        } else {
-            return new XMLJoinTable(node, m_helper, m_logger);
-        }
-    }
-    
-    /**
-     * INTERNAL: (Override from CollectionAccessor)
-     * 
-     * Checks for a map-key node and returns its value if there is one. 
-     * Otherwise, ask the parent to look for an annotation.
-     */
-    public String getMapKey() { 
-        Node mapKeyNode = m_helper.getNode(m_node, XMLConstants.MAPKEY);
-        String mapKeyValue = m_helper.getNodeValue(mapKeyNode, XMLConstants.ATT_NAME);
-        
-        if (mapKeyNode == null) {
-            return super.getMapKey();
-        } else {
-            return mapKeyValue;
-        }
-    }
-    
-    /**
-     * INTERNAL: (Override from OneToManyAccessor)
-     */
-    public String getMappedBy() {
-        return m_helper.getMappedBy(m_node);
-    }
-    
-    /**
-     * INTERNAL: (Override from CollectionAccessor)
-     * 
-     * If the order value is not specified, look for one on an annotation.
-     */
-    public String getOrderBy() {
-        if (hasOrderBy()) {
-            return m_helper.getNodeTextValue(m_node, XMLConstants.ORDER_BY);
-        } else {
-            return super.getOrderBy();
-        }
-    }
-    
-    /**
-     * INTERNAL: (Override from OneToManyAccessor)
-     */
-    public Class getTargetEntity() {
-        return m_helper.getTargetEntity(m_node);
-    }
-    
-    /**
-     * INTERNAL: (Override from CollectionAccessor)
-     * 
-	 * Checks for an order-by node. If one isn't found, as the parent to look
-     * for an annotation.
-     */
-	public boolean hasOrderBy() {
-		Node orderByNode = m_helper.getNode(m_node, XMLConstants.ORDER_BY);
-        
-        if (orderByNode == null) {
-            return super.hasOrderBy();
-        } else {
-            return true;
-        }
-	}
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/XMLValidator.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/XMLValidator.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/XMLValidator.java	(working copy)
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml;
-
-import java.lang.reflect.AnnotatedElement;
-
-import org.eclipse.persistence.exceptions.ValidationException;
-import org.eclipse.persistence.internal.jpa.metadata.MetadataValidator;
-
-/**
- * XML validator class.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLValidator extends MetadataValidator  { 
-    /**
-     * INTERNAL
-     */
-    public XMLValidator() {}
-    
-    /**
-     * INTERNAL
-     */
-    public void throwEmbeddedIdAndIdFound(Class entityClass, String attributeName, String idAttributeName) {
-        throw ValidationException.embeddedIdAndIdElementFound(entityClass, attributeName, idAttributeName);
-    }
-    
-    /**
-     * INTERNAL
-     */
-    public void throwErrorProcessingNamedQueryElement(String queryName, Exception exception) {
-        throw ValidationException.errorProcessingNamedQueryElement(queryName, exception);
-    }
-    
-    /**
-     * INTERNAL
-     */
-    public void throwExcessiveJoinColumnsSpecified(Class entityClass, Object element) {
-        throw ValidationException.excessiveJoinColumnElementsSpecified((String) element, entityClass);
-    }
-    
-    /**
-     * INTERNAL
-     */
-    public void throwExcessivePrimaryKeyJoinColumnsSpecified(Class entityClass, AnnotatedElement annotatedElement) {
-        throw ValidationException.excessivePrimaryKeyJoinColumnElementsSpecified(entityClass);
-    }
-    
-    /**
-     * INTERNAL
-     */
-    public void throwIncompleteJoinColumnsSpecified(Class entityClass, Object element) {
-        throw ValidationException.incompleteJoinColumnElementsSpecified(element, entityClass);
-    }
-    
-    /**
-     * INTERNAL
-     */
-    public void throwIncompletePrimaryKeyJoinColumnsSpecified(Class entityClass, AnnotatedElement annotatedElement) {
-        throw ValidationException.incompletePrimaryKeyJoinColumnElementsSpecified(entityClass);
-    }
-    
-    /**
-     * INTERNAL
-     */
-    public void throwMultipleEmbeddedIdsFound(Class entityClass, String attributeName, String embeddedIdAttributeName) {
-        throw ValidationException.multipleEmbeddedIdElementsFound(entityClass, attributeName, embeddedIdAttributeName);
-    }
-    
-    /**
-     * INTERNAL
-     */
-    public void throwNoMappedByAttributeFound(Class owningClass, String owningAttributeName, Class entityClass, String attributeName) {
-        // ignore, not applicable.
-    }
-    
-    /**
-     * INTERNAL
-     */
-    public void throwNoTemporalTypeSpecified(Class entityClass, String attributeName) {
-        // WIP - copied from AnnotationsValidator ... might need to have its own ...
-        throw ValidationException.noTemporalTypeSpecified(attributeName, entityClass);
-    }
-    
-    /**
-     * INTERNAL
-     */
-    public void throwPersistenceUnitMetadataConflict(String element) {
-        throw ValidationException.persistenceUnitMetadataConflict(element);
-    }
-    
-    /**
-     * INTERNAL
-     */
-    public void throwRelationshipHasColumnSpecified(Class entityClass, String attributeName) {
-        throw ValidationException.invalidColumnElementOnRelationship(entityClass, attributeName);
-    }
-    
-    /**
-     * INTERNAL:
-     */  
-    public void throwSequenceGeneratorUsingAReservedName(String document, String reservedName) {
-        throw ValidationException.sequenceGeneratorUsingAReservedName(reservedName, document);
-    }
-    
-    /**
-     * INTERNAL:
-     */  
-    public void throwTableGeneratorUsingAReservedName(String document, String reservedName) {
-        throw ValidationException.tableGeneratorUsingAReservedName(reservedName, document);
-    }
-    
-    /**
-     * INTERNAL
-     */
-    public void throwUniDirectionalOneToManyHasJoinColumnSpecified(String attributeName, Class entityClass) {
-        throw ValidationException.uniDirectionalOneToManyHasJoinColumnElements(attributeName, entityClass);
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/listeners/XMLEntityListener.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/listeners/XMLEntityListener.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/listeners/XMLEntityListener.java	(working copy)
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.listeners;
-
-import org.eclipse.persistence.internal.jpa.metadata.listeners.MetadataEntityListener;
-
-import java.lang.reflect.Method;
-
-/**
- * An XML specified entity listener.
- * 
- * WIP - similar code in here as XMLEntityClassListener
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLEntityListener extends MetadataEntityListener {
-    /**
-     * INTERNAL:
-     */
-	public XMLEntityListener(Class listenerClass, Class entityClass) {
-		super(listenerClass, entityClass);
-	}
-    
-    /**
-     * INTERNAL:
-     * Set it only if the same method wasn't already set from XML. If this
-     * is a different method and one has already been set from XML, then an 
-     * exception will be thrown from the set on the parent.
-     */
-    public void setPostBuildMethod(Method method) {
-        if (noCallbackMethodAlreadySetFor(POST_BUILD, method)) {
-            super.setPostBuildMethod(method);
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     * Set it only if the same method wasn't already set from XML. If this
-     * is a different method and one has already been set from XML, then an 
-     * exception will be thrown from the set on the parent.
-     */
-    public void setPostCloneMethod(Method method) {
-        if (noCallbackMethodAlreadySetFor(POST_CLONE, method)) {
-            super.setPostCloneMethod(method);
-        }
-    }
-
-    /**
-     * INTERNAL:
-     * Set it only if the same method wasn't already set from XML. If this
-     * is a different method and one has already been set from XML, then an 
-     * exception will be thrown from the set on the parent.
-     */
-    public void setPostDeleteMethod(Method method) {
-        if (noCallbackMethodAlreadySetFor(POST_DELETE, method)) {
-            super.setPostDeleteMethod(method);
-        }
-    }
-
-    /**
-     * INTERNAL:
-     * Set it only if the same method wasn't already set from XML. If this
-     * is a different method and one has already been set from XML, then an 
-     * exception will be thrown from the set on the parent.
-     */
-    public void setPostInsertMethod(Method method) {
-        if (noCallbackMethodAlreadySetFor(POST_INSERT, method)) {
-            super.setPostInsertMethod(method);
-        }
-    }
-
-    /**
-     * INTERNAL:
-     * Set it only if the same method wasn't already set from XML. If this
-     * is a different method and one has already been set from XML, then an 
-     * exception will be thrown from the set on the parent.
-     */
-    public void setPostRefreshMethod(Method method) {
-        if (noCallbackMethodAlreadySetFor(POST_REFRESH, method)) {
-            super.setPostRefreshMethod(method);
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     * Set it only if the same method wasn't already set from XML. If this
-     * is a different method and one has already been set from XML, then an 
-     * exception will be thrown from the set on the parent.
-     */
-    public void setPostUpdateMethod(Method method) {
-        if (noCallbackMethodAlreadySetFor(POST_UPDATE, method)) {
-            super.setPostUpdateMethod(method);
-        }
-    }
-
-    /**
-     * INTERNAL:
-     * Set it only if the same method wasn't already set from XML. If this
-     * is a different method and one has already been set from XML, then an 
-     * exception will be thrown from the set on the parent.
-     */
-    public void setPrePersistMethod(Method method) {
-        if (noCallbackMethodAlreadySetFor(PRE_PERSIST, method)) {
-            super.setPrePersistMethod(method);
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     * Set it only if the same method wasn't already set from XML. If this
-     * is a different method and one has already been set from XML, then an 
-     * exception will be thrown from the set on the parent.
-     */
-    public void setPreRemoveMethod(Method method) {
-        if (noCallbackMethodAlreadySetFor(PRE_REMOVE, method)) {
-            super.setPreRemoveMethod(method);
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     * Set it only if the same method wasn't already set from XML. If this
-     * is a different method and one has already been set from XML, then an 
-     * exception will be thrown from the set on the parent.
-     */
-    public void setPreUpdateWithChangesMethod(Method method) {
-        if (noCallbackMethodAlreadySetFor(PRE_UPDATE_WITH_CHANGES, method)) {
-            super.setPreUpdateWithChangesMethod(method);
-        }
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/listeners/XMLEntityClassListener.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/listeners/XMLEntityClassListener.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/listeners/XMLEntityClassListener.java	(working copy)
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.listeners;
-
-import java.lang.reflect.Method;
-
-import org.eclipse.persistence.internal.jpa.metadata.listeners.MetadataEntityClassListener;
-
-/**
- * An XML specified entity class event listener.
- * 
- * WIP - similar code in here as XMLEntityListener
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLEntityClassListener extends MetadataEntityClassListener {
-    /**
-     * INTERNAL:
-     */
-    public XMLEntityClassListener(Class entityClass) {
-        super(entityClass);
-    }
-
-    /**
-     * INTERNAL:
-     * Set it only if the same method wasn't already set from XML. If this
-     * is a different method and one has already been set from XML, then an 
-     * exception will be thrown from the set on the parent.
-     */
-    public void setPostBuildMethod(Method method) {
-        if (noCallbackMethodAlreadySetFor(POST_BUILD, method)) {
-            super.setPostBuildMethod(method);
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     * Set it only if the same method wasn't already set from XML. If this
-     * is a different method and one has already been set from XML, then an 
-     * exception will be thrown from the set on the parent.
-     */
-    public void setPostCloneMethod(Method method) {
-        if (noCallbackMethodAlreadySetFor(POST_CLONE, method)) {
-            super.setPostCloneMethod(method);
-        }
-    }
-
-    /**
-     * INTERNAL:
-     * Set it only if the same method wasn't already set from XML. If this
-     * is a different method and one has already been set from XML, then an 
-     * exception will be thrown from the set on the parent.
-     */
-    public void setPostDeleteMethod(Method method) {
-        if (noCallbackMethodAlreadySetFor(POST_DELETE, method)) {
-            super.setPostDeleteMethod(method);
-        }
-    }
-
-    /**
-     * INTERNAL:
-     * Set it only if the same method wasn't already set from XML. If this
-     * is a different method and one has already been set from XML, then an 
-     * exception will be thrown from the set on the parent.
-     */
-    public void setPostInsertMethod(Method method) {
-        if (noCallbackMethodAlreadySetFor(POST_INSERT, method)) {
-            super.setPostInsertMethod(method);
-        }
-    }
-
-    /**
-     * INTERNAL:
-     * Set it only if the same method wasn't already set from XML. If this
-     * is a different method and one has already been set from XML, then an 
-     * exception will be thrown from the set on the parent.
-     */
-    public void setPostRefreshMethod(Method method) {
-        if (noCallbackMethodAlreadySetFor(POST_REFRESH, method)) {
-            super.setPostRefreshMethod(method);
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     * Set it only if the same method wasn't already set from XML. If this
-     * is a different method and one has already been set from XML, then an 
-     * exception will be thrown from the set on the parent.
-     */
-    public void setPostUpdateMethod(Method method) {
-        if (noCallbackMethodAlreadySetFor(POST_UPDATE, method)) {
-            super.setPostUpdateMethod(method);
-        }
-    }
-
-    /**
-     * INTERNAL:
-     * Set it only if the same method wasn't already set from XML. If this
-     * is a different method and one has already been set from XML, then an 
-     * exception will be thrown from the set on the parent.
-     */
-    public void setPrePersistMethod(Method method) {
-        if (noCallbackMethodAlreadySetFor(PRE_PERSIST, method)) {
-            super.setPrePersistMethod(method);
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     * Set it only if the same method wasn't already set from XML. If this
-     * is a different method and one has already been set from XML, then an 
-     * exception will be thrown from the set on the parent.
-     */
-    public void setPreRemoveMethod(Method method) {
-        if (noCallbackMethodAlreadySetFor(PRE_REMOVE, method)) {
-            super.setPreRemoveMethod(method);
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     * Set it only if the same method wasn't already set from XML. If this
-     * is a different method and one has already been set from XML, then an 
-     * exception will be thrown from the set on the parent.
-     */
-    public void setPreUpdateWithChangesMethod(Method method) {
-        if (noCallbackMethodAlreadySetFor(PRE_UPDATE_WITH_CHANGES, method)) {
-            super.setPreUpdateWithChangesMethod(method);
-        }
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/tables/XMLSecondaryTable.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/tables/XMLSecondaryTable.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/tables/XMLSecondaryTable.java	(working copy)
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.tables;
-
-import org.w3c.dom.Node;
-
-import org.eclipse.persistence.internal.jpa.metadata.MetadataLogger;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLPrimaryKeyJoinColumns;
-
-import org.eclipse.persistence.internal.jpa.metadata.tables.MetadataSecondaryTable;
-
-import org.eclipse.persistence.internal.helper.DatabaseTable;
-
-/**
- * Object to hold onto an XML secondary table metadata in a TopLink database 
- * table.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLSecondaryTable extends MetadataSecondaryTable  {
-    private Node m_node;
-    private XMLHelper m_helper;
-    
-    /**
-     * INTERNAL:
-     */
-    public XMLSecondaryTable(Node node, XMLHelper helper, MetadataLogger logger) {
-        super(logger);
-        
-        m_node = node;
-        m_helper = helper;
-        m_name = m_helper.getNodeValue(node, XMLConstants.ATT_NAME);  
-        m_schema = m_helper.getNodeValue(node, XMLConstants.ATT_SCHEMA);
-        m_catalog = m_helper.getNodeValue(node, XMLConstants.ATT_CATALOG);
-        
-        processName();
-        XMLTableHelper.processUniqueConstraints(node, helper, m_databaseTable);
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-     */
-    protected void processPrimaryKeyJoinColumns(DatabaseTable sourceTable) {
-        m_primaryKeyJoinColumns = new XMLPrimaryKeyJoinColumns(m_node, m_helper, sourceTable, m_databaseTable);
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/tables/XMLJoinTable.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/tables/XMLJoinTable.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/tables/XMLJoinTable.java	(working copy)
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.tables;
-
-import org.eclipse.persistence.internal.jpa.metadata.MetadataLogger;
-
-import org.eclipse.persistence.internal.jpa.metadata.columns.MetadataJoinColumns;
-import org.eclipse.persistence.internal.jpa.metadata.tables.MetadataJoinTable;
-
-import org.eclipse.persistence.internal.jpa.xml.columns.XMLJoinColumns;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * Object to hold onto an XML join table metadata in a TopLink database table.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLJoinTable extends MetadataJoinTable {
-    protected XMLHelper m_helper;
-    protected NodeList m_joinColumns;
-    protected NodeList m_inverseJoinColumns;
-    
-    /**
-     * INTERNAL:
-     */
-    public XMLJoinTable(Node node, XMLHelper helper, MetadataLogger logger) {
-        super(logger);
-        
-        m_helper = helper;
-        
-        m_name = helper.getNodeValue(node, XMLConstants.ATT_NAME);
-        m_schema = helper.getNodeValue(node, XMLConstants.ATT_SCHEMA);
-        m_catalog = helper.getNodeValue(node, XMLConstants.ATT_CATALOG);
-        
-        m_joinColumns = helper.getNodes(node, XMLConstants.JOIN_COLUMN);
-        m_inverseJoinColumns =  helper.getNodes(node, XMLConstants.INVERSE_JOIN_COLUMN);
-            
-        processName();
-        XMLTableHelper.processUniqueConstraints(node, helper, m_databaseTable);
-    }
-
-    /**
-     * INTERNAL:
-     */
-    public boolean loadedFromXML() {
-        return true;
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-     */
-    protected MetadataJoinColumns processInverseJoinColumns() {
-        return new XMLJoinColumns(m_inverseJoinColumns, m_helper);
-    }
-    
-    /**
-     * INTERNAL: (OVERRIDE)
-     */
-    protected MetadataJoinColumns processJoinColumns() {
-        return new XMLJoinColumns(m_joinColumns, m_helper);
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/tables/XMLTable.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/tables/XMLTable.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/tables/XMLTable.java	(working copy)
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.tables;
-
-import org.eclipse.persistence.internal.jpa.metadata.MetadataLogger;
-import org.eclipse.persistence.internal.jpa.metadata.tables.MetadataTable;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
-import org.w3c.dom.Node;
-
-/**
- * Object to hold onto an XML table metadata in a TopLink database table.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLTable extends MetadataTable {
-    /**
-     * INTERNAL:
-     */
-    public XMLTable(Node node, XMLHelper helper, MetadataLogger logger) {
-        super(logger);
-        
-        m_name = helper.getNodeValue(node, XMLConstants.ATT_NAME);
-        m_schema = helper.getNodeValue(node, XMLConstants.ATT_SCHEMA);
-        m_catalog = helper.getNodeValue(node, XMLConstants.ATT_CATALOG);
-        
-        processName();
-        XMLTableHelper.processUniqueConstraints(node, helper, m_databaseTable);
-    }
-
-    /**
-     * INTERNAL:
-     */
-    public boolean loadedFromXML() {
-        return true;
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/tables/XMLTableHelper.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/tables/XMLTableHelper.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/tables/XMLTableHelper.java	(working copy)
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.tables;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-import org.eclipse.persistence.internal.helper.DatabaseTable;
-
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * Object to hold onto an XML table metadata in a TopLink database table.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLTableHelper {
-    /**
-     * INTERNAL:
-     * Process the unique-constraints for a given table node.
-     */
-    public static void processUniqueConstraints(Node node, XMLHelper helper, DatabaseTable table) {
-        NodeList uniqueConstraintNodes = helper.getNodes(node, XMLConstants.UNIQUE_CONSTRAINTS);
-        
-        if (uniqueConstraintNodes != null) {
-            for (int i = 0; i < uniqueConstraintNodes.getLength(); i++) {
-                NodeList columnNameNodes = helper.getTextColumnNodes(uniqueConstraintNodes.item(i));
-                
-                if (columnNameNodes != null) {
-                    List<String> columnNames = new ArrayList<String>(columnNameNodes.getLength());
-                    for (int k = 0; k < columnNameNodes.getLength(); k++) {
-                        String columnName = columnNameNodes.item(k).getNodeValue();
-                        
-                        if (columnName != null && !columnName.equals("")) {
-                            columnNames.add(columnName);
-                        }
-                    }
-                    if (columnNames.size() > 0) {
-                        table.addUniqueConstraints(columnNames.toArray(new String[0]));
-                    }
-                }
-            }
-        }
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/parser/XMLException.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/parser/XMLException.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/parser/XMLException.java	(working copy)
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.parser;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.persistence.internal.helper.Helper;
-
-public class XMLException extends RuntimeException {
-    private List m_nestedExceptions;
-
-    public XMLException() {
-        super();
-        m_nestedExceptions = new ArrayList(); 
-    }
-    
-    public void addNestedException(Exception nestedException) {
-        m_nestedExceptions.add(nestedException);
-    }
-    
-    public String getMessage() {
-        StringBuffer buffer = new StringBuffer();
-        Exception nestedException;
-        for (int x=0; x<m_nestedExceptions.size(); x++) {
-            nestedException = (Exception) m_nestedExceptions.get(x);
-            buffer.append(Helper.cr());
-            buffer.append('(');
-            buffer.append(x + 1);
-            buffer.append(". ");
-            buffer.append(nestedException.getMessage());
-            buffer.append(')');
-        }
-        return buffer.toString();
-    }
-    
-    public String toString() { return getMessage(); }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/parser/XMLNodeList.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/parser/XMLNodeList.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/parser/XMLNodeList.java	(working copy)
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.parser;
-
-import java.util.ArrayList;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * Implementation of the org.w3c.dom.NodeList interface
- */
-public class XMLNodeList implements NodeList {
-    private ArrayList nodes;
-
-    public XMLNodeList() {
-        nodes = new ArrayList();
-    }
-
-    public XMLNodeList(int size) {
-        nodes = new ArrayList(size);
-    }
-
-    public int getLength() {
-        return nodes.size();
-    }
-
-    public Node item(int i) {
-        return (Node)nodes.get(i);
-    }
-
-    public void add(Node node) {
-        nodes.add(node);
-    }
-
-    public void addAll(NodeList nodelist) {
-        int size = nodelist.getLength();
-        for (int i = 0; i < size; i++) {
-            nodes.add(nodelist.item(i));
-        }
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/parser/XPathEngine.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/parser/XPathEngine.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/parser/XPathEngine.java	(working copy)
@@ -1,249 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.parser;
-
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-
-/**
- * INTERNAL
- * Utility class for finding XML nodes using XPath expressions.
- */
-public class XPathEngine {
-    private static final String ATTRIBUTE = "@";
-    private static final String TEXT = "text()";
-    private static final String ALL_CHILDREN = "child::*";
-    private static final String NAMESPACE_URI = "http://java.sun.com/xml/ns/persistence/orm";;
-    private static XPathEngine instance = null;
-
-    private XPathEngine() {
-        super();
-    }
-
-    /**
-     * Return the <code>XPathEngine</code> singleton.
-     */
-    public static XPathEngine getInstance() {
-        if (instance == null) {
-            instance = new XPathEngine();
-        }
-        return instance;
-    }
-
-    /**
-     * Execute the XPath statement relative to the context node.
-     *
-     * @param contextNode the node relative to which the XPath statement will be executed
-     * @param xmlField the field containing the XPath statement to be executed
-     * @param namespaceResolver used to resolve namespace prefixes to the corresponding namespace URI
-     * @return the first node located matching the XPath statement
-     * @throws XMLPlatformException
-     */
-    public Node selectSingleNode(Node contextNode, String[] xPathFragments) {
-        if (contextNode == null) {
-            return null;
-        }
-
-        return selectSingleNode(contextNode, xPathFragments, 0);
-    }
-
-    private Node selectSingleNode(Node contextNode, String[] xPathFragments, int index) {
-        Node resultNode = getSingleNode(contextNode, xPathFragments[index]);
-        if ((resultNode == null) || (xPathFragments.length == (index + 1))) {
-            return resultNode;
-        }
-
-        return selectSingleNode(resultNode, xPathFragments, index + 1);
-    }
-
-    /**
-     * Execute the XPath statement relative to the context node.
-     *
-     * @param contextNode the node relative to which the XPath statement will be executed
-     * @param xmlField the field containing the XPath statement to be executed
-     * @param namespaceResolver used to resolve namespace prefixes to the corresponding namespace URI
-     * @return a list of nodes matching the XPath statement
-     * @throws XMLPlatformException
-     */
-    public NodeList selectNodes(Node contextNode, String[] xPathFragments) {
-        if (contextNode == null) {
-            return null;
-        }
-
-        return selectNodes(contextNode, xPathFragments, 0);
-    }
-
-    private NodeList selectNodes(Node contextNode, String[] xPathFragments, int index) {
-    
-        NodeList resultNodes = getNodes(contextNode, xPathFragments[index]);
-
-        if (xPathFragments.length != index + 1) {
-            Node resultNode;
-            XMLNodeList result = new XMLNodeList();
-            int numberOfResultNodes = resultNodes.getLength();
-            for (int x = 0; x < numberOfResultNodes; x++) {
-                resultNode = resultNodes.item(x);
-                result.addAll(selectNodes(resultNode, xPathFragments, index + 1));
-            }
-            return result;
-        }
-
-        return resultNodes;
-    }
-
-    private Node getSingleNode(Node contextNode, String xPathFragment) {
-        if (xPathFragment.startsWith(ATTRIBUTE)) {
-            return selectSingleAttribute(contextNode, xPathFragment);
-        } else if (TEXT.equals(xPathFragment)) {
-            return selectSingleText(contextNode);
-        }
-        return selectSingleElement(contextNode, xPathFragment);
-    }
-
-    private NodeList getNodes(Node contextNode, String xPathFragment) {
-    	if (xPathFragment.startsWith(ATTRIBUTE)) {
-            return selectAttributeNodes(contextNode, xPathFragment);
-        } else if (TEXT.equals(xPathFragment)) {
-            return selectTextNodes(contextNode);
-        } else if (xPathFragment.equals(ALL_CHILDREN)) {
-        	return selectChildElements(contextNode);
-        }
-        return selectElementNodes(contextNode, xPathFragment);
-
-    }
-
-    private Node selectSingleAttribute(Node contextNode, String xPathFragment) {
-        Element contextElement = (Element)contextNode;
-        return contextElement.getAttributeNode(xPathFragment.substring(1));
-    }
-
-    private NodeList selectAttributeNodes(Node contextNode, String xPathFragment) {
-        XMLNodeList xmlNodeList = new XMLNodeList();
-
-        Node child = selectSingleAttribute(contextNode, xPathFragment);
-        if (null != child) {
-            xmlNodeList.add(child);
-        }
-        return xmlNodeList;
-    }
-
-    private Node selectSingleElement(Node contextNode, String xPathFragment) {
-        Node child = contextNode.getFirstChild();
-        while (null != child) {
-            if ((child.getNodeType() == Node.ELEMENT_NODE) && sameName(child, xPathFragment) && sameNamespaceURI(child, NAMESPACE_URI)) {
-                return child;
-            }
-
-            child = child.getNextSibling();
-        }
-        return null;
-    }
-
-    private NodeList selectChildElements(Node contextNode) {
-        XMLNodeList xmlNodeList = new XMLNodeList();
-        Node child = contextNode.getFirstChild();
-
-        while (child != null) {
-            if (child.getNodeType() == Node.ELEMENT_NODE) {
-                xmlNodeList.add(child);
-            }
-            child = child.getNextSibling();
-        }
-
-        return xmlNodeList;
-    }
-
-    private NodeList selectElementNodes(Node contextNode, String xPathFragment) {
-        XMLNodeList xmlNodeList = new XMLNodeList();
-        Node child = contextNode.getFirstChild();
-
-        while (null != child) {
-            if ((child.getNodeType() == Node.ELEMENT_NODE) && sameName(child, xPathFragment) && sameNamespaceURI(child, NAMESPACE_URI)) {
-                xmlNodeList.add(child);
-            }
-
-            child = child.getNextSibling();
-        }
-
-        return xmlNodeList;
-    }
-
-    private Node selectSingleText(Node contextNode) {
-        NodeList childrenNodes = contextNode.getChildNodes();
-
-        if (childrenNodes.getLength() == 0) {
-            return null;
-        }
-
-        if (childrenNodes.getLength() == 1) {
-            Node child = childrenNodes.item(0);
-            if (child.getNodeType() == Node.TEXT_NODE) {
-                return child;
-            }
-            return null;
-        }
-
-        String returnVal = null;
-        for (int i = 0; i < childrenNodes.getLength(); i++) {
-            Node next = childrenNodes.item(i);
-            if (next.getNodeType() == Node.TEXT_NODE) {
-                String val = ((Text)next).getNodeValue();
-                if (val != null) {
-                    if (returnVal == null) {
-                        returnVal = new String();
-                    }
-                    returnVal += val;
-                }
-            }
-        }
-
-        //bug#4515249 a new text node was being created when null should have been returned
-        //case where contextNode had several children but no Text children
-        if (returnVal != null) {
-            return contextNode.getOwnerDocument().createTextNode(returnVal);
-        }
-        return null;
-    }
-
-    private NodeList selectTextNodes(Node contextNode) {
-        Node n = selectSingleText(contextNode);
-
-        XMLNodeList xmlNodeList = new XMLNodeList();
-        if (n != null) {
-            xmlNodeList.add(n);
-        }
-        return xmlNodeList;
-    }
-
-    private boolean sameNamespaceURI(Node node, String namespaceURI) {
-        // HANDLE THE NULL CASE
-        String nodeNamespaceURI = node.getNamespaceURI();
-        if (nodeNamespaceURI == namespaceURI) {
-            return true;
-        }
-
-        if ((nodeNamespaceURI == null) && namespaceURI.equals("")) {
-            return true;
-        }
-
-        if ((namespaceURI == null) && nodeNamespaceURI.equals("")) {
-            return true;
-        }
-
-        // HANDLE THE NON-NULL CASE
-        return (null != nodeNamespaceURI) && nodeNamespaceURI.equals(namespaceURI);
-    }
-
-    private boolean sameName(Node node, String name) {
-        return name.equals(node.getLocalName()) || name.equals(node.getNodeName());
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/parser/PersistenceContentHandler.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/parser/PersistenceContentHandler.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/parser/PersistenceContentHandler.java	(working copy)
@@ -1,170 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.parser;
-
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-
-import java.net.URL;
-import java.net.MalformedURLException;
-import java.util.Vector;
-import javax.persistence.spi.PersistenceUnitTransactionType;
-
-import org.eclipse.persistence.internal.jpa.deployment.SEPersistenceUnitInfo;
-import org.eclipse.persistence.internal.jpa.jdbc.base.DataSourceImpl;
-import org.eclipse.persistence.logging.AbstractSessionLog;
-
-public class PersistenceContentHandler implements ContentHandler {
-    private static final String NAMESPACE_URI = "http://java.sun.com/xml/ns/persistence";;
-    private static final String ELEMENT_PERSISTENCE_UNIT = "persistence-unit";
-    private static final String ELEMENT_PROVIDER = "provider";
-    private static final String ELEMENT_JTA_DATA_SOURCE = "jta-data-source";
-    private static final String ELEMENT_NON_JTA_DATA_SOURCE = "non-jta-data-source";
-    private static final String ELEMENT_MAPPING_FILE = "mapping-file";
-    private static final String ELEMENT_JAR_FILE = "jar-file";
-    private static final String ELEMENT_CLASS = "class";
-    private static final String ELEMENT_EXCLUDE_UNLISTED_CLASSES = "exclude-unlisted-classes";
-    private static final String ELEMENT_PROPERTY = "property";
-    private static final String ATTRIBUTE_NAME = "name";
-    private static final String ATTRIBUTE_VALUE = "value";  
-    private static final String ATTRIBUTE_TRANSACTION_TYPE = "transaction-type";  
-
-    private SEPersistenceUnitInfo persistenceUnitInfo;
-    private Vector<SEPersistenceUnitInfo> persistenceUnits;
-    private StringBuffer stringBuffer;
-    private boolean readCharacters = false;
-
-    public PersistenceContentHandler() {
-        super();
-        stringBuffer = new StringBuffer();
-        persistenceUnits = new Vector();
-    }
-
-   public Vector<SEPersistenceUnitInfo> getPersistenceUnits() {
-        return persistenceUnits;
-    }
-
-    public void setDocumentLocator(Locator locator) {
-    }
-
-    public void startDocument() throws SAXException {
-    }
-
-    public void endDocument() throws SAXException {
-    }
-
-    public void startPrefixMapping(String prefix, String uri) throws SAXException {
-    }
-
-    public void endPrefixMapping(String prefix) throws SAXException {
-    }
-
-    public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
-        if (NAMESPACE_URI.equals(namespaceURI)) {
-            if (ELEMENT_PERSISTENCE_UNIT.equals(localName)) {
-                persistenceUnitInfo = new SEPersistenceUnitInfo();
-                persistenceUnitInfo.setPersistenceUnitName(atts.getValue(ATTRIBUTE_NAME));
-                String transactionType = atts.getValue(ATTRIBUTE_TRANSACTION_TYPE);
-                if(transactionType != null) {
-                    persistenceUnitInfo.setTransactionType(PersistenceUnitTransactionType.valueOf(transactionType));
-                }
-                return;
-            } else if (ELEMENT_PROPERTY.equals(localName)) {
-                String name = atts.getValue(ATTRIBUTE_NAME);
-                String value = atts.getValue(ATTRIBUTE_VALUE);
-                persistenceUnitInfo.getProperties().setProperty(name, value);
-            } else if (ELEMENT_PROVIDER.equals(localName)) {
-                readCharacters = true;
-                return;
-            } else if (ELEMENT_JTA_DATA_SOURCE.equals(localName)) {
-                readCharacters = true;
-                return;
-            } else if (ELEMENT_NON_JTA_DATA_SOURCE.equals(localName)) {
-                readCharacters = true;
-                return;
-            } else if (ELEMENT_MAPPING_FILE.equals(localName)) {
-                readCharacters = true;
-                return;
-            } else if (ELEMENT_JAR_FILE.equals(localName)) {
-                readCharacters = true;
-                return;
-            } else if (ELEMENT_EXCLUDE_UNLISTED_CLASSES.equals(localName)) {
-                readCharacters = true;
-                return;
-            } else if (ELEMENT_CLASS.equals(localName)) {
-                readCharacters = true;
-                return;
-            }
-        }
-    }
-
-    public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
-        String string = stringBuffer.toString().trim();
-        stringBuffer.delete(0, stringBuffer.length());
-        readCharacters = false;
-
-        if (NAMESPACE_URI.equals(namespaceURI)) {
-            if (ELEMENT_PROVIDER.equals(localName)) {
-                persistenceUnitInfo.setPersistenceProviderClassName(string);
-                return;
-            } else if (ELEMENT_JTA_DATA_SOURCE.equals(localName)) {
-                persistenceUnitInfo.setJtaDataSource(
-                    // Create a dummy DataSource that will 
-                    // throw an exception on access
-                    new DataSourceImpl(string, null, null, null));
-                return;
-            } else if (ELEMENT_NON_JTA_DATA_SOURCE.equals(localName)) {
-                persistenceUnitInfo.setNonJtaDataSource(
-                    // Create a dummy DataSource that will 
-                    // throw an exception on access
-                    new DataSourceImpl(string, null, null, null));
-                return;
-            } else if (ELEMENT_MAPPING_FILE.equals(localName)) {
-                persistenceUnitInfo.getMappingFileNames().add(string);
-                return;
-            } else if (ELEMENT_JAR_FILE.equals(localName)) {
-                persistenceUnitInfo.getJarFiles().add(string);
-                return;
-            } else if (ELEMENT_CLASS.equals(localName)) {
-                persistenceUnitInfo.getManagedClassNames().add(string);
-                return;
-            } else if (ELEMENT_EXCLUDE_UNLISTED_CLASSES.equals(localName)) {
-                if (string.equals("true") || string.equals("1")){
-                    persistenceUnitInfo.setExcludeUnlistedClasses(true);
-                } else {
-                    persistenceUnitInfo.setExcludeUnlistedClasses(false);
-                }
-                return;
-            } else if (ELEMENT_PERSISTENCE_UNIT.equals(localName)) {
-                if (persistenceUnitInfo != null){
-                    persistenceUnits.add(persistenceUnitInfo);
-                    persistenceUnitInfo = null;
-                }
-            } 
-        }
-    }
-
-    public void characters(char[] ch, int start, int length) throws SAXException {
-        if (readCharacters) {
-            stringBuffer.append(ch, start, length);
-        }
-    }
-
-    public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
-    }
-
-    public void processingInstruction(String target, String data) throws SAXException {
-    }
-
-    public void skippedEntity(String name) throws SAXException {
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/parser/XMLExceptionHandler.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/parser/XMLExceptionHandler.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/parser/XMLExceptionHandler.java	(working copy)
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.parser;
-
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-public class XMLExceptionHandler implements ErrorHandler {
-    private XMLException m_xmlException;
-
-    public void warning(SAXParseException exception) throws SAXException {
-    	this.error(exception);
-    }
-
-    public void error(SAXParseException exception) throws SAXException {
-        if (m_xmlException == null) {
-        	m_xmlException = new XMLException();
-        }
-        m_xmlException.addNestedException(exception);
-    }
-
-    public void fatalError(SAXParseException exception) throws SAXException {
-        this.error(exception);
-    }
-    
-    public XMLException getXMLException() {
-    	return m_xmlException;
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/queries/XMLNamedNativeQuery.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/queries/XMLNamedNativeQuery.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/queries/XMLNamedNativeQuery.java	(working copy)
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.queries;
-
-import org.eclipse.persistence.internal.jpa.metadata.MetadataLogger;
-
-import org.eclipse.persistence.internal.jpa.metadata.queries.MetadataQueryHint;
-import org.eclipse.persistence.internal.jpa.metadata.queries.MetadataNamedNativeQuery;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * Object to hold onto an XML named native query metadata.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLNamedNativeQuery extends MetadataNamedNativeQuery {
-    /**
-     * INTERNAL:
-     */
-    public XMLNamedNativeQuery(Node node, XMLHelper helper) {
-        // Set the location where we found this query.
-        setLocation(helper.getDocumentName());
-        
-        // Process the name.
-        setName(helper.getNodeValue(node, XMLConstants.ATT_NAME));
-        
-        // Process the query string.
-        setEJBQLString(helper.getNodeTextValue(node, XMLConstants.QUERY));
-        
-        // Process the query hints.
-        NodeList hints = helper.getNodes(node, XMLConstants.QUERY_HINT);
-        if (hints != null) {
-            for (int i = 0; i < hints.getLength(); i++) {
-                Node hintNode = hints.item(i);
-                String name = helper.getNodeValue(hintNode, XMLConstants.ATT_NAME);
-                String value = helper.getNodeValue(hintNode, XMLConstants.ATT_VALUE);
-                addHint(new MetadataQueryHint(name, value));
-            }
-        }
-            
-        // Process the result class.
-        setResultClass(helper.getNodeValue(node, XMLConstants.ATT_RESULT_CLASS, void.class));
-        
-        // Process the result set mapping.
-        setResultSetMapping(helper.getNodeValue(node, XMLConstants.ATT_RESULT_SET_MAPPING, ""));
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getIgnoreLogMessageContext() {
-        return MetadataLogger.IGNORE_NAMED_NATIVE_QUERY_ELEMENT;
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public boolean loadedFromAnnotations() {
-        return false;
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public boolean loadedFromXML() {
-        return true;
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/queries/XMLFieldResult.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/queries/XMLFieldResult.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/queries/XMLFieldResult.java	(working copy)
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.queries;
-
-import org.w3c.dom.Node;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
-import org.eclipse.persistence.internal.jpa.metadata.queries.MetadataFieldResult;
-
-/**
- * Object to hold onto an xml field result metadata.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLFieldResult extends MetadataFieldResult {
-    protected Node m_node;
-    protected XMLHelper m_helper;
-
-    /**
-     * INTERNAL:
-     */
-    public XMLFieldResult(Node node, XMLHelper helper) {
-        m_node = node;
-        m_helper = helper;
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getColumn() {
-        return m_helper.getNodeValue(m_node, XMLConstants.ATT_COLUMN);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getName() {
-        return m_helper.getNodeValue(m_node, XMLConstants.ATT_NAME);
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/queries/XMLSQLResultSetMapping.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/queries/XMLSQLResultSetMapping.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/queries/XMLSQLResultSetMapping.java	(working copy)
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.queries;
-
-import java.util.List;
-import java.util.ArrayList;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
-import org.eclipse.persistence.internal.jpa.metadata.queries.MetadataEntityResult;
-import org.eclipse.persistence.internal.jpa.metadata.queries.MetadataSQLResultSetMapping;
-
-/**
- * Object to hold onto an XML sql result set mapping metadata.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLSQLResultSetMapping extends MetadataSQLResultSetMapping {
-    protected Node m_node;
-    protected XMLHelper m_helper;
-
-    /**
-     * INTERNAL:
-     */
-    public XMLSQLResultSetMapping(Node node, XMLHelper helper) {
-        m_node = node;
-        m_helper = helper;
-    }
-    
-   /**
-     * INTERNAL:
-     */
-    public List<MetadataEntityResult> getEntityResults() {
-        if (m_entityResults == null) {
-            m_entityResults = new ArrayList<MetadataEntityResult>();
-            NodeList entityResultNodes = m_helper.getNodes(m_node, XMLConstants.ENTITY_RESULT);
-            
-            if (entityResultNodes != null) {
-                for (int i = 0; i < entityResultNodes.getLength(); i++) {
-                    m_entityResults.add(new XMLEntityResult(entityResultNodes.item(i), m_helper));
-                }
-            }
-        }
-        
-        return m_entityResults;
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public List<String> getColumnResults() {
-        if (m_columnResults == null) {
-            m_columnResults = new ArrayList<String>();    
-            NodeList columnResultList = m_helper.getNodes(m_node, XMLConstants.COLUMN_RESULT);
-            
-            if (columnResultList != null) {
-                for (int i = 0; i < columnResultList.getLength(); i++) {
-                    m_columnResults.add(m_helper.getNodeValue(columnResultList.item(i), XMLConstants.ATT_NAME));
-                }
-            }
-        }
-        
-        return m_columnResults;
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getName() {
-        return m_helper.getNodeValue(m_node, XMLConstants.ATT_NAME);
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/queries/XMLNamedQuery.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/queries/XMLNamedQuery.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/queries/XMLNamedQuery.java	(working copy)
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.queries;
-
-import org.eclipse.persistence.internal.jpa.metadata.MetadataLogger;
-
-import org.eclipse.persistence.internal.jpa.metadata.queries.MetadataQueryHint;
-import org.eclipse.persistence.internal.jpa.metadata.queries.MetadataNamedQuery;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * Object to hold onto a named query metadata that came from XML.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLNamedQuery extends MetadataNamedQuery {
-    /**
-     * INTERNAL:
-     */
-    public XMLNamedQuery(Node node, XMLHelper helper) {
-        // Set the location where we found this query.
-        setLocation(helper.getDocumentName());
-        
-        // Process the name.
-        setName(helper.getNodeValue(node, XMLConstants.ATT_NAME));
-        
-        // Process the query string.
-        setEJBQLString(helper.getNodeTextValue(node, XMLConstants.QUERY));
-            
-        // Process the query hints.
-        NodeList hints = helper.getNodes(node, XMLConstants.QUERY_HINT);
-        if (hints != null) {
-            for (int i = 0; i < hints.getLength(); i++) {
-                Node hintNode = hints.item(i);
-                String name = helper.getNodeValue(hintNode, XMLConstants.ATT_NAME);
-                String value = helper.getNodeValue(hintNode, XMLConstants.ATT_VALUE);
-                addHint(new MetadataQueryHint(name, value));
-            }
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getIgnoreLogMessageContext() {
-        return MetadataLogger.IGNORE_NAMED_QUERY_ELEMENT;
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public boolean loadedFromAnnotations() {
-        return false;
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public boolean loadedFromXML() {
-        return true;
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/queries/XMLEntityResult.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/queries/XMLEntityResult.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/queries/XMLEntityResult.java	(working copy)
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml.queries;
-
-import java.util.List;
-import java.util.ArrayList;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import org.eclipse.persistence.internal.jpa.xml.XMLHelper;
-import org.eclipse.persistence.internal.jpa.xml.XMLConstants;
-
-import org.eclipse.persistence.internal.jpa.metadata.queries.MetadataFieldResult;
-import org.eclipse.persistence.internal.jpa.metadata.queries.MetadataEntityResult;
-
-/**
- * Object to hold onto an xml entity result metadata.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLEntityResult extends MetadataEntityResult {
-    protected Node m_node;
-    protected XMLHelper m_helper;
-
-    /**
-     * INTERNAL:
-     */
-    public XMLEntityResult(Node node, XMLHelper helper) {
-        m_node = node;
-        m_helper = helper;
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public String getDiscriminatorColumn() {
-        return m_helper.getNodeValue(m_node, XMLConstants.ATT_DISCRIMINATOR_COLUMN, "");
-    }
-    
-    /**
-     * INTERNAL:
-     * Note this attribute is required but we send in the default void.class
-     * object to ensure we go through the correct class loading.
-     */
-    public Class getEntityClass() {
-        return m_helper.getNodeValue(m_node, XMLConstants.ATT_ENTITY_CLASS, void.class);
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public List<MetadataFieldResult> getFieldResults() {
-        if (m_fieldResults == null) {
-            m_fieldResults = new ArrayList<MetadataFieldResult>();
-            NodeList fieldResultNodes = m_helper.getNodes(m_node, XMLConstants.FIELD_RESULT);
-            
-            if (fieldResultNodes != null) {
-                for (int i = 0; i < fieldResultNodes.getLength(); i++) {
-                    m_fieldResults.add(new XMLFieldResult(fieldResultNodes.item(i), m_helper));
-                }
-            }
-        }
-        
-        return m_fieldResults;
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/XMLConstants.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/XMLConstants.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/xml/XMLConstants.java	(working copy)
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.xml;
-
-/**
- * INTERNAL:
- * 
- * Static values for XML processing.
- * 
- * @author Guy Pelletier
- * @since TopLink EJB 3.0 Reference Implementation
- */
-public class XMLConstants {
-    // miscellaneous values
-    public static final String FIELD = "FIELD";
-    public static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";;
-    public static final String ORM_SCHEMA_NAME = "xsd/orm_1_0.xsd";
-    public static final String PERSISTENCE_SCHEMA_NAME = "xsd/persistence_1_0.xsd";
-    public static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";;
-    public static final String VALIDATING = "http://xml.org/sax/features/validation";;
-    public static final String XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";;
-    public static final String ALL = "ALL";
-    public static final String ALL_CHILDREN = "child::*";
-    public static final String CALLBACK_METHODS = "CALLBACK_METHODS";
-    public static final String DEFAULT_TEMPORAL = "TIMESTAMP";
-    public static final String ENTITIES_TO_DEFAULT = "entitiesToDefault";
-    public static final String ENTITIES_TO_PROCESS = "entitiesToProcess";
-    public static final String ORDINAL = "ORDINAL";
-    public static final String PROPERTY = "PROPERTY";
-    public static final String SET = "set";
-    public static final String SINGLE_TABLE = "SINGLE_TABLE";
-    public static final String TABLE_PER_CLASS = "TABLE_PER_CLASS";
-    public static final String TEXT = "text()";
-    
-    // attribute values
-    public static final String ATT_ACCESS = "@access";
-    public static final String ATT_ALLOCATION_SIZE = "@allocation-size";
-    public static final String ATT_CATALOG = "@catalog";
-    public static final String ATT_CLASS = "@class";
-    public static final String ATT_COLUMN = "@column";
-    public static final String ATT_COLUMN_DEFINITION = "@column-definition";
-    public static final String ATT_DISCRIMINATOR_COLUMN = "@discriminator-column";
-    public static final String ATT_DISCRIMINATOR_TYPE = "@discriminator-type";
-    public static final String ATT_ENTITY_CLASS = "@entity-class";
-    public static final String ATT_FETCH = "@fetch";
-    public static final String ATT_GENERATOR = "@generator";
-    public static final String ATT_INITIAL_VALUE = "@initial-value";
-    public static final String ATT_INSERTABLE = "@insertable";
-    public static final String ATT_LENGTH = "@length";
-    public static final String ATT_MAPPED_BY = "@mapped-by";
-    public static final String ATT_METADATA_COMPLETE = "@metadata-complete";
-    public static final String ATT_METHOD_NAME = "@method-name";
-    public static final String ATT_NAME = "@name";
-    public static final String ATT_NULLABLE = "@nullable";
-    public static final String ATT_OPTIONAL = "@optional";
-    public static final String ATT_PK_COLUMN_NAME = "@pk-column-name";
-    public static final String ATT_PK_COLUMN_VALUE = "@pk-column-value";
-    public static final String ATT_PRECISION = "@precision";
-    public static final String ATT_REFERENCED_COLUMN_NAME = "@referenced-column-name";
-    public static final String ATT_RESULT_CLASS = "@result-class";
-    public static final String ATT_RESULT_SET_MAPPING = "@result-set-mapping";
-    public static final String ATT_SCALE = "@scale";
-    public static final String ATT_SCHEMA = "@schema";
-    public static final String ATT_SECONDARY_TABLE = "@secondary-table";
-    public static final String ATT_TABLE = "@table";
-    public static final String ATT_SEQUENCE_NAME = "@sequence-name";
-    public static final String ATT_STRATEGY = "@strategy";
-    public static final String ATT_TARGET_ENTITY = "@target-entity";
-    public static final String ATT_UNIQUE = "@unique";
-    public static final String ATT_UPDATABLE = "@updatable";
-    public static final String ATT_VALUE = "@value";
-    public static final String ATT_VALUE_COLUMN_NAME = "@value-column-name";
-    public static final String ATT_VERSION = "@version";
-
-    // element/complex-type values
-    public static final String ACCESS = "access";
-    public static final String ATTRIBUTES = "attributes";
-    public static final String ASSOCIATION_OVERRIDE = "association-override";
-    public static final String ATTRIBUTE_OVERRIDE = "attribute-override";
-    public static final String BASIC = "basic";
-    public static final String CASCADE = "cascade";
-    public static final String CASCADE_PERSIST = "cascade-persist";
-    public static final String CATALOG = "catalog";
-    public static final String COLUMN = "column";
-    public static final String COLUMN_NAME = "column-name";
-    public static final String COLUMN_RESULT = "column-result";
-    public static final String DEFAULT_ENTITY_LISTENERS = "default-entity-listeners";
-    public static final String DESCRIPTION = "description";
-    public static final String DISCRIMINATOR_COLUMN = "discriminator-column";
-    public static final String DISCRIMINATOR_VALUE = "discriminator-value";
-    public static final String EMBEDDED = "embedded";
-    public static final String EMBEDDED_ID = "embedded-id";
-    public static final String EMBEDDABLE = "embeddable";
-    public static final String EMBEDDABLE_ATTRIBUTE = "embeddable-attribute";
-    public static final String ENTITY = "entity";
-    public static final String ENTITY_LISTENER = "entity-listener";
-    public static final String ENTITY_LISTENERS = "entity-listeners";
-    public static final String ENTITY_MAPPINGS = "entity-mappings";
-    public static final String ENTITY_RESULT = "entity-result";
-    public static final String ENUMERATED = "enumerated";
-    public static final String EXCLUDE_DEFAULT_LISTENERS = "exclude-default-listeners";
-    public static final String EXCLUDE_SUPERCLASS_LISTENERS = "exclude-superclass-listeners";
-    public static final String FIELD_RESULT = "field-result";
-    public static final String FLUSH_MODE = "flush-mode";
-    public static final String GENERATED_VALUE = "generated-value";
-    public static final String ID = "id";
-    public static final String ID_CLASS = "id-class";
-    public static final String INHERITANCE = "inheritance";
-    public static final String INVERSE_JOIN_COLUMN = "inverse-join-column";
-    public static final String JOIN_COLUMN = "join-column";
-    public static final String JOIN_TABLE = "join-table";
-    public static final String LOB = "lob";
-    public static final String MANY_TO_MANY = "many-to-many";
-    public static final String MANY_TO_ONE = "many-to-one";
-    public static final String MAPKEY = "map-key";
-    public static final String MAPPED_SUPERCLASS = "mapped-superclass";
-    public static final String METADATA_COMPLETE = "xml-mapping-metadata-complete";
-    public static final String NAMED_NATIVE_QUERY = "named-native-query";
-    public static final String NAMED_QUERY = "named-query";
-    public static final String ONE_TO_MANY = "one-to-many";
-    public static final String ONE_TO_ONE = "one-to-one";
-    public static final String ORDER_BY = "order-by";
-    public static final String PACKAGE = "package";
-    public static final String PK_JOIN_COLUMN = "primary-key-join-column";
-    public static final String POST_LOAD = "post-load";
-    public static final String POST_PERSIST = "post-persist";
-    public static final String POST_REMOVE = "post-remove";
-    public static final String POST_UPDATE = "post-update";
-    public static final String PRE_PERSIST = "pre-persist";
-    public static final String PRE_REMOVE = "pre-remove";
-    public static final String PRE_UPDATE = "pre-update";
-    public static final String PU_DEFAULTS = "persistence-unit-defaults";
-    public static final String PU_METADATA = "persistence-unit-metadata";
-    public static final String QUERY = "query";
-    public static final String QUERY_HINT = "hint";
-    public static final String SCHEMA = "schema";
-    public static final String SECONDARY_TABLE = "secondary-table";
-    public static final String SEQUENCE_GENERATOR = "sequence-generator";
-    public static final String SQL_RESULT_SET_MAPPING = "sql-result-set-mapping";
-    public static final String TABLE = "table";
-    public static final String TABLE_GENERATOR = "table-generator";
-    public static final String TEMPORAL = "temporal";
-    public static final String TRANSIENT = "transient";
-    public static final String UNIQUE_CONSTRAINTS = "unique-constraint";
-    public static final String VERSION = "version";
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/DataSourceConfig.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/DataSourceConfig.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/DataSourceConfig.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.base;
+package org.eclipse.persistence.internal.jpa;
 
 import java.io.StringWriter;
 
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/EntityManagerFactoryImpl.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/EntityManagerFactoryImpl.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/EntityManagerFactoryImpl.java	(working copy)
@@ -17,6 +17,8 @@
 
 import org.eclipse.persistence.sessions.server.ServerSession;
 import org.eclipse.persistence.sessions.JNDIConnector;
+import org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl;
+import org.eclipse.persistence.internal.jpa.EntityManagerImpl;
 import org.eclipse.persistence.internal.localization.ExceptionLocalization;
 
 /**
@@ -28,35 +30,69 @@
 * The primary consumer of these EntityManager is assumed to be either the Container.    There is
 * one EntityManagerFactory per deployment.
 * @see javax.persistence.EntityManager
-* @see org.eclipse.persistence.jpa.EntityManager
+* @see org.eclipse.persistence.jpa.JpaEntityManager
 * @see org.eclipse.persistence.jpa.EntityManagerFactory
+* 
+* @author  gyorke
+* @since   TopLink 10.1.3 EJB 3.0 Preview
 */
+public class EntityManagerFactoryImpl implements EntityManagerFactory {
+	// This stores a reference to the ServerSession for this deployment.
+    protected ServerSession serverSession;
+    protected EntityManagerSetupImpl setupImpl;
+    protected boolean isOpen = true;
+    protected Map properties;
 
-/*  @author  gyorke
- *  @since   TopLink 10.1.3 EJB 3.0 Preview
- */
-public class EntityManagerFactoryImpl 
-    extends org.eclipse.persistence.internal.jpa.base.EntityManagerFactoryImpl
-    implements EntityManagerFactory 
-{
-
     /**
      * Will return an instance of the Factory.  Should only be called by TopLink.
      * @param serverSession
      */
-    public EntityManagerFactoryImpl(ServerSession serverSession) {
-        super(serverSession);
+    public EntityManagerFactoryImpl(ServerSession serverSession){
+        this.serverSession = serverSession;
     }
-
+    
+    public EntityManagerFactoryImpl(EntityManagerSetupImpl setupImpl, Map properties){
+        this.setupImpl = setupImpl;
+        this.properties = properties;
+    }
+    
     /**
-     * Will return an instance of the Factory.  Should only be called by TopLink.
-     * @param serverSession
+     * INTERNAL:
+     * Returns the ServerSession that the Factory will be using and initializes it if it is not available.
+     * This method makes use of the partially constructed session stored in our setupImpl and
+     * completes its construction
      */
-    public EntityManagerFactoryImpl(EntityManagerSetupImpl setupImpl, Map properties) {
-        super(setupImpl, properties);
+    public synchronized ServerSession getServerSession(){
+        if (serverSession == null){   
+            ClassLoader realLoader = setupImpl.getPersistenceUnitInfo().getClassLoader();
+            // the call top setupImpl.deploy() finishes the session creation
+            serverSession = setupImpl.deploy(realLoader, properties);
+        }
+        return this.serverSession;
     }
+    
+    /**
+	 * Closes this factory, releasing any resources that might be held by this factory. After
+	 * invoking this method, all methods on the instance will throw an
+	 * {@link IllegalStateException}, except for {@link #isOpen}, which will return
+	 * <code>false</code>.
+	 */
+	public synchronized void close(){
+        verifyOpen();
+        isOpen = false;
+        setupImpl.undeploy();
+    }
 
-    /**
+
+	/**
+	 * Indicates whether or not this factory is open. Returns <code>true</code> until a call
+	 * to {@link #close} is made.
+	 */
+	public boolean isOpen(){
+       return isOpen;
+    }
+
+	/**
      * PUBLIC:
      * Returns an EntityManager for this deployment
      */
@@ -71,9 +107,47 @@
     public EntityManager createEntityManager(Map properties) {
         return (EntityManager) createEntityManagerImpl(properties, false);
     }
+    
+    protected EntityManagerImpl createEntityManagerImpl(boolean extended) {
+        return createEntityManagerImpl(null, extended);
+    }
 
+    protected synchronized EntityManagerImpl createEntityManagerImpl(Map properties, boolean extended) {
+        verifyOpen();
+
+        if (!getServerSession().isConnected()) {
+            getServerSession().login();
+        }
+        return createEntityManagerImplInternal(properties, extended);
+    }
+
     //TODO change the way create works to deal with how the specification works with persistence contexts
-    protected org.eclipse.persistence.internal.jpa.base.EntityManagerImpl createEntityManagerImplInternal(Map properties, boolean extended) {
+    protected org.eclipse.persistence.internal.jpa.EntityManagerImpl createEntityManagerImplInternal(Map properties, boolean extended) {
         return new EntityManagerImpl(this, properties, false, extended);
     }
+    
+    protected void verifyOpen(){
+        if (!isOpen){
+            throw new IllegalStateException(ExceptionLocalization.buildMessage("operation_on_closed_entity_manager_factory"));
+        }
+    }    
+
+    protected void finalize() throws Throwable {
+        if(isOpen()) {
+            close();
+        }
+    }
+    
+    /**
+     * The method return user defined property passed in from EntityManagerFactory. 
+     * @param name
+     * @return
+     */
+    public Object getProperty(String name) {
+        Object propertyValue=null;
+        if(name==null){
+            return null;
+        }
+        return this.getServerSession().getProperty(name);
+    }
 }
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/CMP3Policy.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/CMP3Policy.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/CMP3Policy.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.base;
+package org.eclipse.persistence.internal.jpa;
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/jdbc/ConnectionProxyHandler.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/jdbc/ConnectionProxyHandler.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/jdbc/ConnectionProxyHandler.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.jdbc.base;
+package org.eclipse.persistence.internal.jpa.jdbc;
 
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/jdbc/base/ConnectionProxyHandler.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/jdbc/base/ConnectionProxyHandler.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/jdbc/base/ConnectionProxyHandler.java	(working copy)
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.jdbc.base;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.sql.Connection;
-
-/**
- * A simple invocation handler for the proxied connection.
- *
- * Connections are proxied only when they are obtained from a
- * transactional data source and within the context of a JTA
- * transaction.
- */
-public class ConnectionProxyHandler implements InvocationHandler {
-    Connection connection;
-
-    /************************/
-    /***** Internal API *****/
-    /************************/
-    private void debug(String s) {
-        System.out.println(s);
-    }
-
-    /*
-     * Use this constructor
-     */
-    public ConnectionProxyHandler(Connection connection) {
-        this.connection = connection;
-    }
-
-    /*********************************/
-    /***** InvocationHandler API *****/
-    /*********************************/
-
-    /*
-     * Gateway for method interception
-     */
-    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
-        String methodName = method.getName();
-        debug("PROXY method: " + methodName);
-        // No-op if any of the following calls
-        if (methodName.equals("close") || methodName.equals("commit") || methodName.equals("rollback")) {
-            return null;
-        }
-
-        // Normal case is just to forward on to the real connection
-        return method.invoke(connection, args);
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/jdbc/base/DataSourceImpl.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/jdbc/base/DataSourceImpl.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/jdbc/base/DataSourceImpl.java	(working copy)
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.jdbc.base;
-
-import java.io.PrintWriter;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.DriverManager;
-import javax.sql.DataSource;
-import org.eclipse.persistence.internal.jpa.transaction.base.TransactionManagerImpl;
-
-/**
- * A stubbed out impl of DataSource that can be used for testing.
- *
- * Does not support multiple threads or multiple usernames/passwords.
- */
-public class DataSourceImpl implements DataSource {
-    String dsName;
-    String url;
-    String userName;
-    String password;
-
-    // When a transaction is active we need to get the right connection.
-    // This should not be set (will be null) when the data source is non-JTA (non-tx).
-    TransactionManagerImpl tm;
-
-    /************************/
-    /***** Internal API *****/
-    /************************/
-    private void debug(String s) {
-        System.out.println(s);
-    }
-
-    /*
-     * Use this constructor to create a new datasource
-     */
-    public DataSourceImpl(String dsName, String url, String userName, String password) {
-        this.dsName = dsName;
-        this.url = url;
-        this.userName = userName;
-        this.password = password;
-    }
-
-    /*
-     * Return the unique name of this data source
-     */
-    public String getName() {
-        return this.dsName;
-    }
-
-    /*
-     * This must be called right after initialization if data source is transactional.
-     * Must not get set if data source is a non-transactional data source.
-     */
-    public void setTransactionManager(TransactionManagerImpl tm) {
-        this.tm = tm;
-    }
-
-    /*
-     * Get all connections from the DriverManager.
-     */
-    public Connection internalGetConnection(String userName, String password) throws SQLException {
-        return DriverManager.getConnection(this.url, userName, password);
-    }
-
-    /*
-     * Get all connections from the DriverManager.
-     */
-    public Connection internalGetConnection() throws SQLException {
-        return internalGetConnection(this.userName, this.password);
-    }
-
-    /*
-     * Return true if this data source is transactional, false if not
-     */
-    public boolean isTransactional() {
-        return tm != null;
-    }
-
-    /************************************************************/
-    /***** Supported DataSource  API *****/
-    /************************************************************/
-
-    /*
-     * Forward to the other method.
-     */
-    public Connection getConnection() throws SQLException {
-        return getConnection(this.userName, this.password);
-    }
-
-    /*
-     * Go to the Transaction Manager to get a connection
-     */
-    public Connection getConnection(String userName, String password) throws SQLException {
-        if (isTransactional() && tm.isTransactionActive()) {
-            // This will actually eventually call back into this class, but allows
-            // the connection to be cached in the transaction first
-            return tm.getConnection(this, userName, password);
-        } else {//{
-            debug("Ds - Allocating new non-tx connection");
-        }
-        return internalGetConnection(userName, password);
-    }
-
-    /*
-     * Forward to the DriverManager.
-     */
-    public PrintWriter getLogWriter() throws SQLException {
-        return DriverManager.getLogWriter();
-    }
-
-    /*
-     * Forward to the DriverManager.
-     */
-    public void setLogWriter(PrintWriter out) throws SQLException {
-        DriverManager.setLogWriter(out);
-    }
-
-    /*
-     * Forward to the DriverManager.
-     */
-    public int getLoginTimeout() throws SQLException {
-        return DriverManager.getLoginTimeout();
-    }
-
-    /*
-     * Forward to the DriverManager.
-     */
-    public void setLoginTimeout(int seconds) throws SQLException {
-        DriverManager.setLoginTimeout(seconds);
-    }
-
-    /*
-     * JDBC 4.0
-     */
-    public <T> T unwrap(Class<T> iface) throws SQLException {
-        throw new SQLException();
-    }
-
-    /*
-     * JDBC 4.0
-     */
-    public boolean isWrapperFor(Class<?> iface) throws SQLException {
-        return false;
-    }
-
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/jdbc/DataSourceImpl.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/jdbc/DataSourceImpl.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/jdbc/DataSourceImpl.java	(working copy)
@@ -7,14 +7,14 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.jdbc.base;
+package org.eclipse.persistence.internal.jpa.jdbc;
 
 import java.io.PrintWriter;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.DriverManager;
 import javax.sql.DataSource;
-import org.eclipse.persistence.internal.jpa.transaction.base.TransactionManagerImpl;
+import org.eclipse.persistence.internal.jpa.transaction.TransactionManagerImpl;
 
 /**
  * A stubbed out impl of DataSource that can be used for testing.
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/ExceptionFactory.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/ExceptionFactory.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/ExceptionFactory.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.base;
+package org.eclipse.persistence.internal.jpa;
 
 import java.io.StringWriter;
 import java.io.PrintWriter;
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/EntityManagerImpl.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/EntityManagerImpl.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/EntityManagerImpl.java	(working copy)
@@ -12,17 +12,34 @@
 import java.util.Map;
 import java.util.Vector;
 
+import javax.persistence.EntityExistsException;
+import javax.persistence.EntityNotFoundException;
 import javax.persistence.FlushModeType;
+import javax.persistence.LockModeType;
+import javax.persistence.PersistenceException;
 import javax.persistence.Query;
 
+import org.eclipse.persistence.exceptions.EclipseLinkException;
 import org.eclipse.persistence.exceptions.JPQLException;
+import org.eclipse.persistence.exceptions.ValidationException;
 import org.eclipse.persistence.expressions.Expression;
 import org.eclipse.persistence.queries.DatabaseQuery;
+import org.eclipse.persistence.queries.ObjectBuildingQuery;
+import org.eclipse.persistence.queries.ReadAllQuery;
+import org.eclipse.persistence.queries.ReadObjectQuery;
 import org.eclipse.persistence.queries.ResultSetMappingQuery;
+import org.eclipse.persistence.sessions.Session;
+import org.eclipse.persistence.sessions.UnitOfWork;
+import org.eclipse.persistence.sessions.factories.SessionManager;
 import org.eclipse.persistence.sessions.server.ServerSession;
+import org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy;
+import org.eclipse.persistence.internal.helper.IdentityHashtable;
 import org.eclipse.persistence.internal.jpa.transaction.*;
 import org.eclipse.persistence.internal.localization.ExceptionLocalization;
+import org.eclipse.persistence.internal.sessions.MergeManager;
+import org.eclipse.persistence.jpa.config.PersistenceUnitProperties;
 import org.eclipse.persistence.descriptors.ClassDescriptor;
+import org.eclipse.persistence.descriptors.VersionLockingPolicy;
 
 /**
 * <p>
@@ -34,19 +51,33 @@
 * <b>Responsibilities</b>:It is responcible for tracking transaction state and the
 * objects within that transaction.
 * @see javax.persistence.EntityManager
-* @see org.eclipse.persistence.jpa.EntityManager
+* @see org.eclipse.persistence.jpa.JpaEntityManager
+* 
+* @author gyorke
+* @since TopLink 10.1.3 EJB 3.0 Preview
 */
+public class EntityManagerImpl implements org.eclipse.persistence.jpa.JpaEntityManager {
+	
+    protected TransactionWrapperImpl transaction = null;
+    protected boolean isOpen = true;
+    protected RepeatableWriteUnitOfWork extendedPersistenceContext;
+    // This attribute references the ServerSession that this deployement is using.
+    // This is a simple mechanism to reduce the number of SessionManager accesses.
+    protected ServerSession serverSession;
+    // References the factory that has created this entity manager
+    // to make sure that the factory is not garbage collected
+    protected EntityManagerFactoryImpl factory;
 
-/*  @author  gyorke  
- *  @since   TopLink 10.1.3 EJB 3.0 Preview
- */
+    // We have not removed these flags because we may want to use them at a later date to provide transactional EntityManagers in JAVA SE
+    protected boolean extended;
+    protected boolean propagatePersistenceContext;
+        
+    //gf3334, force early transaction flag.
+    protected boolean beginEarlyTransaction = false;
+    
+    //gf3334, this is place holder for properties that passed from createEntityManager 
+    protected Map properties;
 
-
-public class EntityManagerImpl 
-    extends org.eclipse.persistence.internal.jpa.base.EntityManagerImpl
-    implements org.eclipse.persistence.jpa.EntityManager 
-{
-   
     private FlushModeType flushMode;
     
     /**
@@ -55,8 +86,8 @@
      * This constructor can potentially throw TopLink exceptions regarding the existence, or
      * errors with the specified session.
      */
-    public EntityManagerImpl(String sessionName, boolean propagatePersistenceContext, boolean extended){
-        super(sessionName, propagatePersistenceContext, extended);
+    public EntityManagerImpl(String sessionName, boolean propagatePersistenceContext, boolean extended) {
+        this((ServerSession)SessionManager.getManager().getSession(sessionName), null, propagatePersistenceContext, extended);
         flushMode = FlushModeType.AUTO;
     }
 
@@ -67,29 +98,103 @@
     public EntityManagerImpl(ServerSession serverSession, boolean propagatePersistenceContext, boolean extended){
         this(serverSession, null, propagatePersistenceContext, extended);
     }
-
+    
     /**
      * Constructor called from the EntityManagerFactory to create an EntityManager
      * @param serverSession the serverSession assigned to this deployment.
      * Note: The properties argument is provided to allow properties to be passed into this EntityManager,
      * but there are currently no such properties implemented
      */
-    public EntityManagerImpl(ServerSession serverSession, Map properties, boolean propagePersistenceContext, boolean extended){
-        super(serverSession, properties, propagePersistenceContext, extended);
+    public EntityManagerImpl(ServerSession serverSession, Map properties, boolean propagatePersistenceContext, boolean extended) {
+        this.serverSession = serverSession;
+        detectTransactionWrapper();
+        this.extended = true;
+        this.propagatePersistenceContext = false;
+        this.properties=properties;
+        setBeginEarlyTransaction();
         flushMode = FlushModeType.AUTO;
     }
-	
+    
     /**
      * Constructor called from the EntityManagerFactory to create an EntityManager
      * @param factory the EntityMangerFactoryImpl that created this entity manager.
      * Note: The properties argument is provided to allow properties to be passed into this EntityManager,
      * but there are currently no such properties implemented
      */
-    public EntityManagerImpl(EntityManagerFactoryImpl factory, Map properties, boolean propagePersistenceContext, boolean extended){
-        super(factory, properties, propagePersistenceContext, extended);
+    public EntityManagerImpl(EntityManagerFactoryImpl factory, Map properties, boolean propagatePersistenceContext, boolean extended) {
+        this.factory = factory;
+        this.serverSession = factory.getServerSession();
+        detectTransactionWrapper();
+        this.extended = true;
+        this.propagatePersistenceContext = false;
+        this.properties=properties;
+        setBeginEarlyTransaction();
         flushMode = FlushModeType.AUTO;
     }
 	
+    /**
+     * Clear the persistence context, causing all managed
+     * entities to become detached. Changes made to entities that
+     * have not been flushed to the database will not be
+     * persisted.
+     */
+    public void clear() {
+        try {
+            verifyOpen();
+            if (this.isExtended()) {
+                if (this.extendedPersistenceContext != null) {
+                    if (checkForTransaction(false) == null) {
+                        // clear all change sets and cache
+                        this.extendedPersistenceContext.clearForClose(true);
+                        this.extendedPersistenceContext = null;
+                    } else {
+                        // clear all change sets created after the last flush and cache
+                        this.extendedPersistenceContext.clear(true);
+                    }
+                }
+            } else {
+                transaction.clear();
+            }
+        } catch (RuntimeException e) {
+            this.setRollbackOnly();
+            throw e;
+        }
+    }
+
+    /**
+     * Internal method called by EntityTransactionImpl class in case of transaction rollback.
+     * The caller is responsible for releasing extendedPersistenceContext and it's parent.
+     */
+    public void removeExtendedPersistenceContext() {
+        this.extendedPersistenceContext = null;
+    }
+
+    /**
+     * If in a transaction this method will check for existence and register the object if
+     * it is new.  The instance of the entity provided will become managed.
+     * @param entity
+     * @throws IllegalArgumentException if the given Object is not an entity.
+     */
+    public void persist(Object entity) {
+        try {
+            verifyOpen();
+            if (entity == null) {
+                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[] { entity }));
+            }
+            try {
+                getActivePersistenceContext(checkForTransaction(!isExtended())).registerNewObjectForPersist(entity, new IdentityHashtable());
+            } catch (RuntimeException e) {
+                if (ValidationException.class.isAssignableFrom(e.getClass())) {
+                    throw new EntityExistsException(e.getLocalizedMessage(), e);
+                }
+                throw e;
+            }
+        } catch (RuntimeException e) {
+            this.setRollbackOnly();
+            throw e;
+        }
+    }
+
 	/**
 	 * Merge the state of the given entity into the
 	 * current persistence context, using the unqualified
@@ -107,6 +212,51 @@
         }
 	}
 	
+    /**
+     * Merge the state of the given entity into the
+     * current persistence context, using the unqualified
+     * class name as the entity name.
+     * @param entity
+     * @return the instance that the state was merged to
+     * @throws IllegalArgumentException if given Object is not an entity or is a removed entity
+     */
+    protected Object mergeInternal(Object entity) {
+        if (entity == null) {
+            throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[] { entity }));
+        }
+        //gf830 - merging a removed entity should throw exception
+        if (getActivePersistenceContext(checkForTransaction(!isExtended())).getDeletedObjects().containsKey(entity)) {
+            throw new IllegalArgumentException(ExceptionLocalization.buildMessage("cannot_merge_removed_entity", new Object[] { entity }));
+        }
+        try {
+            return getActivePersistenceContext(checkForTransaction(!isExtended())).mergeCloneWithReferences(entity, MergeManager.CASCADE_BY_MAPPING, true);
+        } catch (org.eclipse.persistence.exceptions.OptimisticLockException ole) {
+            throw new javax.persistence.OptimisticLockException(ole);
+        }
+    }
+
+    /**
+     * Remove the instance.
+     * @param entity
+     * @throws IllegalArgumentException if Object passed in is not an entity
+     */
+    public void remove(Object entity) {
+        try {
+            verifyOpen();
+            if (entity == null) { //gf732 - check for null
+                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[] { entity }));
+            }
+            try {
+                getActivePersistenceContext(checkForTransaction(!isExtended())).performRemove(entity, new IdentityHashtable());
+            } catch (RuntimeException e) {
+                throw e;
+            }
+        } catch (RuntimeException e) {
+            this.setRollbackOnly();
+            throw e;
+        }
+    }
+
 	/**
 	* Find by primary key.
 	* @param entityClass
@@ -128,68 +278,178 @@
 	}
 	
     /**
-     * Get an instance, whose state may be lazily fetched.
-     * If the requested instance does not exist in the database,
-     * throws EntityNotFoundException when the instance state is first accessed. 
-     * (The container is permitted to throw EntityNotFoundException when get is called.)
-     * The application should not expect that the instance state will
-     * be available upon detachment, unless it was accessed by the
-     * application while the entity manager was open.
+     * Find by primary key.
+     * @param entityName
+     * @param primaryKey
+     * @return the found entity instance
+     * @throws IllegalArgumentException if the first argument does not indicate an entity or if the
+     * second argument is not a valid type for that entity's primaryKey
+     */
+    public Object find(String entityName, Object primaryKey) {
+        try {
+            verifyOpen();
+            Session session = getActiveSession();
+            ClassDescriptor descriptor = session.getDescriptorForAlias(entityName);
+            if (descriptor == null || descriptor.isAggregateDescriptor() || descriptor.isAggregateCollectionDescriptor()) {
+                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("unknown_entitybean_name", new Object[] { entityName }));
+            }
+            if (primaryKey == null) { //gf721 - check for null PK
+                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("null_pk"));
+            }
+            if (((CMP3Policy)descriptor.getCMPPolicy()).getPKClass() != null && !((CMP3Policy)descriptor.getCMPPolicy()).getPKClass().isAssignableFrom(primaryKey.getClass())) {
+                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("invalid_pk_class", new Object[] { ((CMP3Policy)descriptor.getCMPPolicy()).getPKClass(), primaryKey.getClass() }));
+            }
+            return findInternal(descriptor, session, primaryKey);
+        } catch (RuntimeException e) {
+            this.setRollbackOnly();
+            throw e;
+        }
+    }
+
+    /**
+     * Find by primary key.
      * @param entityClass
      * @param primaryKey
-     * @return the found entity instance
+     * @return the found entity instance or null
+     * if the entity does not exist
      * @throws IllegalArgumentException if the first argument does
-     * not denote an entity type or the second
-     * argument is not a valid type for that
+     * not denote an entity type or the second argument is not a valid type for that
      * entity's primary key
-     * @throws EntityNotFoundException if the entity state
-     * cannot be accessed
      */
-    public <T> T getReference(Class<T> entityClass, Object primaryKey) {
+    protected Object findInternal(Class entityClass, Object primaryKey) {
+        Session session = getActiveSession();
+        ClassDescriptor descriptor = session.getDescriptor(entityClass);
+        if (descriptor == null || descriptor.isAggregateDescriptor() || descriptor.isAggregateCollectionDescriptor()) {
+            throw new IllegalArgumentException(ExceptionLocalization.buildMessage("unknown_bean_class", new Object[] { entityClass }));
+        }
+        if (primaryKey == null) { //gf721 - check for null PK
+            throw new IllegalArgumentException(ExceptionLocalization.buildMessage("null_pk"));
+        }
+        if (((CMP3Policy)descriptor.getCMPPolicy()).getPKClass() != null && !((CMP3Policy)descriptor.getCMPPolicy()).getPKClass().isAssignableFrom(primaryKey.getClass())) {
+            throw new IllegalArgumentException(ExceptionLocalization.buildMessage("invalid_pk_class", new Object[] { ((CMP3Policy)descriptor.getCMPPolicy()).getPKClass(), primaryKey.getClass() }));
+        }
+        return findInternal(descriptor, session, primaryKey);
+    }
+
+    /**
+     * Find by primary key.
+     * @param descriptor
+     * @param session
+     * @param primaryKey
+     * @return the found entity instance or null
+     * if the entity does not exist
+     * @throws IllegalArgumentException if the first argument does
+     * not denote an entity type or the second argument is not a valid type for that
+     * entity's primary key
+     */
+    protected static Object findInternal(ClassDescriptor descriptor, Session session, Object primaryKey) {
+        Vector pk;
+        if (primaryKey instanceof Vector) {
+            pk = (Vector)primaryKey;
+        } else {
+            pk = ((CMP3Policy)descriptor.getCMPPolicy()).createPkVectorFromKey(primaryKey, (org.eclipse.persistence.internal.sessions.AbstractSession)session);
+        }
+        ReadObjectQuery query = new ReadObjectQuery(descriptor.getJavaClass());
+        query.setSelectionKey(pk);
+        query.conformResultsInUnitOfWork();
+        return session.executeQuery(query);
+    }
+
+    /**
+     * Synchronize the persistence context with the
+     * underlying database.
+     */
+    public void flush() {
         try {
             verifyOpen();
-            Object returnValue = findInternal(entityClass, primaryKey);
-            if (returnValue ==null){
-                Object[] o = {primaryKey};
-                String message = ExceptionLocalization.buildMessage("no_entities_retrieved_for_get_reference", o);
-                throw new javax.persistence.EntityNotFoundException(message);
+
+            try {
+                getActivePersistenceContext(checkForTransaction(true)).writeChanges();
+            } catch (RuntimeException e) {
+                if (EclipseLinkException.class.isAssignableFrom(e.getClass())) {
+                    throw new PersistenceException(e);
+                }
+                throw e;
             }
-            return (T)returnValue;
         } catch (RuntimeException e) {
-            this.transaction.setRollbackOnlyInternal();
+            this.setRollbackOnly();
             throw e;
         }
     }
-    
-	/**
-	* Create an instance of Query for executing an
-	* EJBQL query.
-	* @param ejbqlString an EJBQL query string
-	* @return the new query instance
-	*/
-	public Query createQuery(String ejbqlString){
-    
+
+    protected void detectTransactionWrapper() {
+        if (this.serverSession.hasExternalTransactionController()) {
+            setJTATransactionWrapper();
+        } else {
+            setEntityTransactionWrapper();
+        }
+    }
+
+    /**
+     * Refresh the state of the instance from the database.
+     * @param entity instance registered in the current persistence context.
+     */
+    public void refresh(Object entity) {
         try {
             verifyOpen();
-            
-            EJBQueryImpl ejbqImpl;
-            
-            try
-            {
-                ejbqImpl = new EJBQueryImpl(ejbqlString, this);    
+            UnitOfWork uow = getActivePersistenceContext(checkForTransaction(!isExtended()));
+            if (!contains(entity, uow)) {
+                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("cant_refresh_not_managed_object", new Object[] { entity }));
             }
-            
-            catch(JPQLException ex)
-            {            
-                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("wrap_ejbql_exception"), ex);            
+            ReadObjectQuery query = new ReadObjectQuery();
+            query.setSelectionObject(entity);
+            query.refreshIdentityMapResult();
+            query.cascadeByMapping();
+            query.setLockMode(ObjectBuildingQuery.NO_LOCK);
+            query.setIsExecutionClone(true);
+            Object refreshedEntity = null;
+            refreshedEntity = uow.executeQuery(query);
+            if (refreshedEntity == null) {
+                // bug5955326, ReadObjectQuery will now ensure the object is invalidated if refresh returns null.
+                throw new EntityNotFoundException(ExceptionLocalization.buildMessage("entity_no_longer_exists_in_db", new Object[] { entity }));
             }
-            
-            return ejbqImpl;
+        } catch (RuntimeException exception) {
+            setRollbackOnly();
+            throw exception;
+        }
+    }
+
+    /**
+     * Check if the instance belongs to the current persistence
+     * context.
+     * @param entity
+     * @return
+     * @throws IllegalArgumentException if given Object is not an entity
+     */
+    public boolean contains(Object entity) {
+        try {
+            verifyOpen();
+            if (entity == null) {
+                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[] { entity }));
+            }
+            ClassDescriptor descriptor = (ClassDescriptor)getServerSession().getDescriptors().get(entity.getClass());
+            if (descriptor == null || descriptor.isAggregateDescriptor() || descriptor.isAggregateCollectionDescriptor()) {
+                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[] { entity }));
+            }
+
+            if ((!hasActivePersistenceContext())) {
+                return false;
+            }
+
+            return contains(entity, getActivePersistenceContext(checkForTransaction(false)));
         } catch (RuntimeException e) {
-            this.transaction.setRollbackOnlyInternal();
+            this.setRollbackOnly();
             throw e;
         }
-	}
+    }
+
+    /**
+     * Check if the instance belongs to the current persistence
+     * context.
+     */
+    protected boolean contains(Object entity, UnitOfWork uow) {
+        return ((org.eclipse.persistence.internal.sessions.UnitOfWorkImpl)uow).isObjectRegistered(entity) && !((org.eclipse.persistence.internal.sessions.UnitOfWorkImpl)uow).isObjectDeleted(entity);
+    }
     
     public javax.persistence.Query createDescriptorNamedQuery(String queryName, Class descriptorClass){
         return createDescriptorNamedQuery(queryName, descriptorClass, null);
@@ -212,12 +472,12 @@
         }
     }
     
-	/**
-	* Create an instance of Query for executing a
-	* named query (in EJBQL or native SQL).
-	* @param name the name of a query defined in metadata
-	* @return the new query instance
-	*/
+    /**
+	 * Create an instance of Query for executing a
+	 * named query (in EJBQL or native SQL).
+	 * @param name the name of a query defined in metadata
+	 * @return the new query instance
+	 */
 	public Query createNamedQuery(String name){
         try {
             verifyOpen();
@@ -227,12 +487,13 @@
             throw e;
         }
 	}
+	
 	/**
-	* Create an instance of Query for executing
-	* a native SQL query.
-	* @param sqlString a native SQL query string
-	* @return the new query instance
-	*/
+	 * Create an instance of Query for executing
+	 * a native SQL query.
+	 * @param sqlString a native SQL query string
+	 * @return the new query instance
+	 */
 	public Query createNativeQuery(String sqlString){
         try {
             verifyOpen();
@@ -281,10 +542,39 @@
     }
 
     /**
-    * Get the flush mode that applies to all objects contained
-    * in the persistence context.
-    * @return flushMode
-    */
+     * This method returns the current session to the requestor.  The current session
+     * will be a the active UnitOfWork within a transaction and will be a 'scrap'
+     * UnitOfWork outside of a transaction.  The caller is conserned about the results
+     * then the getSession() or getUnitOfWork() API should be called.
+     */
+    public Session getActiveSession() {
+        Object txn = checkForTransaction(false);
+        if (txn == null && !this.isExtended()) {
+            return this.serverSession.acquireNonSynchronizedUnitOfWork();
+        } else {
+            return getActivePersistenceContext(txn);
+        }
+    }
+    /**
+     * Return the underlying provider object for the EntityManager,
+     * if available. The result of this method is implementation
+     * specific.
+     */
+    public Object getDelegate() {
+        try {
+            verifyOpen();
+            return this;
+        } catch (RuntimeException e) {
+            this.setRollbackOnly();
+            throw e;
+        }
+    }
+    
+    /**
+     * Get the flush mode that applies to all objects contained
+     * in the persistence context.
+     * @return flushMode
+     */
     public FlushModeType getFlushMode() {
         try {
             verifyOpen();
@@ -296,20 +586,111 @@
     }
 
     /**
-    * Set the flush mode that applies to all objects contained
-    * in the persistence context.
-    * @param flushMode
-    */
-    public void setFlushMode(FlushModeType flushMode) {
+     * This method will return the active UnitOfWork 
+     */
+    public UnitOfWork getUnitOfWork() {
+        return getActivePersistenceContext(checkForTransaction(false));
+    }
+    
+    /**
+     * This method will return a Session outside of a transaction and null within a transaction.
+     */
+    public Session getSession() {
+        if (checkForTransaction(false) == null) {
+            return this.serverSession.acquireNonSynchronizedUnitOfWork();
+        }
+        return null;
+    }
+    
+	/**
+     * Returns the resource-level transaction object.
+     * The EntityTransaction instance may be used serially to
+     * begin and commit multiple transactions.
+     * @return EntityTransaction instance
+     * @throws IllegalStateException if invoked on a JTA
+     * EntityManager.
+     */
+    public javax.persistence.EntityTransaction getTransaction(){
         try {
+            return ((TransactionWrapper)transaction).getTransaction();
+        } catch (RuntimeException e) {
+            this.transaction.setRollbackOnlyInternal();
+            throw e;
+        }
+    }
+    
+    /**
+     * The method search for user defined property passed in from EntityManager, if it is not found then
+     * search for it from EntityManagerFactory properties.
+     * @param name
+     * @return
+     */
+    public Object getProperty(String name) {
+        Object propertyValue=null;
+        if(name==null){
+            return null;
+        }
+        if(this.properties!=null){
+            propertyValue=this.properties.get(name);
+        }
+        if(propertyValue==null){
+            propertyValue=this.factory.getServerSession().getProperty(name);
+        }
+        return propertyValue;
+    }
+    
+    /**
+     * Get an instance, whose state may be lazily fetched.
+     * If the requested instance does not exist in the database,
+     * throws EntityNotFoundException when the instance state is first accessed. 
+     * (The container is permitted to throw EntityNotFoundException when get is called.)
+     * The application should not expect that the instance state will
+     * be available upon detachment, unless it was accessed by the
+     * application while the entity manager was open.
+     * @param entityClass
+     * @param primaryKey
+     * @return the found entity instance
+     * @throws IllegalArgumentException if the first argument does
+     * not denote an entity type or the second
+     * argument is not a valid type for that
+     * entity's primary key
+     * @throws EntityNotFoundException if the entity state
+     * cannot be accessed
+     */
+    public <T> T getReference(Class<T> entityClass, Object primaryKey) {
+        try {
             verifyOpen();
-            this.flushMode = flushMode;
+            Object returnValue = findInternal(entityClass, primaryKey);
+            if (returnValue ==null){
+                Object[] o = {primaryKey};
+                String message = ExceptionLocalization.buildMessage("no_entities_retrieved_for_get_reference", o);
+                throw new javax.persistence.EntityNotFoundException(message);
+            }
+            return (T)returnValue;
         } catch (RuntimeException e) {
             this.transaction.setRollbackOnlyInternal();
             throw e;
         }
     }
+
+    /**
+     * Return the underlying server session
+     */
+    public ServerSession getServerSession() {
+        return this.serverSession;
+    }
+    /**
+     * This method is used to create a query using SQL.  The class, must be the expected
+     * return type.
+     */
+    protected DatabaseQuery createNativeQueryInternal(String sqlString, Class resultType) {
+        ReadAllQuery query = new ReadAllQuery(resultType);
+        query.setSQLString(sqlString);
+        query.setIsUserDefined(true);
+        return query;
+    }
     
+    
     /**
      * This method is used to create a query using a Toplink Expression and the return type.
      */
@@ -323,37 +704,252 @@
             throw e;
         }
     }  
+    
+    /**
+	 * Create an instance of Query for executing an
+	 * EJBQL query.
+	 * @param ejbqlString an EJBQL query string
+	 * @return the new query instance
+	 */
+    public Query createQuery(String ejbqlString){
+    
+        try {
+            verifyOpen();
+            
+            EJBQueryImpl ejbqImpl;
+            
+            try
+            {
+                ejbqImpl = new EJBQueryImpl(ejbqlString, this);    
+            }
+            
+            catch(JPQLException ex)
+            {            
+                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("wrap_ejbql_exception"), ex);            
+            }
+            
+            return ejbqImpl;
+        } catch (RuntimeException e) {
+            this.transaction.setRollbackOnlyInternal();
+            throw e;
+        }
+    }
+	
+    /**
+     * This method is used to create a query using a Toplink Expression and the return type.
+     */
+    protected DatabaseQuery createQueryInternal(Expression expression, Class resultType) {
+        ReadAllQuery query = new ReadAllQuery(resultType);
+        query.setSelectionCriteria(expression);
+        return query;
+    }
 
-	/**
-     * Returns the resource-level transaction object.
-     * The EntityTransaction instance may be used serially to
-     * begin and commit multiple transactions.
-     * @return EntityTransaction instance
-     * @throws IllegalStateException if invoked on a JTA
-     * EntityManager.
+
+    /**
+     * <p>Closes this EntityManager.
+     * 
+     * <p>After invoking this method, all methods on the instance will throw an
+     * {@link IllegalStateException} except for {@link #isOpen}, which will return
+     * <code>false</code>   .</p>
+     *
+     * <p>This should be called when a method is finished with the EntityManager in a
+     * bean-managed transaction environment or when executed outside a container. Closing
+     * of the EntityManager is handled by the container when using container-managed
+     * transactions.</p>
      */
-    public javax.persistence.EntityTransaction getTransaction(){
+    public void close() {
         try {
-            return ((TransactionWrapper)transaction).getTransaction();
+            verifyOpen();
+            isOpen = false;
+            factory = null;
+            serverSession = null;
+            if (extendedPersistenceContext != null) {
+                if (checkForTransaction(false) == null) {
+                    // clear change sets but keep the cache
+                    extendedPersistenceContext.clearForClose(false);
+                } else {
+                    // when commit will be called, all change sets will be cleared, but the cache will be kept
+                    extendedPersistenceContext.setShouldClearForCloseInsteadOfResume(true);
+                }
+                extendedPersistenceContext = null;
+            }
         } catch (RuntimeException e) {
-            this.transaction.setRollbackOnlyInternal();
+            this.setRollbackOnly();
             throw e;
         }
     }
 
+
     /**
-    * Internal method. Indicates whether flushMode is AUTO.
-    * @return boolean
-    */
+     * Indicates if this EntityManager is an extended Persistence Context
+     */
+    public boolean isExtended() {
+        return this.extended;
+    }
+    
+    /**
+     * Internal method. Indicates whether flushMode is AUTO.
+     * @return boolean
+     */
     public boolean isFlushModeAUTO() {
         return flushMode == FlushModeType.AUTO;    
     }
     
-    protected void setJTATransactionWrapper() {
-        transaction = new JTATransactionWrapper(this);
+    /**
+     * Indicates whether or not this entity manager is open. Returns <code>true</code> until
+     * a call to {@link #close} is made.
+     */
+    public boolean isOpen() {
+        return isOpen && factory.isOpen();
     }
+    /**
+     * Set the lock mode for an entity object contained in the persistence context.
+     * @param entity
+     * @param lockMode
+     * @throws PersistenceException if an unsupported lock call is made
+     * @throws IllegalArgumentException if the instance is not an entity or is a detached entity
+     * @throws javax.persistence.TransactionRequiredException if there is no transaction
+     */
+    public void lock(Object entity, LockModeType lockMode) {
+        try {
+            verifyOpen();
+            RepeatableWriteUnitOfWork context = getActivePersistenceContext(checkForTransaction(!isExtended()));
+            ClassDescriptor descriptor = context.getDescriptor(entity);
+            OptimisticLockingPolicy lockingPolicy = descriptor.getOptimisticLockingPolicy();
+            if ((lockingPolicy == null) || !(lockingPolicy instanceof VersionLockingPolicy)) {
+                throw new PersistenceException(ExceptionLocalization.buildMessage("ejb30-wrong-lock_called_without_version_locking-index", null));
+            }
+            context.forceUpdateToVersionField(entity, (lockMode == LockModeType.WRITE));
+        } catch (RuntimeException e) {
+            this.setRollbackOnly();
+            throw e;
+        }
+    }
+
+    public void verifyOpen() {
+        if (!isOpen()) {
+            throw new IllegalStateException(ExceptionLocalization.buildMessage("operation_on_closed_entity_manager"));
+        }
+    }
+    public RepeatableWriteUnitOfWork getActivePersistenceContext(Object txn) {
+        if (this.isExtended()) {
+            // use local uow as it will be local to this EM and not on the txn
+            if (this.extendedPersistenceContext == null || !this.extendedPersistenceContext.isActive()) {
+                this.extendedPersistenceContext = new RepeatableWriteUnitOfWork(this.serverSession.acquireClientSession());
+                this.extendedPersistenceContext.setResumeUnitOfWorkOnTransactionCompletion(true);
+                this.extendedPersistenceContext.setShouldCascadeCloneToJoinedRelationship(true);
+                this.extendedPersistenceContext.setProperties(properties);
+
+                if (txn != null) {
+                    // if there is an active txn we must register with it on creation of PC
+                    transaction.registerUnitOfWorkWithTxn(this.extendedPersistenceContext);
+                }
+            }
+            if (this.beginEarlyTransaction && txn != null && !this.extendedPersistenceContext.isInTransaction() ) {
+                //gf3334, force persistencecontext early transaction
+               this.extendedPersistenceContext.beginEarlyTransaction();
+            }
+            return this.extendedPersistenceContext;
+        } else {
+            return getTransactionalUnitOfWork_new(txn);
+        }
+    }
+
+    /**
+     * This method is used in contains to check if we already have a persistence context.
+     * If there is no active persistence context the method returns false
+     */
+    private boolean hasActivePersistenceContext() {
+        if (isExtended() && (this.extendedPersistenceContext == null || !this.extendedPersistenceContext.isActive()))
+            return false;
+        else
+            return true;
+    }
+    protected RepeatableWriteUnitOfWork getTransactionalUnitOfWork_new(Object tnx) {
+        return transaction.getTransactionalUnitOfWork(tnx);
+    }
+    protected Object checkForTransaction(boolean validateExistence) {
+        return transaction.checkForTransaction(validateExistence);
+    }
+
+    public boolean shouldFlushBeforeQuery() {
+        Object foundTransaction = checkForTransaction(false);
+        if ((foundTransaction != null) && transaction.shouldFlushBeforeQuery(getActivePersistenceContext(foundTransaction))) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * This is used to determine if the Persistence Contexts (in the form of UOWs)
+     * should be propagated or not, which effectively means we will use the 
+     * active unit of work.
+     */
+    public boolean shouldPropagatePersistenceContext() {
+        return this.propagatePersistenceContext;
+    }
     
+    //Indicate the early transaction should be forced to start.
+    public boolean shouldBeginEarlyTransaction(){
+        return this.beginEarlyTransaction;
+    }
+    
+    /**
+     * Indicate to the EntityManager that a JTA transaction is
+     * active. This method should be called on a JTA application
+     * managed EntityManager that was created outside the scope
+     * of the active transaction to associate it with the current
+     * JTA transaction.
+     * @throws javax.persistence.TransactionRequiredException if there is
+     * no transaction.
+     */
+    public void joinTransaction() {
+        try {
+            verifyOpen();
+            transaction.registerUnitOfWorkWithTxn(getActivePersistenceContext(checkForTransaction(true)));
+        } catch (RuntimeException e) {
+            this.setRollbackOnly();
+            throw e;
+        }
+    }
+
+    /**
+     * Internal method. Sets transaction to rollback only.
+     */
+    protected void setRollbackOnly() {
+        this.transaction.setRollbackOnlyInternal();
+    }
+    
+    /**
+     * Internal method, set begin early transaction if property has been specified.
+     */
+    private void setBeginEarlyTransaction(){
+        String beginEarlyTransactionProperty = (String)getProperty(PersistenceUnitProperties.JOIN_EXISTING_TRANSACTION);
+        if(beginEarlyTransactionProperty!=null){
+            this.beginEarlyTransaction="true".equalsIgnoreCase(beginEarlyTransactionProperty);
+        }
+    }
+    
     protected void setEntityTransactionWrapper() {   
         transaction = new EntityTransactionWrapper(this);
-    }    
+    }
+    
+    /**
+     * Set the flush mode that applies to all objects contained
+     * in the persistence context.
+     * @param flushMode
+     */
+    public void setFlushMode(FlushModeType flushMode) {
+        try {
+            verifyOpen();
+            this.flushMode = flushMode;
+        } catch (RuntimeException e) {
+            this.transaction.setRollbackOnlyInternal();
+            throw e;
+        }
+    }
+    
+    protected void setJTATransactionWrapper() {
+        transaction = new JTATransactionWrapper(this);
+    }
 }
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/PropertiesHandler.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/PropertiesHandler.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/PropertiesHandler.java	(working copy)
@@ -7,7 +7,7 @@
  * Contributors:
  *     Oracle - initial API and implementation from Oracle TopLink
  ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.base;
+package org.eclipse.persistence.internal.jpa;
 
 import java.util.HashMap;
 import java.util.Iterator;
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/DataSourceConfig.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/DataSourceConfig.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/DataSourceConfig.java	(working copy)
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.base;
-
-import java.io.StringWriter;
-
-/**
- * Simplest of all possible holder objects for all of the data source 
- * info required by the Entity test environment. Use the constructor to 
- * simultaneously create the instance and set the fields. 
- * <p>
- * At least one (transactional) data source must be specified and 
- * potentially a non-transactional if such a data source is appropriate 
- * (e.g. for non-transactional operations).
- * <p>
- * @see ContainerConfig
- * @see EntityContainer
- */
-public class DataSourceConfig {
-
-    /** Identifier to name this data source (must be Container-unique) */
-    public String dsName;
-
-    /** JNDI name that data source should be bound to */
-    public String jndiName;
-
-    /** URL that is passed to the driver to determine db */
-    public String url;
-
-    /** Driver class name string */
-    public String driver;
-
-    /** User name to use when connecting to the db */
-    public String user;
-
-    /** Password to use when connecting to the db */
-    public String password;
-    
-    /**
-     * Constructor used to create a DataSourceConfig
-     *
-     * @param dsName Data source identifier 
-     * @param jndiName Name that the data source should be bound to in JNDI
-     * @param url Passed to the driver to determine db
-     * @param driver The class name for the db driver
-     * @param user User name to use when connecting to the db
-     * @param password Password to use when connecting to the db
-     */
-    public DataSourceConfig(String dsName, String jndiName, String url, String driver, String user, String password) {
-        this.dsName = dsName;
-        this.jndiName = jndiName;
-        this.url = url;
-        this.driver = driver;
-        this.user = user;
-        this.password = password;
-    }
-
-    /**
-     * INTERNAL:
-     */
-    public String toString() {
-        StringWriter writer = new StringWriter();
-        if(dsName != null) {
-            writer.write("dsName = " + dsName + '\n');
-        }
-        if(jndiName != null) {
-            writer.write("jndiName = " + jndiName + '\n');
-        }
-        if(url != null) {
-            writer.write("url = " + url + '\n');
-        }
-        if(driver != null) {
-            writer.write("driver = " + driver + '\n');
-        }
-        if(user != null) {
-            writer.write("user = " + user + '\n');
-        }
-        return writer.toString();
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/EntityManagerFactoryImpl.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/EntityManagerFactoryImpl.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/EntityManagerFactoryImpl.java	(working copy)
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.base;
-
-import java.util.Map;
-import org.eclipse.persistence.sessions.server.ServerSession;
-import org.eclipse.persistence.internal.localization.ExceptionLocalization;
-import org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl;
-
-/**
-* <p>
-* <b>Purpose</b>: Provides the implementation for the EntityManager Factory.
-* <p>
-* <b>Description</b>: This class will store a reference to the active ServerSession.  When a request
-* is made for an EntityManager an new EntityManager is created with the ServerSession and returned.
-* The primary consumer of these EntityManager is assumed to be either the Container.    There is
-* one EntityManagerFactory per deployment.
-* @see javax.persistence.EntityManager
-* @see org.eclipse.persistence.jpa.EntityManager
-* @see javax.persistence.EntityManagerFactory
-*/
-
-/*  @author  gyorke  
- *  @since   TopLink 10.1.3 EJB 3.0 Preview
- */
-
-public abstract class EntityManagerFactoryImpl {
-    // This stores a reference to the ServerSession for this deployement.
-    protected ServerSession serverSession;
-    protected EntityManagerSetupImpl setupImpl;
-    protected boolean isOpen = true;
-    protected Map properties;
-
-    protected abstract EntityManagerImpl createEntityManagerImplInternal(Map properties, boolean extended);
-
-    /**
-     * Will return an instance of the Factory.  Should only be called by TopLink.
-     * @param serverSession
-     */
-    public EntityManagerFactoryImpl(ServerSession serverSession){
-        this.serverSession = serverSession;
-    }
-    
-    public EntityManagerFactoryImpl(EntityManagerSetupImpl setupImpl, Map properties){
-        this.setupImpl = setupImpl;
-        this.properties = properties;
-    }
-    
-    /**
-     * INTERNAL:
-     * Returns the ServerSession that the Factory will be using and initializes it if it is not available.
-     * This method makes use of the partially constructed session stored in our setupImpl and
-     * completes its construction
-     */
-    public synchronized ServerSession getServerSession(){
-        if (serverSession == null){   
-            ClassLoader realLoader = setupImpl.getPersistenceUnitInfo().getClassLoader();
-            // the call top setupImpl.deploy() finishes the session creation
-            serverSession = setupImpl.deploy(realLoader, properties);
-        }
-        return this.serverSession;
-    }
-    
-    /**
-	 * Closes this factory, releasing any resources that might be held by this factory. After
-	 * invoking this method, all methods on the instance will throw an
-	 * {@link IllegalStateException}, except for {@link #isOpen}, which will return
-	 * <code>false</code>.
-	 */
-	public synchronized void close(){
-        verifyOpen();
-        isOpen = false;
-        setupImpl.undeploy();
-    }
-
-
-	/**
-	 * Indicates whether or not this factory is open. Returns <code>true</code> until a call
-	 * to {@link #close} is made.
-	 */
-	public boolean isOpen(){
-       return isOpen;
-    }
-
-    protected EntityManagerImpl createEntityManagerImpl(boolean extended) {
-        return createEntityManagerImpl(null, extended);
-    }
-
-    protected synchronized EntityManagerImpl createEntityManagerImpl(Map properties, boolean extended) {
-        verifyOpen();
-
-        if (!getServerSession().isConnected()) {
-            getServerSession().login();
-        }
-        return createEntityManagerImplInternal(properties, extended);
-    }
-
-    protected void verifyOpen(){
-        if (!isOpen){
-            throw new IllegalStateException(ExceptionLocalization.buildMessage("operation_on_closed_entity_manager_factory"));
-        }
-    }    
-
-    protected void finalize() throws Throwable {
-        if(isOpen()) {
-            close();
-        }
-    }
-    
-    /**
-     * The method return user defined property passed in from EntityManagerFactory. 
-     * @param name
-     * @return
-     */
-    public Object getProperty(String name) {
-        Object propertyValue=null;
-        if(name==null){
-            return null;
-        }
-        return this.getServerSession().getProperty(name);
-    }
-
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/CMP3Policy.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/CMP3Policy.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/CMP3Policy.java	(working copy)
@@ -1,498 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.base;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.util.*;
-import org.eclipse.persistence.descriptors.*;
-import org.eclipse.persistence.internal.helper.ConversionManager;
-import org.eclipse.persistence.internal.localization.ExceptionLocalization;
-import org.eclipse.persistence.internal.sessions.AbstractSession;
-import org.eclipse.persistence.mappings.DatabaseMapping;
-import org.eclipse.persistence.mappings.foundation.AbstractDirectMapping;
-import org.eclipse.persistence.exceptions.*;
-import org.eclipse.persistence.internal.helper.DatabaseField;
-import org.eclipse.persistence.internal.descriptors.ObjectBuilder;
-import org.eclipse.persistence.internal.security.PrivilegedAccessHelper;
-import org.eclipse.persistence.internal.security.PrivilegedGetField;
-import org.eclipse.persistence.internal.security.PrivilegedClassForName;
-import org.eclipse.persistence.internal.security.PrivilegedGetMethod;
-import org.eclipse.persistence.internal.security.PrivilegedGetValueFromField;
-import org.eclipse.persistence.internal.security.PrivilegedSetValueInField;
-import org.eclipse.persistence.internal.security.PrivilegedMethodInvoker;
-import org.eclipse.persistence.internal.jpa.metadata.MetadataHelper;
-
-/**
- * <b>Description</b>: Defines primary key extraction coce,
- * and differentiates CMP3 from CMP1/2.
- *
- * @since TopLink 10.1.3
- */
-
-// This should be refactored to have an abstract CMPPolicy, and have CMP1/2/3 subclass and define correct functionality.
-public class CMP3Policy extends CMPPolicy {
-
-    /** Stores the fields for this classes compound primary key class if required. */
-    protected KeyElementAccessor[] keyClassFields;
-    
-    // Store the primary key class name
-    protected String pkClassName;
-    
-    // Stores the class version of the PKClass
-    protected Class pkClass;
-
-    public CMP3Policy() {
-        super();
-    }
-    
-    /**
-     * INTERNAL:
-     * Convert all the class-name-based settings in this object to actual class-based
-     * settings. This method is used when converting a project that has been built
-     * with class names to a project with classes.
-     * @param classLoader 
-     */
-    public void convertClassNamesToClasses(ClassLoader classLoader){
-        if(getPKClassName() != null){
-            try{
-                Class pkClass = null;
-                if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
-                    try {
-                        pkClass = (Class)AccessController.doPrivileged(new PrivilegedClassForName(getPKClassName(), true, classLoader));
-                    } catch (PrivilegedActionException exception) {
-                        throw new IllegalArgumentException(ExceptionLocalization.buildMessage("pk_class_not_found", new Object[] {this.pkClassName}), exception.getException());
-                        
-                    }
-                } else {
-                    pkClass = org.eclipse.persistence.internal.security.PrivilegedAccessHelper.getClassForName(getPKClassName(), true, classLoader);
-                }
-                setPKClass(pkClass);
-            } catch (ClassNotFoundException exc){
-                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("pk_class_not_found", new Object[] {this.pkClassName}), exc);
-            }
-        }
-    }
-
-    /**
-     * INTERNAL:
-     * Return if this policy is for CMP3.
-     */
-    public boolean isCMP3Policy() {
-        return true;
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public void setPrimaryKeyClassName(String pkClassName) {
-        this.pkClassName = pkClassName;
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public Class getPKClass() {
-        if(this.pkClass == null && getPKClassName() == null) {
-            initializePrimaryKeyFields(null);
-        }
-        return this.pkClass;
-    }
-
-    /**
-     * ADVANCED:
-     */
-    public void setPKClass(Class pkClass) {
-        this.pkClass = pkClass;
-    }
-
-    /**
-     * INTERNAL:
-     */
-    public String getPKClassName() {
-        return pkClassName;
-    }
-    
-    /**
-     * INTERNAL:
-     */
-    public Object getPKClassInstance() {
-        try {
-            return getPKClass().newInstance();
-        } catch (Exception ex) {
-            return null;
-            // WIP - this should throw an exception
-        }
-    }
-    
-    /**
-     * INTERNAL:
-     * Use the key to create a TopLink primary key Vector.
-     * If the key is simple (direct mapped) then just add it to a vector,
-     * otherwise must go through the inefficient process of copying the key into the bean
-     * and extracting the key from the bean.
-     *
-     * @param key Object the primary key to use for creating the vector
-     * @return Vector
-     */
-    public Vector createPkVectorFromKey(Object key, AbstractSession session) {
-        // If the descriptor primary key is mapped through direct-to-field mappings,
-        // then no elaborate conversion is required.
-        // If key is compound, add each value to the vector.
-        KeyElementAccessor[] pkElementArray = this.getKeyClassFields(key.getClass());
-        Vector pkVector = new Vector(pkElementArray.length);
-        for (int index = 0; index < pkElementArray.length; index++) {
-            DatabaseMapping mapping = this.getDescriptor().getObjectBuilder().getMappingForAttributeName(pkElementArray[index].getAttributeName());
-            if (mapping == null) {
-                mapping = this.getDescriptor().getObjectBuilder().getMappingForField(pkElementArray[index].getDatabaseField());
-            }
-            while (mapping.isAggregateObjectMapping()) {
-                mapping = mapping.getReferenceDescriptor().getObjectBuilder().getMappingForAttributeName(pkElementArray[index].getAttributeName());
-                if (mapping == null) {// must be aggregate
-                    mapping = this.getDescriptor().getObjectBuilder().getMappingForField(pkElementArray[index].getDatabaseField());
-                }
-            }
-            Object fieldValue = null;
-            if (mapping.isDirectToFieldMapping()) {
-                fieldValue = ((AbstractDirectMapping)mapping).getFieldValue(pkElementArray[index].getValue(key), (org.eclipse.persistence.internal.sessions.AbstractSession)session);
-            } else {
-                fieldValue = pkElementArray[index].getValue(key);
-            }
-            pkVector.add(fieldValue);
-        }
-        return pkVector;
-    }
-
-    /**
-     * INTERNAL:
-     * Use the key to create a bean and initialize its primary key fields.
-     * Note: If is a compound PK then a primary key object is being used.
-     * This method should only be used for 'templates' when executing
-     * queries.  The bean built will not be given an EntityContext and should
-     * not be used as an actual entity bean.
-     *
-     * @param key Object the primary key to use for initializing the bean's
-     *            corresponding pk fields
-     * @return TopLinkCmpEntity
-     */
-    protected Object createBeanUsingKey(Object key, AbstractSession session) {
-        try {
-            Object bean = this.getDescriptor().getInstantiationPolicy().buildNewInstance();
-            KeyElementAccessor[] keyElements = this.getKeyClassFields(key.getClass());
-            for (int index = 0; index < keyElements.length; ++index) {
-                Object toWriteInto = bean;
-                Object keyFieldValue = keyElements[index].getValue(key);
-                DatabaseField field = keyElements[index].getDatabaseField();
-                DatabaseMapping mapping = this.getDescriptor().getObjectBuilder().getMappingForAttributeName(keyElements[index].getAttributeName());
-                if (mapping == null) {// must be aggregate
-                    mapping = this.getDescriptor().getObjectBuilder().getMappingForField(field);
-                }
-                while (mapping.isAggregateObjectMapping()) {
-                    Object aggregate = mapping.getRealAttributeValueFromObject(toWriteInto, session);
-                    if (aggregate == null) {
-                        aggregate = mapping.getReferenceDescriptor().getJavaClass().newInstance();
-                        mapping.setRealAttributeValueInObject(toWriteInto, aggregate);
-                    }
-                    mapping = mapping.getReferenceDescriptor().getObjectBuilder().getMappingForAttributeName(keyElements[index].getAttributeName());
-                    if (mapping == null) {// must be aggregate
-                        mapping = this.getDescriptor().getObjectBuilder().getMappingForField(field);
-                    }
-
-                    //change the object to write into to the aggregate for the next stage of the 
-                    // loop or for when we exit the loop.
-                    toWriteInto = aggregate;
-                }
-                mapping.setRealAttributeValueInObject(toWriteInto, keyFieldValue);
-            }
-            return bean;
-        } catch (Exception e) {
-            throw DescriptorException.errorUsingPrimaryKey(key, this.getDescriptor(), e);
-        }
-    }
-
-    /**
-     * INTERNAL:
-     * Cache the bean's primary key fields so speed up creating of primary key
-     * objects and initialization of beans.
-     *
-     * Note, we have to re-look up the fields for the bean class since
-     * these fields may have been loaded with the wrong loader (thank you Kirk).
-     * If the key is compound, we also have to look up the fields for the key.
-     */
-    protected KeyElementAccessor[] initializePrimaryKeyFields(Class keyClass) {
-        KeyElementAccessor[] pkAttributes = null;
-        ClassDescriptor descriptor = this.getDescriptor();
-
-        pkAttributes = new KeyElementAccessor[descriptor.getObjectBuilder().getPrimaryKeyMappings().size()];
-
-        Iterator attributesIter = descriptor.getPrimaryKeyFields().iterator();
-
-        // Used fields in case it is an embedded class
-        for (int i = 0; attributesIter.hasNext(); i++) {
-            DatabaseField field = (DatabaseField)attributesIter.next();
-
-            // This next section looks strange but we need to check all mappings
-            // for this field, not just the writable one and instead of having 
-            // multiple sections of duplicate code I will just add the writable 
-            // mapping to the list.
-            Vector allMappings = descriptor.getObjectBuilder().getReadOnlyMappingsForField(field);
-            if (allMappings == null) {
-                allMappings = new Vector(1);
-            } 
-            allMappings.add(descriptor.getObjectBuilder().getMappingForField(field));
-            
-            Exception elementIsFound = null; // use exception existence to detemine if element was found, so we can throw exception later
-            for (int index = (allMappings.size() - 1); index >= 0; --index) { // start with the writable first
-                DatabaseMapping mapping = (DatabaseMapping) allMappings.get(index);
-                
-                if (mapping.isForeignReferenceMapping()) {
-                    // In EJB3 this should be a direct to field mapping (either
-                    // on the entity directly or on an embeddable (aggregate).
-                    continue;
-                } else if (mapping.isAggregateMapping()) { // in the case of aggregates drill down.
-                    ObjectBuilder builder = mapping.getReferenceDescriptor().getObjectBuilder();
-                    
-                    Vector aggregateMappings = builder.getReadOnlyMappingsForField(field);
-                    if ((aggregateMappings != null) && (!aggregateMappings.isEmpty())) {
-                        // Add all the mappings from the aggregate to be
-                        // processed.
-                        allMappings.addAll(aggregateMappings);
-                    }
-                                        
-                    DatabaseMapping writableMapping = builder.getMappingForField(field);
-                    
-                    if (writableMapping != null) {
-                        // Since it may be another aggregate mapping, add it to 
-                        // the allMappings list so we can drill down on it as 
-                        // well.
-                        allMappings.add(writableMapping);
-                    }
-                    
-                    // Since we added the mappings from this aggregate mapping, 
-                    // we should remove this aggregate mapping from the
-                    // allMappings list. Otherwise, if the mapping for the 
-                    // primary key field is not found in the aggregate (or 
-                    // nested aggregate) then we will hit an infinite loop when
-                    // searching the aggregate and its mappings.
-                    // Note: This is cautionary, since in reality, this 'should'
-                    // never happen, but if it does we certainly would rather
-                    // throw an exception instead of causing an infinite loop.
-                    allMappings.remove(mapping);
-                    
-                    // Update the index to parse the next mapping.
-                    index = allMappings.size();
-                        
-                    // We modified the allMappings list, start over!
-                    continue; // for loop.
-                }
-                
-                String fieldName = mapping.getAttributeName();
-                if (keyClass == null){
-                    // must be a primitive
-                    pkAttributes[i] = new KeyIsElementAccessor(mapping.getAttributeName(), field);
-                    setPKClass(ConversionManager.getObjectClass(mapping.getAttributeClassification()));
-                    elementIsFound = null;
-                } else {
-                    try {
-                        Field keyField = null;
-                        if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
-                            try {
-                                keyField = (Field)AccessController.doPrivileged(new PrivilegedGetField(keyClass, fieldName, true));
-                            } catch (PrivilegedActionException exception) {
-                                throw (NoSuchFieldException)exception.getException();
-                            }
-                        } else {
-                            keyField = PrivilegedAccessHelper.getField(keyClass, fieldName, true);
-                        }
-                        pkAttributes[i] = new FieldAccessor(keyField, fieldName, field);
-                        elementIsFound = null;
-                    } catch (NoSuchFieldException ex) {
-                        //must be a property
-                        StringBuffer buffer = new StringBuffer();
-                        buffer.append("get");
-                        buffer.append(fieldName.substring(0, 1).toUpperCase());
-                        buffer.append(fieldName.substring(1));
-                        try {
-                            Method method = null;
-                            if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
-                                try {
-                                    method = AccessController.doPrivileged(new PrivilegedGetMethod(keyClass, buffer.toString(), new Class[] {  }, true));
-                                } catch (PrivilegedActionException exception) {
-                                    throw (NoSuchMethodException)exception.getException();
-                                }
-                            } else {
-                                method = PrivilegedAccessHelper.getMethod(keyClass, buffer.toString(), new Class[] {  }, true);
-                            }
-                            pkAttributes[i] = new PropertyAccessor(method, fieldName, field);
-                            elementIsFound = null;
-                        } catch (NoSuchMethodException exs) {
-                            // not a field not a method 
-                            if (descriptor.getObjectBuilder().getPrimaryKeyMappings().size() == 1) {
-                                //must be a primitive
-                                pkAttributes[i] = new KeyIsElementAccessor(mapping.getAttributeName(), field);
-                                setPKClass(ConversionManager.getObjectClass(mapping.getAttributeClassification()));
-                                elementIsFound = null;
-                            } else {
-                                elementIsFound = exs;
-                            }
-                        }
-                    }
-                }
-                
-                if (elementIsFound == null) {
-                    break;// break out of the loop we do not need to look for any more
-                }
-            }
-            if (elementIsFound != null) {
-                throw DescriptorException.errorUsingPrimaryKey(keyClass, getDescriptor(), elementIsFound);
-            }
-        }
-        return pkAttributes;
-    }
-
-    /**
-     * INTERNAL:
-     * @return Returns the keyClassFields.
-     */
-    protected KeyElementAccessor[] getKeyClassFields(Class clazz) {
-        if (this.keyClassFields == null){
-            this.keyClassFields = initializePrimaryKeyFields(this.pkClass == null? clazz : this.pkClass);
-        }
-        return this.keyClassFields;
-    }
-
-    /**
-     * INTERNAL:
-     * This class is used when the key class element is a property
-     */
-    private class PropertyAccessor implements KeyElementAccessor {
-        protected Method method;
-        protected String attributeName;
-        protected DatabaseField databaseField;
-
-        public PropertyAccessor(Method method, String attributeName, DatabaseField field) {
-            this.method = method;
-            this.attributeName = attributeName;
-            this.databaseField = field;
-        }
-
-        public String getAttributeName() {
-            return this.attributeName;
-        }
-
-        public DatabaseField getDatabaseField() {
-            return this.databaseField;
-        }
-        
-        public Object getValue(Object object) {
-            try {
-                if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
-                    try {
-                        return AccessController.doPrivileged(new PrivilegedMethodInvoker(method, object, new Object[] {  }));
-                    } catch (PrivilegedActionException exception) {
-                        Exception throwableException = exception.getException();
-                        if (throwableException instanceof IllegalAccessException) {
-                            throw (IllegalAccessException)throwableException;
-                        } else {
-                            throw (java.lang.reflect.InvocationTargetException)throwableException;
-                        }
-                    }
-                } else {
-                    return PrivilegedAccessHelper.invokeMethod(method, object, new Object[] {  });
-                }
-            } catch (Exception ex) {
-                throw DescriptorException.errorUsingPrimaryKey(object, getDescriptor(), ex);
-            }
-        }
-        
-        public void setValue(Object object, Object value) {
-            try {
-                if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
-                    try {
-                        AccessController.doPrivileged(new PrivilegedMethodInvoker(MetadataHelper.getSetMethod(method, object.getClass()), object, new Object[] {value}));
-                    } catch (PrivilegedActionException exception) {
-                        Exception throwableException = exception.getException();
-                        if (throwableException instanceof IllegalAccessException) {
-                            throw (IllegalAccessException)throwableException;
-                        } else {
-                            throw (java.lang.reflect.InvocationTargetException)throwableException;
-                        }
-                    }
-                } else {
-                    PrivilegedAccessHelper.invokeMethod(MetadataHelper.getSetMethod(method, object.getClass()), object, new Object[] {value});
-                }
-            } catch (Exception ex) {
-                throw DescriptorException.errorUsingPrimaryKey(object, getDescriptor(), ex);
-            }
-        }
-    }
-
-    /**
-     * INTERNAL:
-     * This class will be used when the element of the keyclass is a field
-     */
-    private class FieldAccessor implements KeyElementAccessor {
-        protected Field field;
-        protected String attributeName;
-        protected DatabaseField databaseField;
-
-        public FieldAccessor(Field field, String attributeName, DatabaseField databaseField) {
-            this.field = field;
-            this.attributeName = attributeName;
-            this.databaseField = databaseField;
-        }
-
-        public String getAttributeName() {
-            return this.attributeName;
-        }
-
-        public DatabaseField getDatabaseField() {
-            return this.databaseField;
-        }
-        
-        public Object getValue(Object object) {
-            try {
-                if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
-                    try {
-                        return AccessController.doPrivileged(new PrivilegedGetValueFromField(field, object));
-                    } catch (PrivilegedActionException exception) {
-                        throw DescriptorException.errorUsingPrimaryKey(object, getDescriptor(), exception.getException());                    }
-                } else {
-                    return org.eclipse.persistence.internal.security.PrivilegedAccessHelper.getValueFromField(field, object);
-                }
-            } catch (Exception ex) {
-                throw DescriptorException.errorUsingPrimaryKey(object, getDescriptor(), ex);
-            }
-        }
-        
-        public void setValue(Object object, Object value) {
-            try {
-                Field pkField = null;
-                if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
-                    try {
-                        pkField = (Field)AccessController.doPrivileged(new PrivilegedGetField(object.getClass(), field.getName(), true));
-                        AccessController.doPrivileged(new PrivilegedSetValueInField(pkField, object, value));
-                    } catch (PrivilegedActionException exception) {
-                        throw DescriptorException.errorUsingPrimaryKey(object, getDescriptor(), exception.getException());
-                    }
-                } else {
-                    pkField = PrivilegedAccessHelper.getField(object.getClass(), field.getName(), true);
-                    PrivilegedAccessHelper.setValueInField(pkField, object, value);
-                }
-            } catch (Exception ex) {
-                throw DescriptorException.errorUsingPrimaryKey(object, getDescriptor(), ex);
-            }
-        }
-    }
-
-
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/ExceptionFactory.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/ExceptionFactory.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/ExceptionFactory.java	(working copy)
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.base;
-
-import java.io.StringWriter;
-import java.io.PrintWriter;
-import java.sql.SQLException;
-import javax.transaction.SystemException;
-import javax.transaction.RollbackException;
-
-public class ExceptionFactory {
-    public ExceptionFactory() {
-    }
-
-    protected String stackTraceString(Exception ex) {
-        StringWriter swriter = new StringWriter();
-        PrintWriter writer = new PrintWriter(swriter, true);
-        ex.printStackTrace(writer);
-        writer.close();
-        return swriter.toString();
-    }
-
-    public SystemException newSystemException(String str) {
-        return new SystemException(str);
-    }
-
-    public SystemException newSystemException(Exception ex) {
-        return new SystemException("Real nested exception: " + stackTraceString(ex));
-    }
-
-    public RollbackException rollbackException(SQLException sqlEx) {
-        return new RollbackException(sqlEx.toString());
-    }
-
-    public SystemException txMarkedForRollbackException() {
-        return newSystemException("Transaction marked for rollback");
-    }
-
-    public SystemException txActiveException() {
-        return newSystemException("Transaction is already active");
-    }
-
-    public SystemException txNotActiveException() {
-        return newSystemException("No transaction is active");
-    }
-
-    public SystemException invalidStateException(int state) {
-        return newSystemException("Cannot complete operation, invalid state: " + state);
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/EJBQueryImpl.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/EJBQueryImpl.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/EJBQueryImpl.java	(working copy)
@@ -1,752 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.base;
-
-import java.util.*;
-
-import org.eclipse.persistence.exceptions.*;
-import org.eclipse.persistence.internal.helper.ClassConstants;
-import org.eclipse.persistence.internal.helper.Helper;
-import org.eclipse.persistence.internal.helper.BasicTypeHelperImpl;
-import org.eclipse.persistence.queries.*;
-import org.eclipse.persistence.sessions.Session;
-import org.eclipse.persistence.internal.jpa.parsing.JPQLParseTree;
-import org.eclipse.persistence.internal.jpa.parsing.jpql.*;
-import org.eclipse.persistence.internal.localization.ExceptionLocalization;
-import org.eclipse.persistence.internal.queries.JPQLCallQueryMechanism;
-import org.eclipse.persistence.internal.sessions.AbstractSession;
-import org.eclipse.persistence.sessions.DatabaseRecord;
-import org.eclipse.persistence.queries.StoredProcedureCall;
-
-/**
- * Concrete EJB 3.0 query class.
- */
-public abstract class EJBQueryImpl {
-    protected DatabaseQuery databaseQuery = null;
-    protected EntityManagerImpl entityManager = null;
-    protected String queryName = null;
-    protected Map parameters = null;
-    protected int firstResultIndex = -1; // -1 indicates undefined
-    protected int maxResults = -1; // -1 indicates undefined
-    protected int maxRows = -1; // -1 indicates undefined
-
-    abstract protected void throwNoResultException(String message);    
-    abstract protected void throwNonUniqueResultException(String message);    
-
-    /**
-     * Base constructor for EJBQueryImpl.  Initializes basic variables.
-     */
-    protected EJBQueryImpl(EntityManagerImpl entityManager) {
-        parameters = new HashMap();
-        this.entityManager = entityManager;
-    }
-
-    /**
-     * Create an EJBQueryImpl with a TopLink query.
-     * @param query
-     */
-    public EJBQueryImpl(DatabaseQuery query, EntityManagerImpl entityManager) {
-        this(entityManager);
-        this.databaseQuery = query;
-    }
-
-    /**
-     * Build an EJBQueryImpl based on the given ejbql string
-     * @param ejbql
-     * @param entityManager
-     */
-    public EJBQueryImpl(String ejbql, EntityManagerImpl entityManager) {
-        this(ejbql, entityManager, false);
-    }
-
-    /**
-     * Create an EJBQueryImpl with either a query name or an ejbql string
-     * @param queryDescription
-     * @param entityManager
-     * @param isNamedQuery determines whether to treat the query description as ejbql or a query name
-     */
-    public EJBQueryImpl(String queryDescription, EntityManagerImpl entityManager, boolean isNamedQuery) {
-        this(entityManager);
-        if (isNamedQuery) {
-            this.queryName = queryDescription;
-        } else {
-            if (databaseQuery == null) {
-                databaseQuery = buildEJBQLDatabaseQuery(queryDescription, getActiveSession());
-            }
-        }
-    }
-
-    /**
-     * Internal method to change the wrapped query to a DataModifyQuery if neccessary
-     */
-    protected void setAsSQLModifyQuery(){
-        if (getDatabaseQuery().isDataReadQuery()){
-            DataModifyQuery query = new DataModifyQuery();
-            query.setSQLString(databaseQuery.getSQLString());
-            query.setIsUserDefined(databaseQuery.isUserDefined());
-            query.setFlushOnExecute(databaseQuery.getFlushOnExecute());
-            databaseQuery = query;
-        }
-    }
-
-    /**
-     * Internal method to change the wrapped query to a DataReadQuery if neccessary
-     */
-    protected void setAsSQLReadQuery(){
-        if(getDatabaseQuery().isDataModifyQuery()){
-            DataReadQuery query = new DataReadQuery();
-            query.setUseAbstractRecord(false);
-            query.setSQLString(databaseQuery.getSQLString());
-            query.setIsUserDefined(databaseQuery.isUserDefined());
-            query.setFlushOnExecute(databaseQuery.getFlushOnExecute());
-            databaseQuery = query;
-        }
-    }
-
-    /**
-     * Build a DatabaseQuery from an EJBQL string.
-     * @param ejbql
-     * @param session the session to get the descriptors for this query for.
-     * @return a DatabaseQuery representing the given ejbql
-     */
-    public static DatabaseQuery buildEJBQLDatabaseQuery(String ejbql, Session session) {
-        return buildEJBQLDatabaseQuery(ejbql, null, session);
-    }
-    
-    /**
-     * Build a DatabaseQuery from an EJBQL string.
-     * 
-     * @param ejbql
-     * @param session the session to get the descriptors for this query for.
-     * @param hints a list of hints to be applied to the query
-     * @return a DatabaseQuery representing the given ejbql
-     */
-    public static DatabaseQuery buildEJBQLDatabaseQuery(String ejbql, Session session, HashMap hints) {
-        return buildEJBQLDatabaseQuery(null, ejbql, null, session, hints, null);
-    }
-    
-    /**
-     * Build a DatabaseQuery from an EJBQL string.
-     * 
-     * @param ejbql
-     * @param session the session to get the descriptors for this query for.
-     * @param hints a list of hints to be applied to the query
-     * @param classLoader the class loader to build the query with
-     * @return a DatabaseQuery representing the given ejbql
-     */
-    public static DatabaseQuery buildEJBQLDatabaseQuery(String ejbql, Session session, HashMap hints, ClassLoader classLoader) {
-        return buildEJBQLDatabaseQuery(null, ejbql, null, session, hints, classLoader);
-    }
-    
-    /**
-     * Build a DatabaseQuery from an EJBQL string.
-     * @param ejbql
-     * @parem flushOnExecute
-     * @param session the session to get the descriptors for this query for.
-     * @return a DatabaseQuery representing the given ejbql
-     */
-    public static DatabaseQuery buildEJBQLDatabaseQuery(String ejbql,  Boolean flushOnExecute, Session session) {
-        return buildEJBQLDatabaseQuery(null, ejbql, flushOnExecute, session, null, null);
-    }
-    
-    /**
-     * Build a DatabaseQuery from an EJBQL string.
-     * @param ejbql
-     * @parem flushOnExecute
-     * @param session the session to get the descriptors for this query for.
-     * @return a DatabaseQuery representing the given ejbql
-     */
-    public static DatabaseQuery buildEJBQLDatabaseQuery(String ejbql,  Boolean flushOnExecute, Session session, ClassLoader classLoader) {
-        return buildEJBQLDatabaseQuery(null, ejbql, flushOnExecute, session, null, classLoader);
-    }
-    
-    /**
-     * Build a DatabaseQuery from an JPQL string.
-     * 
-     * @param jpql the JPQL string.
-     * @param flushOnExecute flush the unit of work before executing the query.
-     * @param session the session to get the descriptors for this query for.
-     * @param hints a list of hints to be applied to the query.
-     * @return a DatabaseQuery representing the given jpql.
-     */
-    public static DatabaseQuery buildEJBQLDatabaseQuery(String queryName, String jpql, 
-            Boolean flushOnExecute, Session session, HashMap hints, ClassLoader classLoader) {            
-        // PERF: Check if the JPQL has already been parsed.
-        // Only allow queries with default properties to be parse cached.
-        boolean isCacheable = (queryName == null) && (hints == null) && (flushOnExecute == null);
-        DatabaseQuery databaseQuery = null;
-        if (isCacheable) {
-            databaseQuery = (DatabaseQuery)session.getProject().getJPQLParseCache().get(jpql);            
-        }
-        if ((databaseQuery == null) || (!databaseQuery.isPrepared())) {
-            JPQLParseTree parseTree = JPQLParser.buildParseTree(queryName, jpql);
-            parseTree.setClassLoader(classLoader);
-            databaseQuery = parseTree.createDatabaseQuery();
-            databaseQuery.setJPQLString(jpql);
-            parseTree.populateQuery(databaseQuery, (AbstractSession)session);            
-            // If the query uses fetch joins, need to use JPA default of not filtering duplicates.
-            if (databaseQuery.isReadAllQuery()) {
-                ReadAllQuery readAllQuery = (ReadAllQuery)databaseQuery;
-                if (readAllQuery.hasJoining() && (readAllQuery.getDistinctState() == ReadAllQuery.DONT_USE_DISTINCT)) {
-                    readAllQuery.setShouldFilterDuplicates(false);
-                }
-            }
-            // Bug#4646580  Add arguments to query.
-            parseTree.addParametersToQuery(databaseQuery);
-            ((JPQLCallQueryMechanism)databaseQuery.getQueryMechanism()).getJPQLCall().setIsParsed(true);
-            databaseQuery.setFlushOnExecute(flushOnExecute);            
-
-            //GF#1324 eclipselink.refresh query hint does not cascade
-            //cascade by mapping as default for read query
-            if(databaseQuery.isReadQuery ()) {
-                databaseQuery.cascadeByMapping();
-            }
-
-            // Apply any query hints.
-            databaseQuery = applyHints(hints, databaseQuery);
-            if (isCacheable) {
-                // Prepare query as hint may cause cloning (but not un-prepare as in read-only).
-                databaseQuery.prepareCall(session, new DatabaseRecord());
-                databaseQuery.setIsFromParseCache(true);
-                session.getProject().getJPQLParseCache().put(jpql, databaseQuery);
-            }
-        }
-        
-        return databaseQuery;
-    }
-    
-    /**
-     * Build a ReadAllQuery from a class and sql string.
-     */
-    public static DatabaseQuery buildSQLDatabaseQuery(Class resultClass, String sqlString) {
-        return buildSQLDatabaseQuery(resultClass, sqlString, null);
-    }
-    
-    /**
-     * Build a ReadAllQuery for class and sql string.
-     * 
-     * @param hints a list of hints to be applied to the query.
-     */
-    public static DatabaseQuery buildSQLDatabaseQuery(Class resultClass, String sqlString, HashMap hints) {
-        ReadAllQuery query = new ReadAllQuery(resultClass);
-        query.setSQLString(sqlString);
-        query.setIsUserDefined(true);
-        
-        // apply any query hints
-        return applyHints(hints, query);
-    }
-    /**
-     * Build a ResultSetMappingQuery from a sql result set mapping name and sql string.
-     */
-    public static DatabaseQuery buildSQLDatabaseQuery(String sqlResultSetMappingName, String sqlString) {
-        return buildSQLDatabaseQuery(sqlResultSetMappingName, sqlString, null);
-    }
-    
-    /**
-     * Build a ResultSetMappingQuery from a sql result set mapping name and sql string.
-     * @param hints a list of hints to be applied to the query.
-     */
-    public static DatabaseQuery buildSQLDatabaseQuery(String sqlResultSetMappingName, String sqlString, HashMap hints) {
-        ResultSetMappingQuery query = new ResultSetMappingQuery();
-        query.setSQLResultSetMappingName(sqlResultSetMappingName);
-        query.setSQLString(sqlString);
-        query.setIsUserDefined(true);
-        
-        // apply any query hints
-        return applyHints(hints, query);
-    }
-    
-    /**
-     * Build a ReadAllQuery from a class and stored procedure call.
-     */
-    public static DatabaseQuery buildStoredProcedureQuery(Class resultClass, StoredProcedureCall call, List<String> arguments, HashMap hints) {
-        DatabaseQuery query = new ReadAllQuery(resultClass);
-        query.setCall(call);
-        query.setIsUserDefined(true);
-        
-        // apply any query hints
-        query = applyHints(hints, query);
-        
-        // apply any query arguments
-        applyArguments(arguments, query);
-
-        return query;
-    }
-
-    /**
-     * Build a ResultSetMappingQuery from a sql result set mapping name and a 
-     * stored procedure call.
-     */
-    public static DatabaseQuery buildStoredProcedureQuery(StoredProcedureCall call, List<String> arguments, HashMap hints) {
-        DatabaseQuery query = new ResultSetMappingQuery();
-        query.setCall(call);
-        query.setIsUserDefined(true);
-        
-        // apply any query hints
-        query = applyHints(hints, query);
-        
-        // apply any query arguments
-        applyArguments(arguments, query);
-
-        return query;
-    }
-    
-    /**
-     * Build a ResultSetMappingQuery from a sql result set mapping name and a
-     * stored procedure call.
-     */
-    public static DatabaseQuery buildStoredProcedureQuery(String sqlResultSetMappingName, StoredProcedureCall call, List<String> arguments, HashMap hints) {
-        ResultSetMappingQuery query = new ResultSetMappingQuery();
-        query.setSQLResultSetMappingName(sqlResultSetMappingName);
-        query.setCall(call);
-        query.setIsUserDefined(true);
-        
-        // apply any query hints
-        DatabaseQuery hintQuery = applyHints(hints, query);
-        
-        // apply any query arguments
-        applyArguments(arguments, hintQuery);
-
-        return hintQuery;
-    }
-
-    /**
-     * Build a DataReadQuery from a sql string.
-     */
-    public static DatabaseQuery buildSQLDatabaseQuery(String sqlString, Boolean flushOnExecute) {
-        return buildSQLDatabaseQuery(sqlString, new HashMap());
-    }
-    
-    /**
-     * Build a DataReadQuery from a sql string.
-     */
-    public static DatabaseQuery buildSQLDatabaseQuery(String sqlString, HashMap hints) {
-        DataReadQuery query = new DataReadQuery();
-        query.setUseAbstractRecord(false);
-        query.setSQLString(sqlString);
-        query.setIsUserDefined(true);
-
-        // apply any query hints
-        return applyHints(hints, query);
-    }
-
-    /**
-     * Execute a ReadQuery by assigning the stored parameter values and running it
-     * in the database
-     * @return the results of the query execution
-     */
-    protected Object executeReadQuery() {
-        Vector parameterValues = processParameters();
-        //TODO: the following performFlush() call is a temporary workaround for bug 4752493:
-        // CTS: INMEMORY QUERYING IN EJBQUERY BROKEN DUE TO CHANGE TO USE REPORTQUERY.
-        // Ideally we should only flush in case the selectionExpression can't be conformed in memory.
-        // There are two alternative ways to implement that:
-        // 1. Try running the query with conformInUOW flag first - if it fails with 
-        //    QueryException.cannotConformExpression then flush and run the query again -
-        //    now without conforming.
-        // 2. Implement a new isComformable method on Expression which would determine whether the expression
-        //    could be conformed in memory, flush only in case it returns false.
-        //    Note that doesConform method currently implemented on Expression
-        //    requires object(s) to be confirmed as parameter(s).
-        //    The new isComformable method should not take any objects as parameters,
-        //    it should return false if there could be such an object that
-        //    passed to doesConform causes it to throw QueryException.cannotConformExpression -
-        //    and true otherwise.
-        boolean shouldResetConformResultsInUnitOfWork = false;
-        if (isFlushModeAUTO()) {
-            performPreQueryFlush();
-            if (getDatabaseQuery().isObjectLevelReadQuery()) {
-                if (((ObjectLevelReadQuery)getDatabaseQuery()).shouldConformResultsInUnitOfWork()) {
-                    cloneIfParseCachedQuery();
-                    ((ObjectLevelReadQuery)getDatabaseQuery()).setCacheUsage(ObjectLevelReadQuery.UseDescriptorSetting);
-                    shouldResetConformResultsInUnitOfWork = true;
-                }
-            }
-        }
-        try {
-            // in case it's a user-defined query
-            if (getDatabaseQuery().isUserDefined()) {
-                // and there is an active transaction
-                if (this.entityManager.checkForTransaction(false) != null) {
-                    // verify whether uow has begun early transaction
-                    if (!((org.eclipse.persistence.internal.sessions.UnitOfWorkImpl)getActiveSession()).wasTransactionBegunPrematurely()) {
-                        // uow begins early transaction in case it hasn't already begun.
-                        ((org.eclipse.persistence.internal.sessions.UnitOfWorkImpl)getActiveSession()).beginEarlyTransaction();
-                    }
-                }
-            }
-            return getActiveSession().executeQuery(getDatabaseQuery(), parameterValues);
-        } finally {
-            if (shouldResetConformResultsInUnitOfWork) {
-                ((ObjectLevelReadQuery)getDatabaseQuery()).conformResultsInUnitOfWork();
-            }
-        }
-    }
-
-    /**
-     * Execute an update or delete statement.
-     * @return the number of entities updated or deleted
-     */
-    public int executeUpdate() {
-        try {
-            //bug51411440: need to throw IllegalStateException if query executed on closed em
-            entityManager.verifyOpen();
-            setAsSQLModifyQuery();
-            //bug:4294241, only allow modify queries - UpdateAllQuery prefered
-            if (!(getDatabaseQuery() instanceof ModifyQuery)){
-                throw new IllegalStateException(ExceptionLocalization.buildMessage("incorrect_query_for_execute_update"));
-            }
-            //fix for bug:4288845, did not add the parameters to the query
-            Vector parameterValues = processParameters();
-            if(isFlushModeAUTO()) {
-                performPreQueryFlush();
-            }
-            Integer changedRows = (Integer)getActiveSession().executeQuery(databaseQuery, parameterValues);
-            return changedRows.intValue();
-        } catch (RuntimeException e) {
-            setRollbackOnly();
-            throw e;
-        }
-    }
-
-    /**
-     * Return the cached database query for this EJBQueryImpl.  If the query is
-     * a named query and it has not yet been looked up, the query will be looked up
-     * and stored as the cached query.
-     */
-    public DatabaseQuery getDatabaseQuery() {
-        if ((queryName != null) && (databaseQuery == null)) {
-            // need error checking and appropriate exception for non-existing query
-            databaseQuery = getActiveSession().getQuery(queryName);
-            if (databaseQuery != null) {
-                if (!databaseQuery.isPrepared()){
-                    //prepare the query before cloning, this ensures we do not have to continually prepare on each usage
-                    databaseQuery.prepareCall(getActiveSession(), new DatabaseRecord());
-                }
-                //Bug5040609  Make a clone of the original DatabaseQuery for this EJBQuery
-                databaseQuery = (DatabaseQuery)databaseQuery.clone();
-            } else {
-                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("unable_to_find_named_query", new Object[] {queryName}));
-            }
-            
-        }
-        return databaseQuery;
-    }
-
-    /**
-     * Non-standard method to return results of a ReadQuery that has a containerPoliry
-     * that returns objects as a collection rather than a List
-     * @return Collection of results
-     */
-    public Collection getResultCollection() {
-        //bug51411440: need to throw IllegalStateException if query executed on closed em
-        entityManager.verifyOpen();
-        setAsSQLReadQuery();
-        propagateResultProperties();
-        //bug:4297903, check container policy class and throw exception if its not the right type 
-        if (getDatabaseQuery() instanceof ReadAllQuery){
-          Class containerClass = ((ReadAllQuery)getDatabaseQuery()).getContainerPolicy().getContainerClass();
-          if (! Helper.classImplementsInterface(containerClass, ClassConstants.Collection_Class)){
-            throw QueryException.invalidContainerClass( containerClass, ClassConstants.Collection_Class );
-          }
-        } else if (getDatabaseQuery() instanceof ReadObjectQuery){
-            //bug:4300879, no support for ReadObjectQuery if a collection is required
-            throw QueryException.incorrectQueryObjectFound( getDatabaseQuery(), ReadAllQuery.class );
-        } else if (!(getDatabaseQuery() instanceof ReadQuery)){
-            throw new IllegalStateException(ExceptionLocalization.buildMessage("incorrect_query_for_get_result_collection"));
-        }
-        Object result = executeReadQuery();
-        return (Collection)result;
-    }
-
-    /**
-    * Execute the query and return the query results
-    * as a List.
-    * @return a list of the results
-    */
-    public List getResultList() {
-        try {
-            //bug51411440: need to throw IllegalStateException if query executed on closed em
-            entityManager.verifyOpen();
-            setAsSQLReadQuery();
-            propagateResultProperties();
-            //bug:4297903, check container policy class and throw exception if its not the right type 
-            if (getDatabaseQuery() instanceof ReadAllQuery){
-              Class containerClass = ((ReadAllQuery)getDatabaseQuery()).getContainerPolicy().getContainerClass();
-              if (! Helper.classImplementsInterface(containerClass, ClassConstants.List_Class)){
-                throw QueryException.invalidContainerClass( containerClass, ClassConstants.List_Class );
-              }
-            } else if (getDatabaseQuery() instanceof ReadObjectQuery){
-                //bug:4300879, handle ReadObjectQuery returning null
-                throw QueryException.incorrectQueryObjectFound( getDatabaseQuery(), ReadAllQuery.class );
-            } else if (!(getDatabaseQuery() instanceof ReadQuery)){
-                throw new IllegalStateException(ExceptionLocalization.buildMessage("incorrect_query_for_get_result_list"));
-            }
-            Object result = executeReadQuery();
-            return (List)result;
-        } catch (RuntimeException e) {
-            setRollbackOnly();
-            throw e;
-        }
-    }
-
-    /**
-    * Execute a query that returns a single result.
-    * @return the result
-    * @throws javax.persistence.EntityNotFoundException if there is no result
-    * @throws javax.persistence.NonUniqueResultException if more than one result
-    */
-    public Object getSingleResult() {
-        boolean rollbackOnException = true;
-        try {
-            //bug51411440: need to throw IllegalStateException if query executed on closed em
-            entityManager.verifyOpen();
-            setAsSQLReadQuery();
-            propagateResultProperties();
-            //bug:4301674, requires lists to be returned from ReadAllQuery objects
-            if (getDatabaseQuery() instanceof ReadAllQuery){
-              Class containerClass = ((ReadAllQuery)getDatabaseQuery()).getContainerPolicy().getContainerClass();
-              if (! Helper.classImplementsInterface(containerClass, ClassConstants.List_Class)){
-                throw QueryException.invalidContainerClass( containerClass, ClassConstants.List_Class );
-              }
-            } else if (!(getDatabaseQuery() instanceof ReadQuery)){
-                throw new IllegalStateException(ExceptionLocalization.buildMessage("incorrect_query_for_get_single_result"));
-            }
-            Object result = executeReadQuery();
-            if (result instanceof List){
-                List results = (List)result;
-                if (results.isEmpty()) {
-                    rollbackOnException = false;
-                    throwNoResultException(ExceptionLocalization.buildMessage("no_entities_retrieved_for_get_single_result", (Object[])null));                
-                } else if (results.size() > 1) {
-                    rollbackOnException = false;
-                    throwNonUniqueResultException(ExceptionLocalization.buildMessage("too_many_results_for_get_single_result", (Object[])null));
-                }
-                return results.get(0);
-            }else{
-                if (result == null) {
-                    rollbackOnException = false;
-                    throwNoResultException(ExceptionLocalization.buildMessage("no_entities_retrieved_for_get_single_result", (Object[])null));
-                }
-                return result;
-            }
-        } catch (RuntimeException e) {
-            if(rollbackOnException) {
-                setRollbackOnly();
-            }
-            throw e;
-        }
-    }
-
-    /**
-     * Internal method to add the parameters values to the query prior to execution. 
-     * Returns a list of parameter values in the order the parameters are
-     * defined for the databaseQuery.
-     */
-    protected Vector processParameters() {
-        if (databaseQuery == null) {
-            getDatabaseQuery();
-        }
-        List arguments = databaseQuery.getArguments();
-        if (arguments.isEmpty()) {
-            Iterator params = parameters.keySet().iterator();
-            while (params.hasNext()) {
-                databaseQuery.addArgument((String)params.next());
-            }
-            arguments = databaseQuery.getArguments();
-        }
-        // now create parameterValues in the same order as the argument list
-        Vector parameterValues = new Vector(arguments.size());
-        for (Iterator i = arguments.iterator(); i.hasNext();) {
-            String name = (String)i.next();
-            if (parameters.containsKey(name)) {
-                parameterValues.add(parameters.get(name));
-            } else {
-                // Error: missing actual parameter value
-                throw new IllegalStateException(ExceptionLocalization.buildMessage("missing_parameter_value", new Object[]{name}));
-            }
-        }
-        return parameterValues;
-    }
-
-    /**
-     * Replace the cached query with the given query.
-     */
-    public void setDatabaseQuery(DatabaseQuery query) {
-        databaseQuery = query;
-    }
-
-    /**
-     * Set the position of the first result to retrieve.
-     * @param startPosition position of the first result, numbered from 0.
-     */
-    protected void setFirstResultInternal(int startPosition) {
-        if (startPosition < 0) {
-            throw new IllegalArgumentException(ExceptionLocalization.buildMessage("negative_start_position", (Object[])null));
-        }
-        firstResultIndex = startPosition;
-    }
-
-    /**
-     * Set implementation-specific query arguments.
-     */
-    protected static void applyArguments(List<String> arguments, DatabaseQuery query) {
-        for (String argument : arguments) {
-            query.addArgument(argument);
-        }
-    }
-    
-    /**
-     * Set implementation-specific hints.
-     * 
-     * @param hints a list of hints to be applied to the query
-     * @param query the query to apply the hints to
-     */
-    protected static DatabaseQuery applyHints(HashMap hints, DatabaseQuery query) {
-        return QueryHintsHandler.apply(hints, query);
-    }
-
-    /**
-     * Spec. 3.5.2:
-     * "FlushMode.AUTO is set on the Query object, or if
-     * the flush mode setting for the persistence context is AUTO (the default) 
-     * and a flush mode setting has not been specified for the Query object,
-     * the persistence provider is responsible for ensuring that all updates
-     * to the state of all entities in the persistence context which could potentially 
-     * affect the result of the query are visible to the processing of the query."
-     */
-    protected boolean isFlushModeAUTO() {
-        if(getDatabaseQuery().getFlushOnExecute() != null) {
-            return getDatabaseQuery().getFlushOnExecute().booleanValue();
-        } else {
-            return entityManager.isFlushModeAUTO();
-        }
-    }
-    
-    /**
-     * Set an implementation-specific hint.
-     * If the hint name is not recognized, it is silently ignored.
-     * @throws IllegalArgumentException if the second argument is not
-     * valid for the implementation.
-     */
-    protected void setHintInternal(String hintName, Object value) {
-        cloneIfParseCachedQuery();
-        DatabaseQuery hintQuery = QueryHintsHandler.apply(hintName, value, getDatabaseQuery());
-        if (hintQuery != null) {
-            setDatabaseQuery(hintQuery);
-        }
-    }
-    
-    /**
-     * If the query was from the jpql parse cache it must be cloned before being modified.
-     */
-    protected void cloneIfParseCachedQuery() {
-        DatabaseQuery query = getDatabaseQuery();
-        if (query.isFromParseCache()) {
-            // Clone to allow setting of hints or other properties without corrupting original query.
-            query = (DatabaseQuery)databaseQuery.clone();
-            query.setIsFromParseCache(false);
-            setDatabaseQuery(query);
-        }
-    }
-
-    /**
-    * Set the maximum number of results to retrieve.
-    * @param maxResult
-    */
-    public void setMaxResultsInternal(int maxResult) {
-        if (maxResult < 0) {
-            throw new IllegalArgumentException(ExceptionLocalization.buildMessage("negative_max_result", (Object[])null));
-        }
-        this.maxResults = maxResult;
-    }
-
-    /**
-     * Configure the firstResult and maxRows in the TopLink ReadQuery.
-     */
-    protected void propagateResultProperties() {
-        DatabaseQuery databaseQuery = getDatabaseQuery();
-        if (databaseQuery.isReadQuery()) {
-            ReadQuery readQuery = (ReadQuery)databaseQuery;
-            if (maxResults >= 0) {
-                cloneIfParseCachedQuery();
-                readQuery = (ReadQuery)getDatabaseQuery();
-                maxRows = maxResults + ((firstResultIndex >= 0) ? firstResultIndex : 0);
-                readQuery.setMaxRows(maxRows);
-                maxResults = -1;
-            }
-            if (firstResultIndex > -1) {
-                cloneIfParseCachedQuery();
-                readQuery = (ReadQuery)getDatabaseQuery();
-                readQuery.setFirstResult(firstResultIndex);
-                firstResultIndex = -1;
-            }
-        }
-    }
-
-    /**
-    * Bind an argument to a named parameter.
-    * @param name the parameter name
-    * @param value
-    */
-    protected void setParameterInternal(String name, Object value) {
-        int index  = getDatabaseQuery().getArguments().indexOf(name);
-        if (getDatabaseQuery().getEJBQLString() != null){  //only non native queries
-            if (index == -1){
-                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-wrong-argument-name",new Object[]{name, getDatabaseQuery().getEJBQLString()}));
-            }
-            if (!isValidActualParameter(value, getDatabaseQuery().getArgumentTypes().get(index))) {
-                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-incorrect-parameter-type", new Object[] {name, value.getClass(), getDatabaseQuery().getArgumentTypes().get(index), getDatabaseQuery().getEJBQLString()}));
-            }
-        }
-        parameters.put(name, value);
-    }
-
-    /**
-    * Bind an argument to a positional parameter.
-    * @param position
-    * @param value
-    */
-    protected void setParameterInternal(int position, Object value) {
-        String pos = (new Integer(position)).toString();
-        int index = getDatabaseQuery().getArguments().indexOf(pos);
-        if (getDatabaseQuery().getEJBQLString() != null){  //only non native queries
-            if (index == -1) {
-                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-wrong-argument-index", new Object[]{position, getDatabaseQuery().getEJBQLString()}));
-            }
-            if (!isValidActualParameter(value, getDatabaseQuery().getArgumentTypes().get(index))) {
-                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-incorrect-parameter-type", new Object[] {position, value.getClass(), getDatabaseQuery().getArgumentTypes().get(index), getDatabaseQuery().getEJBQLString()}));
-            }
-        }
-        parameters.put(pos, value);
-    }
-
-    protected boolean isValidActualParameter(Object value, Object parameterType) {
-        if (value == null) {
-            return true;
-        } else {
-            return BasicTypeHelperImpl.getInstance().isAssignableFrom(parameterType, value.getClass());
-        }
-    }
-
-    protected Session getActiveSession() {
-        return entityManager.getActiveSession();
-    }    
-    
-    protected void performPreQueryFlush(){
-        if (this.entityManager.shouldFlushBeforeQuery()){
-            this.entityManager.flush();
-        }
-    }
-
-    protected void setRollbackOnly() {
-        entityManager.setRollbackOnly();
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/EntityManagerImpl.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/EntityManagerImpl.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/EntityManagerImpl.java	(working copy)
@@ -1,680 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.base;
-
-import java.util.Vector;
-import java.util.Map;
-import java.util.HashMap;
-
-import javax.persistence.EntityExistsException;
-import javax.persistence.EntityNotFoundException;
-import javax.persistence.LockModeType;
-import javax.persistence.PersistenceException;
-
-import org.eclipse.persistence.descriptors.ClassDescriptor;
-import org.eclipse.persistence.exceptions.EclipseLinkException;
-import org.eclipse.persistence.exceptions.ValidationException;
-import org.eclipse.persistence.expressions.Expression;
-import org.eclipse.persistence.internal.jpa.transaction.base.TransactionWrapperImpl;
-import org.eclipse.persistence.internal.localization.ExceptionLocalization;
-import org.eclipse.persistence.internal.sessions.MergeManager;
-import org.eclipse.persistence.internal.helper.IdentityHashtable;
-import org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy;
-import org.eclipse.persistence.descriptors.VersionLockingPolicy;
-import org.eclipse.persistence.queries.*;
-import org.eclipse.persistence.sessions.Session;
-import org.eclipse.persistence.sessions.UnitOfWork;
-import org.eclipse.persistence.sessions.server.ServerSession;
-import org.eclipse.persistence.sessions.factories.SessionManager;
-import org.eclipse.persistence.jpa.EntityManagerFactoryProvider;
-import org.eclipse.persistence.jpa.config.PersistenceUnitProperties;
-
-/**
- * <p>
- * <b>Purpose</b>: Contains the implementation of the EntityManager.
- * <p>
- * <b>Description</b>: This class provides the implementation for the combined TopLink
- * and EJB3.0 EntityManager class.  
- * <p>
- * <b>Responsibilities</b>:It is responsible for tracking transaction state and the
- * objects within that transaction.
- * @see javax.persistence.EntityManager
- * @see org.eclipse.persistence.jpa.EntityManager
- */
-/* @author  gyorke
- * @since   TopLink 10.1.3 EJB 3.0 Preview
- */
-public abstract class EntityManagerImpl {
-    protected TransactionWrapperImpl transaction = null;
-    protected boolean isOpen = true;
-    protected RepeatableWriteUnitOfWork extendedPersistenceContext;
-    // This attribute references the ServerSession that this deployement is using.
-    // This is a simple mechanism to reduce the number of SessionManager accesses.
-    protected ServerSession serverSession;
-    // References the factory that has created this entity manager
-    // to make sure that the factory is not garbage collected
-    protected EntityManagerFactoryImpl factory;
-
-    // We have not removed these flags because we may want to use them at a later date to provide transactional EntityManagers in JAVA SE
-    protected boolean extended;
-    protected boolean propagatePersistenceContext;
-    
-    
-    //gf3334, force early transaction flag.
-    protected boolean beginEarlyTransaction = false;
-    
-    //gf3334, this is place holder for properties that passed from createEntityManager 
-    protected Map properties;
-
-    protected abstract void setJTATransactionWrapper();
-    protected abstract void setEntityTransactionWrapper();
-    /**
-     * Internal method. Indicates whether flushMode is AUTO.
-     */
-    public abstract boolean isFlushModeAUTO();
-    /**
-     * Constructor returns an EntityManager assigned to the a particular ServerSession.
-     * @param sessionName the ServerSession name that should be used.
-     * This constructor can potentially throw TopLink exceptions regarding the existence, or
-     * errors with the specified session.
-     */
-    public EntityManagerImpl(String sessionName, boolean propagatePersistenceContext, boolean extended) {
-        this((ServerSession)SessionManager.getManager().getSession(sessionName), null, propagatePersistenceContext, extended);
-    }
-
-    /**
-     * Constructor called from the EntityManagerFactory to create an EntityManager
-     * @param serverSession the serverSession assigned to this deployment.
-     */
-    public EntityManagerImpl(ServerSession serverSession, boolean propagatePersistenceContext, boolean extended) {
-        this(serverSession, null, propagatePersistenceContext, extended);
-    }
-
-
-    /**
-     * Constructor called from the EntityManagerFactory to create an EntityManager
-     * @param serverSession the serverSession assigned to this deployment.
-     * Note: The properties argument is provided to allow properties to be passed into this EntityManager,
-     * but there are currently no such properties implemented
-     */
-    public EntityManagerImpl(ServerSession serverSession, Map properties, boolean propagatePersistenceContext, boolean extended) {
-        this.serverSession = serverSession;
-        detectTransactionWrapper();
-        this.extended = true;
-        this.propagatePersistenceContext = false;
-        this.properties=properties;
-        setBeginEarlyTransaction();
-    }
-
-    /**
-     * Constructor called from the EntityManagerFactory to create an EntityManager
-     * @param factory the EntityMangerFactoryImpl that created this entity manager.
-     * Note: The properties argument is provided to allow properties to be passed into this EntityManager,
-     * but there are currently no such properties implemented
-     */
-    public EntityManagerImpl(EntityManagerFactoryImpl factory, Map properties, boolean propagatePersistenceContext, boolean extended) {
-        this.factory = factory;
-        this.serverSession = factory.getServerSession();
-        detectTransactionWrapper();
-        this.extended = true;
-        this.propagatePersistenceContext = false;
-        this.properties=properties;
-        setBeginEarlyTransaction();
-    }
-
-    /**
-     * Clear the persistence context, causing all managed
-     * entities to become detached. Changes made to entities that
-     * have not been flushed to the database will not be
-     * persisted.
-     */
-    public void clear() {
-        try {
-            verifyOpen();
-            if (this.isExtended()) {
-                if (this.extendedPersistenceContext != null) {
-                    if (checkForTransaction(false) == null) {
-                        // clear all change sets and cache
-                        this.extendedPersistenceContext.clearForClose(true);
-                        this.extendedPersistenceContext = null;
-                    } else {
-                        // clear all change sets created after the last flush and cache
-                        this.extendedPersistenceContext.clear(true);
-                    }
-                }
-            } else {
-                transaction.clear();
-            }
-        } catch (RuntimeException e) {
-            this.setRollbackOnly();
-            throw e;
-        }
-    }
-
-    /**
-     * Internal method called by EntityTransactionImpl class in case of transaction rollback.
-     * The caller is responsible for releasing extendedPersistenceContext and it's parent.
-     */
-    public void removeExtendedPersistenceContext() {
-        this.extendedPersistenceContext = null;
-    }
-
-    /**
-     * If in a transaction this method will check for existence and register the object if
-     * it is new.  The instance of the entity provided will become managed.
-     * @param entity
-     * @throws IllegalArgumentException if the given Object is not an entity.
-     */
-    public void persist(Object entity) {
-        try {
-            verifyOpen();
-            if (entity == null) {
-                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[] { entity }));
-            }
-            try {
-                getActivePersistenceContext(checkForTransaction(!isExtended())).registerNewObjectForPersist(entity, new IdentityHashtable());
-            } catch (RuntimeException e) {
-                if (ValidationException.class.isAssignableFrom(e.getClass())) {
-                    throw new EntityExistsException(e.getLocalizedMessage(), e);
-                }
-                throw e;
-            }
-        } catch (RuntimeException e) {
-            this.setRollbackOnly();
-            throw e;
-        }
-    }
-
-    /**
-     * Merge the state of the given entity into the
-     * current persistence context, using the unqualified
-     * class name as the entity name.
-     * @param entity
-     * @return the instance that the state was merged to
-     * @throws IllegalArgumentException if given Object is not an entity or is a removed entity
-     */
-    protected Object mergeInternal(Object entity) {
-        if (entity == null) {
-            throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[] { entity }));
-        }
-        //gf830 - merging a removed entity should throw exception
-        if (getActivePersistenceContext(checkForTransaction(!isExtended())).getDeletedObjects().containsKey(entity)) {
-            throw new IllegalArgumentException(ExceptionLocalization.buildMessage("cannot_merge_removed_entity", new Object[] { entity }));
-        }
-        try {
-            return getActivePersistenceContext(checkForTransaction(!isExtended())).mergeCloneWithReferences(entity, MergeManager.CASCADE_BY_MAPPING, true);
-        } catch (org.eclipse.persistence.exceptions.OptimisticLockException ole) {
-            throw new javax.persistence.OptimisticLockException(ole);
-        }
-    }
-
-    /**
-     * Remove the instance.
-     * @param entity
-     * @throws IllegalArgumentException if Object passed in is not an entity
-     */
-    public void remove(Object entity) {
-        try {
-            verifyOpen();
-            if (entity == null) { //gf732 - check for null
-                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[] { entity }));
-            }
-            try {
-                getActivePersistenceContext(checkForTransaction(!isExtended())).performRemove(entity, new IdentityHashtable());
-            } catch (RuntimeException e) {
-                throw e;
-            }
-        } catch (RuntimeException e) {
-            this.setRollbackOnly();
-            throw e;
-        }
-    }
-
-    /**
-     * Find by primary key.
-     * @param entityName
-     * @param primaryKey
-     * @return the found entity instance
-     * @throws IllegalArgumentException if the first argument does not indicate an entity or if the
-     * second argument is not a valid type for that entity's primaryKey
-     */
-    public Object find(String entityName, Object primaryKey) {
-        try {
-            verifyOpen();
-            Session session = getActiveSession();
-            ClassDescriptor descriptor = session.getDescriptorForAlias(entityName);
-            if (descriptor == null || descriptor.isAggregateDescriptor() || descriptor.isAggregateCollectionDescriptor()) {
-                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("unknown_entitybean_name", new Object[] { entityName }));
-            }
-            if (primaryKey == null) { //gf721 - check for null PK
-                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("null_pk"));
-            }
-            if (((CMP3Policy)descriptor.getCMPPolicy()).getPKClass() != null && !((CMP3Policy)descriptor.getCMPPolicy()).getPKClass().isAssignableFrom(primaryKey.getClass())) {
-                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("invalid_pk_class", new Object[] { ((CMP3Policy)descriptor.getCMPPolicy()).getPKClass(), primaryKey.getClass() }));
-            }
-            return findInternal(descriptor, session, primaryKey);
-        } catch (RuntimeException e) {
-            this.setRollbackOnly();
-            throw e;
-        }
-    }
-
-    /**
-     * Find by primary key.
-     * @param entityClass
-     * @param primaryKey
-     * @return the found entity instance or null
-     * if the entity does not exist
-     * @throws IllegalArgumentException if the first argument does
-     * not denote an entity type or the second argument is not a valid type for that
-     * entity's primary key
-     */
-    protected Object findInternal(Class entityClass, Object primaryKey) {
-        Session session = getActiveSession();
-        ClassDescriptor descriptor = session.getDescriptor(entityClass);
-        if (descriptor == null || descriptor.isAggregateDescriptor() || descriptor.isAggregateCollectionDescriptor()) {
-            throw new IllegalArgumentException(ExceptionLocalization.buildMessage("unknown_bean_class", new Object[] { entityClass }));
-        }
-        if (primaryKey == null) { //gf721 - check for null PK
-            throw new IllegalArgumentException(ExceptionLocalization.buildMessage("null_pk"));
-        }
-        if (((CMP3Policy)descriptor.getCMPPolicy()).getPKClass() != null && !((CMP3Policy)descriptor.getCMPPolicy()).getPKClass().isAssignableFrom(primaryKey.getClass())) {
-            throw new IllegalArgumentException(ExceptionLocalization.buildMessage("invalid_pk_class", new Object[] { ((CMP3Policy)descriptor.getCMPPolicy()).getPKClass(), primaryKey.getClass() }));
-        }
-        return findInternal(descriptor, session, primaryKey);
-    }
-
-    /**
-     * Find by primary key.
-     * @param descriptor
-     * @param session
-     * @param primaryKey
-     * @return the found entity instance or null
-     * if the entity does not exist
-     * @throws IllegalArgumentException if the first argument does
-     * not denote an entity type or the second argument is not a valid type for that
-     * entity's primary key
-     */
-    protected static Object findInternal(ClassDescriptor descriptor, Session session, Object primaryKey) {
-        Vector pk;
-        if (primaryKey instanceof Vector) {
-            pk = (Vector)primaryKey;
-        } else {
-            pk = ((CMP3Policy)descriptor.getCMPPolicy()).createPkVectorFromKey(primaryKey, (org.eclipse.persistence.internal.sessions.AbstractSession)session);
-        }
-        ReadObjectQuery query = new ReadObjectQuery(descriptor.getJavaClass());
-        query.setSelectionKey(pk);
-        query.conformResultsInUnitOfWork();
-        return session.executeQuery(query);
-    }
-
-    /**
-     * Synchronize the persistence context with the
-     * underlying database.
-     */
-    public void flush() {
-        try {
-            verifyOpen();
-
-            try {
-                getActivePersistenceContext(checkForTransaction(true)).writeChanges();
-            } catch (RuntimeException e) {
-                if (EclipseLinkException.class.isAssignableFrom(e.getClass())) {
-                    throw new PersistenceException(e);
-                }
-                throw e;
-            }
-        } catch (RuntimeException e) {
-            this.setRollbackOnly();
-            throw e;
-        }
-    }
-
-    protected void detectTransactionWrapper() {
-        if (this.serverSession.hasExternalTransactionController()) {
-            setJTATransactionWrapper();
-        } else {
-            setEntityTransactionWrapper();
-        }
-    }
-
-    /**
-     * Refresh the state of the instance from the database.
-     * @param entity instance registered in the current persistence context.
-     */
-    public void refresh(Object entity) {
-        try {
-            verifyOpen();
-            UnitOfWork uow = getActivePersistenceContext(checkForTransaction(!isExtended()));
-            if (!contains(entity, uow)) {
-                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("cant_refresh_not_managed_object", new Object[] { entity }));
-            }
-            ReadObjectQuery query = new ReadObjectQuery();
-            query.setSelectionObject(entity);
-            query.refreshIdentityMapResult();
-            query.cascadeByMapping();
-            query.setLockMode(ObjectBuildingQuery.NO_LOCK);
-            query.setIsExecutionClone(true);
-            Object refreshedEntity = null;
-            refreshedEntity = uow.executeQuery(query);
-            if (refreshedEntity == null) {
-                // bug5955326, ReadObjectQuery will now ensure the object is invalidated if refresh returns null.
-                throw new EntityNotFoundException(ExceptionLocalization.buildMessage("entity_no_longer_exists_in_db", new Object[] { entity }));
-            }
-        } catch (RuntimeException exception) {
-            setRollbackOnly();
-            throw exception;
-        }
-    }
-
-    /**
-     * Check if the instance belongs to the current persistence
-     * context.
-     * @param entity
-     * @return
-     * @throws IllegalArgumentException if given Object is not an entity
-     */
-    public boolean contains(Object entity) {
-        try {
-            verifyOpen();
-            if (entity == null) {
-                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[] { entity }));
-            }
-            ClassDescriptor descriptor = (ClassDescriptor)getServerSession().getDescriptors().get(entity.getClass());
-            if (descriptor == null || descriptor.isAggregateDescriptor() || descriptor.isAggregateCollectionDescriptor()) {
-                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[] { entity }));
-            }
-
-            if ((!hasActivePersistenceContext())) {
-                return false;
-            }
-
-            return contains(entity, getActivePersistenceContext(checkForTransaction(false)));
-        } catch (RuntimeException e) {
-            this.setRollbackOnly();
-            throw e;
-        }
-    }
-
-    /**
-     * Check if the instance belongs to the current persistence
-     * context.
-     */
-    protected boolean contains(Object entity, UnitOfWork uow) {
-
-        return ((org.eclipse.persistence.internal.sessions.UnitOfWorkImpl)uow).isObjectRegistered(entity) && !((org.eclipse.persistence.internal.sessions.UnitOfWorkImpl)uow).isObjectDeleted(entity);
-    }
-
-    /**
-     * This method returns the current session to the requestor.  The current session
-     * will be a the active UnitOfWork within a transaction and will be a 'scrap'
-     * UnitOfWork outside of a transaction.  The caller is conserned about the results
-     * then the getSession() or getUnitOfWork() API should be called.
-     */
-    public Session getActiveSession() {
-        Object txn = checkForTransaction(false);
-        if (txn == null && !this.isExtended()) {
-            return this.serverSession.acquireNonSynchronizedUnitOfWork();
-        } else {
-            return getActivePersistenceContext(txn);
-        }
-    }
-    /**
-     * Return the underlying provider object for the EntityManager,
-     * if available. The result of this method is implementation
-     * specific.
-     */
-    public Object getDelegate() {
-        try {
-            verifyOpen();
-            return this;
-        } catch (RuntimeException e) {
-            this.setRollbackOnly();
-            throw e;
-        }
-    }
-
-    /**
-     * This method will return the active UnitOfWork 
-     */
-    public UnitOfWork getUnitOfWork() {
-        return getActivePersistenceContext(checkForTransaction(false));
-    }
-    /**
-     * This method will return a Session outside of a transaction and null within a transaction.
-     */
-    public Session getSession() {
-        if (checkForTransaction(false) == null) {
-            return this.serverSession.acquireNonSynchronizedUnitOfWork();
-        }
-        return null;
-    }
-    /**
-     * The method search for user defined property passed in from EntityManager, if it is not found then
-     * search for it from EntityManagerFactory properties.
-     * @param name
-     * @return
-     */
-    public Object getProperty(String name) {
-        Object propertyValue=null;
-        if(name==null){
-            return null;
-        }
-        if(this.properties!=null){
-            propertyValue=this.properties.get(name);
-        }
-        if(propertyValue==null){
-            propertyValue=this.factory.getServerSession().getProperty(name);
-        }
-        return propertyValue;
-    }
-
-    /**
-     * Return the underlying server session
-     */
-    public ServerSession getServerSession() {
-        return this.serverSession;
-    }
-    /**
-     * This method is used to create a query using SQL.  The class, must be the expected
-     * return type.
-     */
-    protected DatabaseQuery createNativeQueryInternal(String sqlString, Class resultType) {
-        ReadAllQuery query = new ReadAllQuery(resultType);
-        query.setSQLString(sqlString);
-        query.setIsUserDefined(true);
-        return query;
-    }
-    /**
-     * This method is used to create a query using a Toplink Expression and the return type.
-     */
-    protected DatabaseQuery createQueryInternal(Expression expression, Class resultType) {
-        ReadAllQuery query = new ReadAllQuery(resultType);
-        query.setSelectionCriteria(expression);
-        return query;
-    }
-
-
-    /**
-     * <p>Closes this EntityManager.
-     * 
-     * <p>After invoking this method, all methods on the instance will throw an
-     * {@link IllegalStateException} except for {@link #isOpen}, which will return
-     * <code>false</code>   .</p>
-     *
-     * <p>This should be called when a method is finished with the EntityManager in a
-     * bean-managed transaction environment or when executed outside a container. Closing
-     * of the EntityManager is handled by the container when using container-managed
-     * transactions.</p>
-     */
-    public void close() {
-        try {
-            verifyOpen();
-            isOpen = false;
-            factory = null;
-            serverSession = null;
-            if (extendedPersistenceContext != null) {
-                if (checkForTransaction(false) == null) {
-                    // clear change sets but keep the cache
-                    extendedPersistenceContext.clearForClose(false);
-                } else {
-                    // when commit will be called, all change sets will be cleared, but the cache will be kept
-                    extendedPersistenceContext.setShouldClearForCloseInsteadOfResume(true);
-                }
-                extendedPersistenceContext = null;
-            }
-        } catch (RuntimeException e) {
-            this.setRollbackOnly();
-            throw e;
-        }
-    }
-
-
-    /**
-     * Indicates if this EntityManager is an extended Persistence Context
-     */
-    public boolean isExtended() {
-        return this.extended;
-    }
-    /**
-     * Indicates whether or not this entity manager is open. Returns <code>true</code> until
-     * a call to {@link #close} is made.
-     */
-    public boolean isOpen() {
-        return isOpen && factory.isOpen();
-    }
-    /**
-     * Set the lock mode for an entity object contained in the persistence context.
-     * @param entity
-     * @param lockMode
-     * @throws PersistenceException if an unsupported lock call is made
-     * @throws IllegalArgumentException if the instance is not an entity or is a detached entity
-     * @throws javax.persistence.TransactionRequiredException if there is no transaction
-     */
-    public void lock(Object entity, LockModeType lockMode) {
-        try {
-            verifyOpen();
-            RepeatableWriteUnitOfWork context = getActivePersistenceContext(checkForTransaction(!isExtended()));
-            ClassDescriptor descriptor = context.getDescriptor(entity);
-            OptimisticLockingPolicy lockingPolicy = descriptor.getOptimisticLockingPolicy();
-            if ((lockingPolicy == null) || !(lockingPolicy instanceof VersionLockingPolicy)) {
-                throw new PersistenceException(ExceptionLocalization.buildMessage("ejb30-wrong-lock_called_without_version_locking-index", null));
-            }
-            context.forceUpdateToVersionField(entity, (lockMode == LockModeType.WRITE));
-        } catch (RuntimeException e) {
-            this.setRollbackOnly();
-            throw e;
-        }
-    }
-
-    public void verifyOpen() {
-        if (!isOpen()) {
-            throw new IllegalStateException(ExceptionLocalization.buildMessage("operation_on_closed_entity_manager"));
-        }
-    }
-    public RepeatableWriteUnitOfWork getActivePersistenceContext(Object txn) {
-        if (this.isExtended()) {
-            // use local uow as it will be local to this EM and not on the txn
-            if (this.extendedPersistenceContext == null || !this.extendedPersistenceContext.isActive()) {
-                this.extendedPersistenceContext = new RepeatableWriteUnitOfWork(this.serverSession.acquireClientSession());
-                this.extendedPersistenceContext.setResumeUnitOfWorkOnTransactionCompletion(true);
-                this.extendedPersistenceContext.setShouldCascadeCloneToJoinedRelationship(true);
-                this.extendedPersistenceContext.setProperties(properties);
-
-                if (txn != null) {
-                    // if there is an active txn we must register with it on creation of PC
-                    transaction.registerUnitOfWorkWithTxn(this.extendedPersistenceContext);
-                }
-            }
-            if (this.beginEarlyTransaction && txn != null && !this.extendedPersistenceContext.isInTransaction() ) {
-                //gf3334, force persistencecontext early transaction
-               this.extendedPersistenceContext.beginEarlyTransaction();
-            }
-            return this.extendedPersistenceContext;
-        } else {
-            return getTransactionalUnitOfWork_new(txn);
-        }
-    }
-
-    /**
-     * This method is used in contains to check if we already have a persistence context.
-     * If there is no active persistence context the method returns false
-     */
-    private boolean hasActivePersistenceContext() {
-        if (isExtended() && (this.extendedPersistenceContext == null || !this.extendedPersistenceContext.isActive()))
-            return false;
-        else
-            return true;
-    }
-    protected RepeatableWriteUnitOfWork getTransactionalUnitOfWork_new(Object tnx) {
-        return transaction.getTransactionalUnitOfWork(tnx);
-    }
-    protected Object checkForTransaction(boolean validateExistence) {
-        return transaction.checkForTransaction(validateExistence);
-    }
-
-    public boolean shouldFlushBeforeQuery() {
-        Object foundTransaction = checkForTransaction(false);
-        if ((foundTransaction != null) && transaction.shouldFlushBeforeQuery(getActivePersistenceContext(foundTransaction))) {
-            return true;
-        }
-        return false;
-    }
-
-    /**
-     * This is used to determine if the Persistence Contexts (in the form of UOWs)
-     * should be propagated or not, which effectively means we will use the 
-     * active unit of work.
-     */
-    public boolean shouldPropagatePersistenceContext() {
-        return this.propagatePersistenceContext;
-    }
-    
-    //Indicate the early transaction should be forced to start.
-    public boolean shouldBeginEarlyTransaction(){
-        return this.beginEarlyTransaction;
-    }
-    
-    /**
-     * Indicate to the EntityManager that a JTA transaction is
-     * active. This method should be called on a JTA application
-     * managed EntityManager that was created outside the scope
-     * of the active transaction to associate it with the current
-     * JTA transaction.
-     * @throws javax.persistence.TransactionRequiredException if there is
-     * no transaction.
-     */
-    public void joinTransaction() {
-        try {
-            verifyOpen();
-            transaction.registerUnitOfWorkWithTxn(getActivePersistenceContext(checkForTransaction(true)));
-        } catch (RuntimeException e) {
-            this.setRollbackOnly();
-            throw e;
-        }
-    }
-
-    /**
-     * Internal method. Sets transaction to rollback only.
-     */
-    protected void setRollbackOnly() {
-        this.transaction.setRollbackOnlyInternal();
-    }
-    
-    /**
-     * Internal method, set begin early transaction if property has been specified.
-     */
-    private void setBeginEarlyTransaction(){
-        String beginEarlyTransactionProperty = (String)getProperty(PersistenceUnitProperties.JOIN_EXISTING_TRANSACTION);
-        if(beginEarlyTransactionProperty!=null){
-            this.beginEarlyTransaction="true".equalsIgnoreCase(beginEarlyTransactionProperty);
-        }
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/QueryHintsHandler.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/QueryHintsHandler.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/QueryHintsHandler.java	(working copy)
@@ -1,581 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.base;
-
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.eclipse.persistence.jpa.config.*;
-import org.eclipse.persistence.exceptions.QueryException;
-
-
-import org.eclipse.persistence.queries.DatabaseQuery;
-import org.eclipse.persistence.queries.ObjectLevelReadQuery;
-import org.eclipse.persistence.queries.ReadAllQuery;
-import org.eclipse.persistence.expressions.Expression;
-import org.eclipse.persistence.descriptors.ClassDescriptor;
-import org.eclipse.persistence.internal.localization.ExceptionLocalization;
-import org.eclipse.persistence.internal.security.PrivilegedAccessHelper;
-import org.eclipse.persistence.internal.security.PrivilegedClassForName;
-import org.eclipse.persistence.internal.sessions.AbstractSession;
-import org.eclipse.persistence.logging.SessionLog;
-import org.eclipse.persistence.mappings.ForeignReferenceMapping;
-import org.eclipse.persistence.mappings.DatabaseMapping;
-import org.eclipse.persistence.queries.ObjectBuildingQuery;
-import org.eclipse.persistence.queries.ReadObjectQuery;
-import org.eclipse.persistence.queries.ReadQuery;
-import org.eclipse.persistence.queries.ReportQuery;
-
-/**
- * The class processes query hints.
- * 
- * TopLink query hints and their values defined in org.eclipse.persistence.jpa.config package.
- * 
- * To add a new query hint:
- *   Define a new hint in EclipseLinkQueryHints;
- *   Add a class containing hint's values if required to config package (like CacheUsage);
- *      Alternatively values defined in HintValues may be used - Refresh and BindParameters hints do that.
- *   Add an inner class to this class extending Hint corresponding to the new hint (like CacheUsageHint);
- *      The first constructor parameter is hint name; the second is default value;
- *      In constructor 
- *          provide 2-dimensional value array in case the values should be translated (currently all Hint classes do that);
- *              in case translation is not required provide a single-dimension array (no such examples yet).
- *   In inner class Hint static initializer addHint an instance of the new hint class (like addHint(new CacheUsageHint())).
- * 
- * @see EclipseLinkQueryHints
- * @see HintValues
- * @see CacheUsage
- * @see PessimisticLock
- */
-public class QueryHintsHandler {
-    
-    /**
-     * Verifies the hints.
-     * 
-     * If session != null then logs a FINEST message for each hint.
-     * queryName parameter used only for identifying the query in messages,
-     * if it's null then "null" will be used.
-     * Throws IllegalArgumentException in case the hint value is illegal.
-     */
-    public static void verify(Map hints, String queryName, AbstractSession session) {
-        if(hints == null) {
-            return;
-        }
-        Iterator it = hints.entrySet().iterator();
-        while(it.hasNext()) {
-            Map.Entry entry = (Map.Entry)it.next();
-            String hintName = (String)entry.getKey();
-            verify(hintName, entry.getValue(), queryName, session);
-        }
-    }
-    
-    /**
-     * Verifies the hint.
-     * 
-     * If session != null then logs a FINEST message.
-     * queryName parameter used only for identifying the query in messages,
-     * if it's null then "null" will be used.
-     * Throws IllegalArgumentException in case the hint value is illegal.
-     */
-    public static void verify(String hintName, Object hintValue, String queryName, AbstractSession session) {
-        Hint.verify(hintName, shouldUseDefault(hintValue), hintValue, queryName, session);
-    }
-    
-    /**
-     * Applies the hints to the query.
-     * Throws IllegalArgumentException in case the hint value is illegal.
-     */
-    public static DatabaseQuery apply(Map hints, DatabaseQuery query) {
-        if (hints == null) {
-            return query;
-        }
-        DatabaseQuery hintQuery = query;
-        Iterator iterator = hints.entrySet().iterator();
-        while(iterator.hasNext()) {
-            Map.Entry entry = (Map.Entry)iterator.next();
-            String hintName = (String)entry.getKey();
-            hintQuery = apply(hintName, entry.getValue(), hintQuery);
-        }
-        return hintQuery;
-    }
-    
-    /**
-     * Applies the hint to the query.
-     * Throws IllegalArgumentException in case the hint value is illegal.
-     */
-    public static DatabaseQuery apply(String hintName, Object hintValue, DatabaseQuery query) {
-        return Hint.apply(hintName, shouldUseDefault(hintValue), hintValue, query);
-    }
-    
-    /**
-     * Empty String hintValue indicates that the default hint value
-     * should be used.
-     */
-    protected static boolean shouldUseDefault(Object hintValue) {
-        return (hintValue != null) &&  (hintValue instanceof String) && (((String)hintValue).length() == 0);
-    }
-    
-    /**
-     * Define a generic Hint.
-     * Hints should subclass this and override the applyToDatabaseQuery and set the valueArray.
-     */
-    protected static abstract class Hint {
-        static HashMap mainMap = new HashMap();
-        Object[] valueArray;
-        HashMap valueMap;
-        String name;
-        String defaultValue;
-        Object defaultValueToApply;
-        boolean valueToApplyMayBeNull;
-        
-        static {
-            addHint(new BindParametersHint());
-            addHint(new CacheUsageHint());
-            addHint(new QueryTypeHint());
-            addHint(new PessimisticLockHint());
-            addHint(new RefreshHint());
-            addHint(new BatchHint());
-            addHint(new FetchHint());
-            addHint(new ReturnSharedHint());
-            addHint(new JDBCTimeoutHint());
-            addHint(new JDBCFetchSizeHint());
-            addHint(new JDBCMaxRowsHint());
-            addHint(new ResultCollectionTypeHint());
-        }
-        
-        Hint(String name, String defaultValue) {
-            this.name = name;
-            this.defaultValue = defaultValue;
-        }
-
-        abstract DatabaseQuery applyToDatabaseQuery(Object valueToApply, DatabaseQuery query);
-                
-        static void verify(String hintName, boolean shouldUseDefault, Object hintValue, String queryName, AbstractSession session) {
-            Hint hint = (Hint)mainMap.get(hintName);
-            if(hint == null) {
-                if(session != null) {
-                    session.log(SessionLog.FINEST, SessionLog.QUERY, "unknown_query_hint", new Object[]{getPrintValue(queryName), hintName});
-                }
-                return;
-            }
-                                    
-            hint.verify(hintValue, shouldUseDefault, queryName, session);
-        }
-        
-        void verify(Object hintValue, boolean shouldUseDefault, String queryName, AbstractSession session) {
-            if(shouldUseDefault) {
-                hintValue = defaultValue;
-            }
-            if(session != null) {
-                session.log(SessionLog.FINEST, SessionLog.QUERY, "query_hint", new Object[]{getPrintValue(queryName), name, getPrintValue(hintValue)});
-            }
-            if(!shouldUseDefault && valueMap != null && !valueMap.containsKey(getUpperCaseString(hintValue))) {
-                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-wrong-query-hint-value",new Object[]{getPrintValue(queryName), name, getPrintValue(hintValue)}));
-            }
-        }
-        
-        static DatabaseQuery apply(String hintName, boolean shouldUseDefault, Object hintValue, DatabaseQuery query) {
-            Hint hint = (Hint)mainMap.get(hintName);
-            if (hint == null) {
-                // unknown hint name - silently ignored.
-                return query;
-            }
-            
-            return hint.apply(hintValue, shouldUseDefault, query);
-        }
-        
-        DatabaseQuery apply(Object hintValue, boolean shouldUseDefault, DatabaseQuery query) {
-            Object valueToApply = hintValue;
-            if(shouldUseDefault) {
-                valueToApply = defaultValueToApply;
-            } else {
-                if(valueMap != null) {
-                    String key = getUpperCaseString(hintValue);
-                    valueToApply = valueMap.get(key);
-                    if(valueToApply == null) {
-                        boolean wrongKey = true;
-                        if(valueToApplyMayBeNull) {
-                            wrongKey = !valueMap.containsKey(key);
-                        }
-                        if(wrongKey) {
-                            throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-wrong-query-hint-value",new Object[]{getQueryId(query), name, getPrintValue(hintValue)}));
-                        }
-                    }
-                }
-            }
-            return applyToDatabaseQuery(valueToApply, query);
-        }
-
-        static String getQueryId(DatabaseQuery query) {
-            String queryId = query.getName();
-            if(queryId == null) {
-                queryId = query.getEJBQLString();
-            }
-            return getPrintValue(queryId);
-        }
-        
-        static String getPrintValue(Object hintValue) {
-            return hintValue != null ? hintValue.toString() : "null";
-        }
-    
-        static String getUpperCaseString(Object hintValue) {
-            return hintValue != null ? hintValue.toString().toUpperCase() : null;
-        }
-
-        void initialize() {
-            if(valueArray != null) {
-                valueMap = new HashMap(valueArray.length);
-                if(valueArray instanceof Object[][]) {
-                    Object[][] valueArray2 = (Object[][])valueArray;
-                    for(int i=0; i<valueArray2.length; i++) {
-                        valueMap.put(getUpperCaseString(valueArray2[i][0]), valueArray2[i][1]);
-                        if(valueArray2[i][1] == null) {
-                            valueToApplyMayBeNull = true;
-                        }
-                    }
-                } else {
-                    for(int i=0; i<valueArray.length; i++) {
-                        valueMap.put(getUpperCaseString(valueArray[i]), valueArray[i]);
-                        if(valueArray[i] == null) {
-                            valueToApplyMayBeNull = true;
-                        }
-                    }
-                }
-                defaultValueToApply = valueMap.get(defaultValue.toUpperCase());
-            }
-        }
-        
-        static void addHint(Hint hint) {
-            hint.initialize();
-            mainMap.put(hint.name, hint);
-        }
-    }
-
-    protected static class BindParametersHint extends Hint {
-        BindParametersHint() {
-            super(EclipseLinkQueryHints.BIND_PARAMETERS, HintValues.PERSISTENCE_UNIT_DEFAULT);
-            valueArray = new Object[][] { 
-                {HintValues.PERSISTENCE_UNIT_DEFAULT, null},
-                {HintValues.TRUE, Boolean.TRUE},
-                {HintValues.FALSE, Boolean.FALSE}
-            };
-        }
-    
-        DatabaseQuery applyToDatabaseQuery(Object valueToApply, DatabaseQuery query) {
-            if (valueToApply == null) {
-                query.ignoreBindAllParameters();
-            } else {
-                query.setShouldBindAllParameters(((Boolean)valueToApply).booleanValue());
-            }
-            return query;
-        }
-    }
-
-    /**
-     * Configure the cache usage of the query.
-     * As many of the usages require a ReadObjectQuery, the hint may also require to change the query type.
-     */
-    protected static class CacheUsageHint extends Hint {
-        CacheUsageHint() {
-            super(EclipseLinkQueryHints.CACHE_USAGE, CacheUsage.DEFAULT);
-            valueArray = new Object[][] {
-                {CacheUsage.UseEntityDefault, ObjectLevelReadQuery.UseDescriptorSetting},
-                {CacheUsage.DoNotCheckCache, ObjectLevelReadQuery.DoNotCheckCache},
-                {CacheUsage.CheckCacheByExactPrimaryKey, ObjectLevelReadQuery.CheckCacheByExactPrimaryKey},
-                {CacheUsage.CheckCacheByPrimaryKey, ObjectLevelReadQuery.CheckCacheByPrimaryKey},
-                {CacheUsage.CheckCacheThenDatabase, ObjectLevelReadQuery.CheckCacheThenDatabase},
-                {CacheUsage.CheckCacheOnly, ObjectLevelReadQuery.CheckCacheOnly},
-                {CacheUsage.ConformResultsInUnitOfWork, ObjectLevelReadQuery.ConformResultsInUnitOfWork}
-            };
-        }
-    
-        DatabaseQuery applyToDatabaseQuery(Object valueToApply, DatabaseQuery query) {
-            if (query.isObjectLevelReadQuery()) {
-                int cacheUsage = ((Integer)valueToApply).intValue();
-                ((ObjectLevelReadQuery)query).setCacheUsage(cacheUsage);
-                if (cacheUsage == ObjectLevelReadQuery.CheckCacheByExactPrimaryKey
-                        || cacheUsage == ObjectLevelReadQuery.CheckCacheByPrimaryKey
-                        || cacheUsage == ObjectLevelReadQuery.CheckCacheThenDatabase) {
-                    ReadObjectQuery newQuery = new ReadObjectQuery();
-                    newQuery.copyFromQuery(query);
-                    return newQuery;
-                }
-            }
-            return query;
-        }
-    }
-
-    /**
-     * Configure the type of the query.
-     */
-    protected static class QueryTypeHint extends Hint {
-        QueryTypeHint() {
-            super(EclipseLinkQueryHints.QUERY_TYPE, QueryType.DEFAULT);
-            valueArray = new Object[][] {
-                {QueryType.Auto, QueryType.Auto},
-                {QueryType.ReadAll, QueryType.ReadAll},
-                {QueryType.ReadObject, QueryType.ReadObject},
-                {QueryType.Report, QueryType.Report}
-            };
-        }
-    
-        DatabaseQuery applyToDatabaseQuery(Object valueToApply, DatabaseQuery query) {
-            if (query.isObjectLevelReadQuery()) {
-                if (valueToApply == QueryType.ReadAll) {
-                    ReadAllQuery newQuery = new ReadAllQuery();
-                    newQuery.copyFromQuery(query);
-                    return newQuery;
-                } else if (valueToApply == QueryType.ReadObject) {
-                    ReadObjectQuery newQuery = new ReadObjectQuery();
-                    newQuery.copyFromQuery(query);
-                    return newQuery;
-                } else if (valueToApply == QueryType.Report) {
-                    ReportQuery newQuery = new ReportQuery();
-                    newQuery.copyFromQuery(query);
-                    return newQuery;
-                }
-            }
-            return query;
-        }
-    }
-    
-    protected static class PessimisticLockHint extends Hint {
-        PessimisticLockHint() {
-            super(EclipseLinkQueryHints.PESSIMISTIC_LOCK, PessimisticLock.DEFAULT);
-            valueArray = new Object[][] {
-                {PessimisticLock.NoLock, ObjectLevelReadQuery.NO_LOCK},
-                {PessimisticLock.Lock, ObjectLevelReadQuery.LOCK},
-                {PessimisticLock.LockNoWait, ObjectLevelReadQuery.LOCK_NOWAIT}
-            };
-        }
-    
-        DatabaseQuery applyToDatabaseQuery(Object valueToApply, DatabaseQuery query) {
-            if (query.isObjectBuildingQuery()) {
-                ((ObjectBuildingQuery)query).setLockMode(((Short)valueToApply).shortValue());
-            }
-            return query;
-        }
-    }
-
-    protected static class RefreshHint extends Hint {
-        RefreshHint() {
-            super(EclipseLinkQueryHints.REFRESH, HintValues.FALSE);
-            valueArray = new Object[][] { 
-                {HintValues.FALSE, Boolean.FALSE},
-                {HintValues.TRUE, Boolean.TRUE}
-            };
-        }
-    
-        DatabaseQuery applyToDatabaseQuery(Object valueToApply, DatabaseQuery query) {
-            if (query.isObjectBuildingQuery()) {
-                ((ObjectBuildingQuery)query).setShouldRefreshIdentityMapResult(((Boolean)valueToApply).booleanValue());
-            }
-            return query;
-        }
-    }
-    
-    protected static class BatchHint extends Hint {
-        BatchHint() {
-            super(EclipseLinkQueryHints.BATCH, "");
-        }
-    
-        DatabaseQuery applyToDatabaseQuery(Object valueToApply, DatabaseQuery query) {
-            if (query.isReadAllQuery() && !query.isReportQuery()) {
-                ReadAllQuery raq = (ReadAllQuery)query;
-                StringTokenizer tokenizer = new StringTokenizer((String)valueToApply, ".");
-                if (tokenizer.countTokens() < 2){
-                    throw QueryException.queryHintDidNotContainEnoughTokens(query, EclipseLinkQueryHints.FETCH, valueToApply);
-                }
-                // ignore the first token since we are assuming read all query
-                // e.g. In e.phoneNumbers we will assume "e" refers to the base of the query
-                String previousToken = tokenizer.nextToken();
-                ClassDescriptor descriptor = raq.getDescriptor();
-                Expression expression = raq.getExpressionBuilder();
-                while (tokenizer.hasMoreTokens()){
-                    String token = tokenizer.nextToken();
-                    ForeignReferenceMapping frMapping = null;
-                    DatabaseMapping mapping = descriptor.getMappingForAttributeName(token);
-                    if (mapping == null){
-                        throw QueryException.queryHintNavigatedNonExistantRelationship(query, EclipseLinkQueryHints.BATCH, valueToApply, previousToken + "." + token);
-                    } else if (!mapping.isForeignReferenceMapping()){
-                        throw QueryException.queryHintNavigatedIllegalRelationship(query, EclipseLinkQueryHints.BATCH, valueToApply, previousToken + "." + token);
-                    } else {
-                        frMapping = (ForeignReferenceMapping)mapping;
-                    }
-                    descriptor = frMapping.getReferenceDescriptor();
-                    if (frMapping.isCollectionMapping()){
-                        expression = expression.anyOf(token);
-                    } else {
-                        expression = expression.get(token);
-                    }
-                    previousToken = token;
-                }
-                raq.addBatchReadAttribute(expression);
-            } else {
-                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-wrong-type-for-query-hint",new Object[]{getQueryId(query), name, getPrintValue(valueToApply)}));
-            }
-            return query;
-        }
-    }
-    
-    protected static class FetchHint extends Hint {
-        FetchHint() {
-            super(EclipseLinkQueryHints.FETCH, "");
-        }
-    
-        DatabaseQuery applyToDatabaseQuery(Object valueToApply, DatabaseQuery query) {
-            if (query.isObjectLevelReadQuery() && !query.isReportQuery()) {
-                ObjectLevelReadQuery olrq = (ObjectLevelReadQuery)query;
-                StringTokenizer tokenizer = new StringTokenizer((String)valueToApply, ".");
-                if (tokenizer.countTokens() < 2){
-                    throw QueryException.queryHintDidNotContainEnoughTokens(query, EclipseLinkQueryHints.BATCH, valueToApply);
-                }
-                // ignore the first token since we are assuming read all query
-                // e.g. In e.phoneNumbers we will assume "e" refers to the base of the query
-                String previousToken = tokenizer.nextToken();
-                ClassDescriptor descriptor = olrq.getDescriptor();
-                Expression expression = olrq.getExpressionBuilder();
-                while (tokenizer.hasMoreTokens()){
-                    String token = tokenizer.nextToken();
-                    ForeignReferenceMapping frMapping = null;
-                    DatabaseMapping mapping = descriptor.getMappingForAttributeName(token);
-                    if (mapping == null){
-                        throw QueryException.queryHintNavigatedNonExistantRelationship(query, EclipseLinkQueryHints.BATCH, valueToApply, previousToken + "." + token);
-                    } else if (!mapping.isForeignReferenceMapping()){
-                        throw QueryException.queryHintNavigatedIllegalRelationship(query, EclipseLinkQueryHints.BATCH, valueToApply, previousToken + "." + token);
-                    } else {
-                        frMapping = (ForeignReferenceMapping)mapping;
-                    }
-                    descriptor = frMapping.getReferenceDescriptor();
-                    if (frMapping.isCollectionMapping()){
-                        expression = expression.anyOf(token);
-                    } else {
-                        expression = expression.get(token);
-                    }
-                    previousToken = token;
-                }
-                olrq.addJoinedAttribute(expression);
-            } else {
-                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-wrong-type-for-query-hint",new Object[]{getQueryId(query), name, getPrintValue(valueToApply)}));
-            }
-            return query;
-        }
-    }
-
-    protected static class ReturnSharedHint extends Hint {
-        ReturnSharedHint() {
-            super(EclipseLinkQueryHints.RETURN_SHARED, HintValues.FALSE);
-            valueArray = new Object[][] { 
-                {HintValues.FALSE, Boolean.FALSE},
-                {HintValues.TRUE, Boolean.TRUE}
-            };
-        }
-    
-        DatabaseQuery applyToDatabaseQuery(Object valueToApply, DatabaseQuery query) {
-            if (query.isObjectLevelReadQuery()) {
-                ((ObjectLevelReadQuery)query).setIsReadOnly(((Boolean)valueToApply).booleanValue());
-            } else {
-                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-wrong-type-for-query-hint",new Object[]{getQueryId(query), name, getPrintValue(valueToApply)}));
-            }
-            return query;
-        }
-    }
-    
-    protected static class JDBCTimeoutHint extends Hint {
-        JDBCTimeoutHint() {
-            super(EclipseLinkQueryHints.JDBC_TIMEOUT, "");
-        }
-    
-        DatabaseQuery applyToDatabaseQuery(Object valueToApply, DatabaseQuery query) {
-            try {
-                query.setQueryTimeout(Integer.parseInt(valueToApply.toString()));
-            } catch (NumberFormatException e) {
-                throw QueryException.queryHintContainedInvalidIntegerValue(EclipseLinkQueryHints.JDBC_TIMEOUT,valueToApply,e);
-            }
-            return query;
-        }
-    }
-    
-    protected static class JDBCFetchSizeHint extends Hint {
-        JDBCFetchSizeHint() {
-            super(EclipseLinkQueryHints.JDBC_FETCH_SIZE, "");
-        }
-    
-        DatabaseQuery applyToDatabaseQuery(Object valueToApply, DatabaseQuery query) {
-            if (query.isReadQuery()) {
-                try {
-                    ((ReadQuery)query).setFetchSize(Integer.parseInt(valueToApply.toString()));
-                } catch (NumberFormatException e) {
-                    throw QueryException.queryHintContainedInvalidIntegerValue(EclipseLinkQueryHints.JDBC_FETCH_SIZE,valueToApply,e);
-                }
-            } else {
-                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-wrong-type-for-query-hint",new Object[]{getQueryId(query), name, getPrintValue(valueToApply)}));
-            }
-            return query;
-        }
-    }
-    
-    protected static class JDBCMaxRowsHint extends Hint {
-        JDBCMaxRowsHint() {
-            super(EclipseLinkQueryHints.JDBC_MAX_ROWS, "");
-        }
-    
-        DatabaseQuery applyToDatabaseQuery(Object valueToApply, DatabaseQuery query) {
-            if (query.isReadQuery()) {
-                try {
-                    ((ReadQuery)query).setMaxRows(Integer.parseInt(valueToApply.toString()));
-                } catch (NumberFormatException e) {
-                    throw QueryException.queryHintContainedInvalidIntegerValue(EclipseLinkQueryHints.JDBC_MAX_ROWS,valueToApply,e);
-                }
-            } else {
-                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-wrong-type-for-query-hint",new Object[]{getQueryId(query), name, getPrintValue(valueToApply)}));
-            }
-            return query;
-        }
-    }
-    
-    protected static class ResultCollectionTypeHint extends Hint {
-        ResultCollectionTypeHint() {
-            super(EclipseLinkQueryHints.RESULT_COLLECTION_TYPE, "");
-        }
-    
-        DatabaseQuery applyToDatabaseQuery(Object valueToApply, DatabaseQuery query) {
-            if (query.isReadAllQuery()) {
-                Class collectionClass = null;
-                if (valueToApply instanceof String) {
-                    try {
-                        // TODO: This is not using the correct classloader.
-                        if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
-                            try {
-                                collectionClass = (Class)AccessController.doPrivileged(new PrivilegedClassForName((String)valueToApply));
-                            } catch (PrivilegedActionException exception) {
-                                throw QueryException.classNotFoundWhileUsingQueryHint(query, valueToApply, exception.getException());
-                            }
-                        } else {
-                            collectionClass = PrivilegedAccessHelper.getClassForName((String)valueToApply);
-                        }
-                    } catch (ClassNotFoundException exc){
-                        throw QueryException.classNotFoundWhileUsingQueryHint(query, valueToApply, exc);
-                    }
-                } else {
-                    collectionClass = (Class)valueToApply;
-                }
-                ((ReadAllQuery)query).useCollectionClass(collectionClass);
-            } else {
-                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-wrong-type-for-query-hint",new Object[]{getQueryId(query), name, getPrintValue(valueToApply)}));
-            }
-            return query;
-        }
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/PropertiesHandler.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/PropertiesHandler.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/base/PropertiesHandler.java	(working copy)
@@ -1,503 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- *     Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/  
-package org.eclipse.persistence.internal.jpa.base;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import java.util.logging.Level;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import org.eclipse.persistence.jpa.config.*;
-import org.eclipse.persistence.internal.localization.ExceptionLocalization;
-import org.eclipse.persistence.internal.sessions.AbstractSession;
-import org.eclipse.persistence.logging.SessionLog;
-
-/**
- * 
- * The class processes some of TopLink properties.
- * The class may be used for any properties, but it only makes sense 
- * to use it in the following two cases:
- *      1. There is a set of legal values defined
- *          either requiring translation (like CacheTypeProp);
- *          or not (like LoggingLevelProp).
- *      2. Property is really a prefix from which the property obtained by 
- *      appending entity or class name (like DescriptorCustomizerProp -
- *      it corresponds to "eclipselink.descriptor.customizer." prefix that allows to
- *      define propereties like "eclipselink.descriptor.customizer.myPackage.MyClass"). 
- * 
- * TopLink properties and their values defined in org.eclipse.persistence.jpa.config package.
- * 
- * To add a new property:
- *   Define a new property in PersistenceUnitProperties;
- *   Add a class containing property's values if required to config package (like CacheType);
- *      Alternatively values may be already defined elsewhere (like in LoggingLevelProp).
- *   Add an inner class to this class extending Prop corresponding to the new property (like CacheTypeProp);
- *      The first constructor parameter is property name; the second is default value;
- *      In constructor 
- *          provide 2-dimensional value array in case the values should be translated (like CacheTypeProp);
- *              in case translation is not required provide a single-dimension array (like LoggingLevelProp).
- *   In inner class Prop static initializer addProp an instance of the new prop class (like addProp(new CacheTypeProp())).
- * 
- * @see PersistenceUnitProperties
- * @see CacheType
- * @see TargetDatabase
- * @see TargetServer
- * 
- */
-public class PropertiesHandler {
-    
-    /**
-     * INTERNAL:
-     * Gets property value from the map, if none found looks in System properties.
-     * Use this to get a value for a non-prefixed property.
-     * Could be used on prefixes (like "org.eclipse.persistence.cache-type.") too,
-     * but will always return null
-     * Throws IllegalArgumentException in case the property value is illegal.
-     */
-    public static String getPropertyValueLogDebug(String name, Map m, AbstractSession session) {
-        return Prop.getPropertyValueToApply(name, m, session);
-    }
-    
-    /**
-     * INTERNAL:
-     * Gets property value from the map, if none found looks in System properties.
-     * Use this to get a value for a prefixed property:
-     * for "org.eclipse.persistence.cache-type.Employee"
-     * pass "org.eclipse.persistence.cache-type.", "Employee".
-     * Throws IllegalArgumentException in case the property value is illegal.
-     */
-    public static String getPrefixedPropertyValue(String prefix, String suffix, Map m) {
-        return (String)getPrefixValues(prefix, m).get(suffix);
-    }
-
-    /**
-     * INTERNAL:
-     * Gets properties' values from the map, if none found looks in System properties.
-     * In the returned map values keyed by suffixes.
-     * Use it with prefixes (like "org.eclipse.persistence.cache-type.").
-     * Could be used on simple properties (not prefixes, too),
-     * but will always return either an empty map or a map containing a single 
-     * value keyed by an empty String.
-     * Throws IllegalArgumentException in case the property value is illegal.
-     */
-    public static Map getPrefixValues(String prefix, Map m) {
-        return Prop.getPrefixValuesToApply(prefix, m, null);
-    }
-    
-    public static Map getPrefixValuesLogDebug(String prefix, Map m, AbstractSession session) {
-        return Prop.getPrefixValuesToApply(prefix, m, session);
-    }
-    
-    /**
-     * INTERNAL:
-     * Returns the default property value that should be applied.
-     * Throws IllegalArgumentException in case the name doesn't correspond
-     * to any property.
-     */
-    public static String getDefaultPropertyValue(String name) {
-        return Prop.getDefaultPropertyValueToApply(name, null);
-    }
-    
-    public static String getDefaultPropertyValueLogDebug(String name, AbstractSession session) {
-        return Prop.getDefaultPropertyValueToApply(name, session);
-    }
-    
-    /**
-     * INTERNAL:
-     * Empty String value indicates that the default property value
-     * should be used.
-     */
-    protected static boolean shouldUseDefault(String value) {
-        return value != null &&  value.length() == 0;
-    }
-    
-    protected static abstract class Prop {
-        static HashMap mainMap = new HashMap();
-        Object[] valueArray;
-        HashMap valueMap;
-        String name;
-        String defaultValue;
-        String defaultValueToApply;
-        boolean valueToApplyMayBeNull;
-        boolean shouldReturnOriginalValueIfValueToApplyNotFound;
-        
-        static {
-            addProp(new LoggerTypeProp());
-            addProp(new LoggingLevelProp());
-            addProp(new TargetDatabaseProp());
-            addProp(new TargetServerProp());
-            addProp(new CacheSizeProp());
-            addProp(new CacheTypeProp());
-            addProp(new CacheSharedProp());
-            addProp(new DescriptorCustomizerProp());
-            addProp(new BatchWritingProp());
-        }
-        
-        Prop(String name) {
-            this.name = name;
-        }
-        
-        Prop(String name, String defaultValue) {
-            this(name);
-            this.defaultValue = defaultValue;
-        }
-
-        static String getPropertyValueFromMap(String name, Map m) {
-            String value = (String)m.get(name);
-            return value == null ? System.getProperty(name) : value;
-        }
-    
-        // Collect all entries corresponding to the prefix name.
-        // Note that entries from Map m override those from System properties.
-        static Map getPrefixValuesFromMap(String name, Map m) {
-            Map mapOut = new HashMap();
-            
-            Iterator it = (Iterator)AccessController.doPrivileged(
-                new PrivilegedAction() {
-                    public Object run() {
-                        return System.getProperties().entrySet().iterator();
-                    }    
-                }
-            );
-
-            while(it.hasNext()) {
-                Map.Entry entry = (Map.Entry)it.next();
-                String str = (String)entry.getKey();
-                if(str.startsWith(name)) {
-                    String entityName = str.substring(name.length(), str.length());
-                    mapOut.put(entityName, entry.getValue());
-                }
-            }
-            
-            it = m.entrySet().iterator();
-            while(it.hasNext()) {
-                Map.Entry entry = (Map.Entry)it.next();
-                String str = (String)entry.getKey();
-                if(str.startsWith(name)) {
-                    String entityName = str.substring(name.length(), str.length());
-                    mapOut.put(entityName, entry.getValue());
-                }
-            }
-            
-            return mapOut;
-        }
-    
-        static String getPropertyValue(String name, boolean shouldUseDefault, Map m, AbstractSession session) {
-            Prop prop = (Prop)mainMap.get(name);
-            if(prop == null) {
-                // it's not our property
-                return null; 
-            }
-            String value = (String)getPropertyValueFromMap(name, m);
-            if(value == null) {
-                return null;
-            }
-            return prop.getValueToApply(value, shouldUseDefault, session);
-        }
-                
-        static String getPropertyValueToApply(String name, Map m, AbstractSession session) {
-            Prop prop = (Prop)mainMap.get(name);
-            if(prop == null) {
-                return null; 
-            }
-            String value = (String)getPropertyValueFromMap(name, m);
-            if(value == null) {
-                return null;
-            }
-            return prop.getValueToApply(value, shouldUseDefault(value), session);
-        }
-                
-        static Map getPrefixValuesToApply(String prefix, Map m, AbstractSession session) {
-            Prop prop = (Prop)mainMap.get(prefix);
-            if(prop == null) {
-                // prefix doesn't correspond to a Prop object - it's not our property.
-                return new HashMap(0); 
-            }
-            
-            // mapps suffixes to property values
-            Map mapIn = (Map)getPrefixValuesFromMap(prefix, m);
-            if(mapIn.isEmpty()) {
-                return mapIn;
-            }
-            
-            HashMap mapOut = new HashMap(mapIn.size());
-            Iterator it = mapIn.entrySet().iterator();
-            while(it.hasNext()) {
-                Map.Entry entry = (Map.Entry)it.next();
-                String suffix = (String)entry.getKey();
-                String value = (String)entry.getValue();
-                mapOut.put(suffix, prop.getValueToApply(value, shouldUseDefault(value), suffix, session));
-            }
-            // mapps suffixes to valuesToApply
-            return mapOut;
-        }
-        
-        static String getDefaultPropertyValueToApply(String name, AbstractSession session) {
-            Prop prop = (Prop)mainMap.get(name);
-            if(prop == null) {
-                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-default-for-unknown-property", new Object[]{name}));
-            }
-            prop.logDefault(session);
-            return prop.defaultValueToApply;
-        }
-                
-        String getValueToApply(String value, boolean shouldUseDefault, AbstractSession session) {
-            return getValueToApply(value, shouldUseDefault, null, session);
-        }
-        
-        // suffix is used only for properties-prefixes (like CacheType)
-        String getValueToApply(String value, boolean shouldUseDefault, String suffix, AbstractSession session) {            
-            if(shouldUseDefault) {
-                logDefault(session, suffix);
-                return defaultValueToApply;
-            }
-            String valueToApply = value;
-            if(valueMap != null) {
-                String key = getUpperCaseString(value);
-                valueToApply = (String)valueMap.get(key);
-                if(valueToApply == null) {
-                    boolean notFound = true;
-                    if(valueToApplyMayBeNull) {
-                        notFound = !valueMap.containsKey(key);
-                    }
-                    if(notFound) {
-                        if(shouldReturnOriginalValueIfValueToApplyNotFound) {
-                            valueToApply = value;
-                        } else {
-                            String propertyName = name;
-                            if(suffix != null) {
-                                propertyName = propertyName + suffix;
-                            }
-                            throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-illegal-property-value", new Object[]{propertyName, getPrintValue(value)}));
-                        }
-                    }
-                }
-            }
-            String logValue = PersistenceUnitProperties.getOverriddenLogStringForProperty(name);
-            if (logValue != null){
-                log(session, logValue, logValue, suffix);
-            } else {
-                log(session, value, valueToApply, suffix);
-            }
-            return valueToApply;
-        }
-
-        static String getUpperCaseString(String value) {
-            if(value != null) {
-                return value.toUpperCase();
-            } else {
-                return null;
-            }
-        }
-        static String getPrintValue(String value) {
-            if(value != null) {
-                return value;
-            } else {
-                return "null";
-            }
-        }
-        void initialize() {
-            if(valueArray != null) {
-                valueMap = new HashMap(valueArray.length);
-                if(valueArray instanceof Object[][]) {
-                    Object[][] valueArray2 = (Object[][])valueArray;
-                    for(int i=0; i<valueArray2.length; i++) {
-                        valueMap.put(getUpperCaseString((String)valueArray2[i][0]), valueArray2[i][1]);
-                        if(valueArray2[i][1] == null) {
-                            valueToApplyMayBeNull = true;
-                        }
-                    }
-                } else {
-                    for(int i=0; i<valueArray.length; i++) {
-                        valueMap.put(getUpperCaseString((String)valueArray[i]), valueArray[i]);
-                        if(valueArray[i] == null) {
-                            valueToApplyMayBeNull = true;
-                        }
-                    }
-                }
-                defaultValueToApply = (String)valueMap.get(getUpperCaseString(defaultValue));
-            } else {
-                defaultValueToApply = defaultValue;
-            }
-        }
-
-        void logDefault(AbstractSession session) {
-            logDefault(session, null);
-        }
-        
-        void logDefault(AbstractSession session, String suffix) {
-            if(session != null) {
-                String propertyName = name;
-                if(suffix != null) {
-                    propertyName = propertyName + suffix;
-                }
-                if(defaultValue != defaultValueToApply) {
-                    session.log(SessionLog.FINEST, SessionLog.PROPERTIES, "handler_property_value_default", new Object[]{propertyName, defaultValue, defaultValueToApply});
-                } else {
-                    session.log(SessionLog.FINEST, SessionLog.PROPERTIES, "property_value_default", new Object[]{propertyName, defaultValue});
-                }
-            }
-        }
-        
-        void log(AbstractSession session, String value, String valueToApply, String suffix) {
-            if(session != null) {
-                String propertyName = name;
-                if(suffix != null) {
-                    propertyName = propertyName + suffix;
-                }
-                if(value != valueToApply) {
-                    session.log(SessionLog.FINEST, SessionLog.PROPERTIES, "handler_property_value_specified", new Object[]{propertyName, value, valueToApply});
-                } else {
-                    session.log(SessionLog.FINEST, SessionLog.PROPERTIES, "property_value_specified", new Object[]{propertyName, value});
-                }
-            }
-        }
-        
-        static void addProp(Prop prop) {
-            prop.initialize();
-            mainMap.put(prop.name, prop);
-        }
-    }
-
-    protected static class LoggerTypeProp extends Prop {
-        LoggerTypeProp() {
-            super(PersistenceUnitProperties.LOGGING_LOGGER, LoggerType.DEFAULT);
-            this.shouldReturnOriginalValueIfValueToApplyNotFound = true;
-            String pcg = "org.eclipse.persistence.logging.";
-            valueArray = new Object[][] {
-                {LoggerType.DefaultLogger, pcg + "DefaultSessionLog"},
-                {LoggerType.JavaLogger, pcg + "JavaLog"}
-            };
-        }
-    }
-
-    protected static class LoggingLevelProp extends Prop {
-        LoggingLevelProp() {
-            super(PersistenceUnitProperties.LOGGING_LEVEL, Level.INFO.getName());
-            valueArray = new Object[] { 
-                Level.OFF.getName(),
-                Level.SEVERE.getName(),
-                Level.OFF.getName(),
-                Level.WARNING.getName(),
-                Level.INFO.getName(),
-                Level.CONFIG.getName(),
-                Level.FINE.getName(),
-                Level.FINER.getName(),
-                Level.FINEST.getName(),
-                Level.ALL.getName()
-            };
-        }
-    }
-
-    protected static class TargetDatabaseProp extends Prop {
-        TargetDatabaseProp() {
-            super(PersistenceUnitProperties.TARGET_DATABASE, TargetDatabase.DEFAULT);
-            this.shouldReturnOriginalValueIfValueToApplyNotFound = true;
-            String pcg = "org.eclipse.persistence.platform.database.";
-            valueArray = new Object[][] { 
-                {TargetDatabase.Auto, pcg + "DatabasePlatform"},
-                {TargetDatabase.Oracle, pcg + "oracle.OraclePlatform"},
-                {TargetDatabase.Oracle8, pcg + "oracle.Oracle8Platform"},
-                {TargetDatabase.Oracle9, pcg + "oracle.Oracle9Platform"},
-                {TargetDatabase.Oracle10, pcg + "oracle.Oracle10Platform"},
-                {TargetDatabase.Oracle11, pcg + "oracle.Oracle11Platform"},
-                {TargetDatabase.Attunity, pcg + "AttunityPlatform"},
-                {TargetDatabase.Cloudscape, pcg + "CloudscapePlatform"},
-                {TargetDatabase.Database, pcg + "DatabasePlatform"},
-                {TargetDatabase.DB2Mainframe, pcg + "DB2MainframePlatform"},
-                {TargetDatabase.DB2, pcg + "DB2Platform"},
-                {TargetDatabase.DBase, pcg + "DBasePlatform"},
-                {TargetDatabase.Derby, pcg + "DerbyPlatform"},
-                {TargetDatabase.HSQL, pcg + "HSQLPlatform"},
-                {TargetDatabase.Informix, pcg + "InformixPlatform"},
-                {TargetDatabase.JavaDB, pcg + "JavaDBPlatform"},
-                {TargetDatabase.MySQL4, pcg + "MySQL4Platform"},
-                {TargetDatabase.PointBase,  pcg + "PointBasePlatform"},
-                {TargetDatabase.PostgreSQL,  pcg + "PostgreSQLPlatform"},
-                {TargetDatabase.SQLAnyWhere,  pcg + "SQLAnyWherePlatform"},
-                {TargetDatabase.SQLServer,  pcg + "SQLServerPlatform"},
-                {TargetDatabase.Sybase,  pcg + "SybasePlatform"},
-                {TargetDatabase.TimesTen,  pcg + "TimesTenPlatform"}
-            };
-        }
-    }
-
-    protected static class TargetServerProp extends Prop {
-        TargetServerProp() {
-            super(PersistenceUnitProperties.TARGET_SERVER, TargetServer.DEFAULT);
-            this.shouldReturnOriginalValueIfValueToApplyNotFound = true;
-            String pcg = "org.eclipse.persistence.platform.server.";
-            valueArray = new Object[][] { 
-                {TargetServer.None, pcg + "NoServerPlatform"},
-                {TargetServer.OC4J, pcg + "oc4j.Oc4jPlatform"},
-                {TargetServer.OC4J_10_1_3, pcg + "oc4j.Oc4j_10_1_3_Platform"},
-                {TargetServer.OC4J_11_1_1, pcg + "oc4j.Oc4j_11_1_1_Platform"},
-                {TargetServer.SunAS9, pcg + "sunas.SunAS9ServerPlatform"},
-                {TargetServer.WebSphere, pcg + "was.WebSpherePlatform"},
-                {TargetServer.WebSphere_6_1, pcg + "was.WebSphere_6_1_Platform"},
-                {TargetServer.WebLogic, pcg + "wls.WebLogicPlatform"},
-                {TargetServer.WebLogic_9, pcg + "wls.WebLogic_9_Platform"},
-                {TargetServer.WebLogic_10, pcg + "wls.WebLogic_10_Platform"},
-                {TargetServer.JBoss, pcg + "jboss.JBossPlatform"}
-            };
-        }  
-    }
-
-    protected static class CacheSizeProp extends Prop {
-        CacheSizeProp() {
-            super(PersistenceUnitProperties.CACHE_SIZE_, Integer.toString(1000));
-        }  
-    }
-
-    protected static class CacheTypeProp extends Prop {
-        CacheTypeProp() {
-            super(PersistenceUnitProperties.CACHE_TYPE_, CacheType.DEFAULT);
-            String pcg = "org.eclipse.persistence.internal.identitymaps.";
-            valueArray = new Object[][] { 
-                {CacheType.Weak, pcg + "WeakIdentityMap"},
-                {CacheType.Soft, pcg + "SoftIdentityMap"},
-                {CacheType.SoftWeak, pcg + "SoftCacheWeakIdentityMap"},
-                {CacheType.HardWeak, pcg + "HardCacheWeakIdentityMap"},
-                {CacheType.Full, pcg + "FullIdentityMap"},
-                {CacheType.NONE, pcg + "NoIdentityMap"}
-            };
-        }
-    }
-
-    protected static class CacheSharedProp extends Prop {
-        CacheSharedProp() {
-            super(PersistenceUnitProperties.CACHE_SHARED_, "false");
-            valueArray = new Object[] { 
-                "true",
-                "false"
-            };
-        }  
-    }
-
-    protected static class DescriptorCustomizerProp extends Prop {
-        DescriptorCustomizerProp() {
-            super(PersistenceUnitProperties.DESCRIPTOR_CUSTOMIZER_);
-        }  
-    }
-
-    protected static class BatchWritingProp extends Prop {
-        BatchWritingProp() {
-            super(PersistenceUnitProperties.BATCH_WRITING, BatchWriting.DEFAULT);
-            valueArray = new Object[] { 
-                BatchWriting.None,
-                BatchWriting.JDBC,
-                BatchWriting.Buffered,
-                BatchWriting.OracleJDBC
-            };
-        }
-    }
-}
Index: C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/queries/EJBQLPlaceHolderQuery.java
===================================================================
--- C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/queries/EJBQLPlaceHolderQuery.java	(revision 3295)
+++ C:/Work/eclipse/eclipselink.jpa/src/org/eclipse/persistence/queries/EJBQLPlaceHolderQuery.java	(working copy)
@@ -13,7 +13,7 @@
 import org.eclipse.persistence.exceptions.DatabaseException;
 import org.eclipse.persistence.exceptions.OptimisticLockException;
 import java.util.HashMap;
-import org.eclipse.persistence.internal.jpa.base.EJBQueryImpl;
+import org.eclipse.persistence.internal.jpa.EJBQueryImpl;
 import org.eclipse.persistence.sessions.Session;
 
 

Back to the top