You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by da...@apache.org on 2007/01/30 20:36:40 UTC

svn commit: r501528 - in /incubator/openejb/trunk/openejb3: container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ container/openejb-core/src/main/java/org/apache/openejb/config/ container/openejb-core/src/main/java/org/apache/opene...

Author: dain
Date: Tue Jan 30 11:36:37 2007
New Revision: 501528

URL: http://svn.apache.org/viewvc?view=rev&rev=501528
Log:
Initial CMP to JPA converter (doesn't really work)
Added unmanaged data source to default OpenEJB configuration
Fixed bugs with unmanaged data sources
Added auto config and deploy for persistence unit data sources

Modified:
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/AppInfo.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Cmp2Builder.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PersistenceBuilder.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfigAndDeploy.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbModule.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/jpa/JpaCmpEngine.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/persistence/PersistenceUnitInfoImpl.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/resource/SharedLocalConnectionManager.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/resources/default.openejb.conf
    incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/RedeployTest.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/daytrader/daytrader-orm.xml
    incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/itest-2.2/itest-2.2-orm.xml
    incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/manytomany/simplepk/orm.xml
    incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/manytomany/simplepk/unidirectional-orm.xml
    incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetomany/simplepk/many-unidirectional-orm.xml
    incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetomany/simplepk/one-unidirectional-orm.xml
    incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetomany/simplepk/orm.xml
    incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetoone/simplepk/orm.xml
    incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetoone/simplepk/unidirectional-orm.xml
    incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/EntityBean.java
    incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/resources/geronimo-openejb-jaxb-test.xml
    incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml
    incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/persistence.xml

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/AppInfo.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/AppInfo.java?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/AppInfo.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/AppInfo.java Tue Jan 30 11:36:37 2007
@@ -28,4 +28,5 @@
     public final List<EjbJarInfo> ejbJars = new ArrayList<EjbJarInfo>();
     public final List<PersistenceUnitInfo> persistenceUnits = new ArrayList<PersistenceUnitInfo>();
     public final List<String> libs = new ArrayList<String>();
+    public String cmpMappingsXml;
 }

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Cmp2Builder.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Cmp2Builder.java?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Cmp2Builder.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Cmp2Builder.java Tue Jan 30 11:36:37 2007
@@ -18,22 +18,17 @@
 package org.apache.openejb.assembler.classic;
 
 import java.io.File;
-import java.io.IOException;
 import java.io.FileOutputStream;
-import java.util.jar.JarOutputStream;
-import java.util.jar.JarEntry;
+import java.io.IOException;
 import java.util.Set;
-import java.util.TreeSet;
-import java.util.List;
 import java.util.StringTokenizer;
-import java.util.ArrayList;
-import java.net.URL;
+import java.util.TreeSet;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
 
 import org.apache.openejb.core.TemporaryClassLoader;
 import org.apache.openejb.core.cmp.cmp2.Cmp2Generator;
 import org.apache.openejb.core.cmp.cmp2.CmrField;
-import org.apache.openejb.OpenEJB;
-import org.apache.openejb.OpenEJBException;
 
 public class Cmp2Builder {
     private final ClassLoader tempClassLoader;
@@ -66,6 +61,9 @@
                         generateClass(jarOutputStream, entityBeanInfo);
                     }
                 }
+            }
+            if (appInfo.cmpMappingsXml != null) {
+                addJarEntry(jarOutputStream, "META-INF/openejb-cmp-generated-orm.xml", appInfo.cmpMappingsXml.getBytes());
             }
         } catch (IOException e) {
             threwException = true;

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PersistenceBuilder.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PersistenceBuilder.java?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PersistenceBuilder.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PersistenceBuilder.java Tue Jan 30 11:36:37 2007
@@ -137,7 +137,7 @@
         String nonJta = info.nonJtaDataSource;
         if (nonJtaDataSourceEnv != null) nonJta = nonJtaDataSourceEnv;
         if (nonJta != null) {
-            DataSource nonJtaDataSource = dataSourceResolver.getDataSource(dataSource);
+            DataSource nonJtaDataSource = dataSourceResolver.getDataSource(nonJta);
             unitInfo.setNonJtaDataSource(nonJtaDataSource);
         }
 

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java Tue Jan 30 11:36:37 2007
@@ -30,6 +30,7 @@
     private final List<PersistenceModule> persistenceModules = new ArrayList<PersistenceModule>();;
     private final String jarLocation;
     private final ClassLoader classLoader;
+    public String cmpMappingsXml;
 
     public AppModule(ClassLoader classLoader, String jarLocation) {
         this.classLoader = classLoader;
@@ -58,5 +59,13 @@
 
     public List<URL> getAdditionalLibraries() {
         return additionalLibraries;
+    }
+
+    public String getCmpMappingsXml() {
+        return cmpMappingsXml;
+    }
+
+    public void setCmpMappingsXml(String cmpMappingsXml) {
+        this.cmpMappingsXml = cmpMappingsXml;
     }
 }

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfigAndDeploy.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfigAndDeploy.java?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfigAndDeploy.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfigAndDeploy.java Tue Jan 30 11:36:37 2007
@@ -28,6 +28,8 @@
 import org.apache.openejb.assembler.classic.ConnectorInfo;
 import org.apache.openejb.assembler.classic.ContainerInfo;
 import org.apache.openejb.jee.ResourceRef;
+import org.apache.openejb.jee.jpa.unit.Persistence;
+import org.apache.openejb.jee.jpa.unit.PersistenceUnit;
 import org.apache.openejb.util.Logger;
 import org.apache.openejb.util.Messages;
 import org.apache.openejb.util.SafeToolkit;
@@ -83,6 +85,9 @@
         for (ClientModule clientModule : appModule.getClientModules()) {
             deploy(clientModule);
         }
+        for (PersistenceModule persistenceModule : appModule.getPersistenceModules()) {
+            deploy(persistenceModule);
+        }
         contextData.clear();
         return appModule;
     }
@@ -244,6 +249,56 @@
         return ejbModule;
     }
 
+    public PersistenceModule deploy(PersistenceModule persistenceModule) throws OpenEJBException {
+        if (!autoCreateConnectors) {
+            return persistenceModule;
+        }
+
+        Persistence persistence = persistenceModule.getPersistence();
+        for (PersistenceUnit persistenceUnit : persistence.getPersistenceUnit()) {
+            String jtaDataSourceId = getDataSourceId(persistenceUnit.getJtaDataSource(), persistenceUnit);
+            if (jtaDataSourceId != null) {
+                persistenceUnit.setJtaDataSource("java:openejb/Connector/" + jtaDataSourceId);
+            }
+            String nonJtaDataSourceId = getDataSourceId(persistenceUnit.getNonJtaDataSource(), persistenceUnit);
+            if (nonJtaDataSourceId != null) {
+                persistenceUnit.setNonJtaDataSource("java:openejb/Connector/" + nonJtaDataSourceId);
+            }
+        }
+
+        return persistenceModule;
+    }
+
+    private String getDataSourceId(String dataSource, PersistenceUnit persistenceUnit) throws OpenEJBException {
+        if (dataSource.startsWith("java:comp/env")) {
+            dataSource = dataSource.substring("java:comp/env".length());
+        }
+
+        String id = null;
+        List<String> connectorMap = configFactory.getConnectorIds();
+        if (!connectorMap.contains(dataSource)) {
+            String name = dataSource.replaceFirst(".*/", "");
+            if (!connectorMap.contains(name)) {
+                String message = "No existing datasource found while attempting to Auto-link unmapped datasource '" + dataSource + "' for persistence-unit '" + persistenceUnit.getName() + "'.  Looked for Datasource(id=" + dataSource + ") and Datasource(id=" + name + ")";
+                if (!autoCreateConnectors){
+                    throw new OpenEJBException(message);
+                }
+
+                logger.error(message);
+
+                if (connectorMap.size() > 0) {
+                    id = connectorMap.get(0);
+                } else {
+                    ConnectorInfo connectorInfo = configFactory.configureService(ConnectorInfo.class);
+                    id = connectorInfo.id;
+                    logger.warning("Auto-creating a datasource with res-id " + id + " for persistence-unit '" + persistenceUnit.getName() + "'.  THERE IS LITTLE CHANCE THIS WILL WORK!");
+                    configFactory.install(connectorInfo);
+                }
+            }
+        }
+        return id;
+    }
+
     private static class Key {
         private final Query query;
 
@@ -288,7 +343,7 @@
     private List<Method> getFinderMethods(Class bean) {
 
         Method[] methods = bean.getMethods();
-        List<Method> finderMethods = new ArrayList();
+        List<Method> finderMethods = new ArrayList<Method>();
         for (int i = 0; i < methods.length; i++) {
             if (methods[i].getName().startsWith("find") && !methods[i].getName().equals("findByPrimaryKey")) {
                 finderMethods.add(methods[i]);

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java Tue Jan 30 11:36:37 2007
@@ -21,7 +21,11 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
+import java.util.ArrayList;
 import java.lang.reflect.Field;
+import java.net.URL;
+
+import javax.xml.bind.JAXBException;
 
 import org.apache.openejb.jee.CmpField;
 import org.apache.openejb.jee.EjbJar;
@@ -33,6 +37,7 @@
 import org.apache.openejb.jee.RelationshipRoleSource;
 import org.apache.openejb.jee.Relationships;
 import org.apache.openejb.jee.PersistenceContextRef;
+import org.apache.openejb.jee.CmpVersion;
 import org.apache.openejb.jee.jpa.EntityMappings;
 import org.apache.openejb.jee.jpa.Entity;
 import org.apache.openejb.jee.jpa.Attributes;
@@ -45,10 +50,78 @@
 import org.apache.openejb.jee.jpa.RelationField;
 import org.apache.openejb.jee.jpa.CascadeType;
 import org.apache.openejb.jee.jpa.Transient;
+import org.apache.openejb.jee.jpa.JpaJaxbUtil;
+import org.apache.openejb.jee.jpa.unit.Persistence;
+import org.apache.openejb.jee.jpa.unit.PersistenceUnit;
+import org.apache.openejb.jee.jpa.unit.TransactionType;
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.core.cmp.jpa.JpaCmpEngine;
+
+public class CmpJpaConversion implements DynamicDeployer {
+    private static final String CMP_PERSISTENCE_UNIT_NAME = "cmp";
+
+    public AppModule deploy(AppModule appModule) throws OpenEJBException {
+        // search for the cmp persistence unit
+        PersistenceUnit persistenceUnit = null;
+        for (PersistenceModule persistenceModule : appModule.getPersistenceModules()) {
+            Persistence persistence = persistenceModule.getPersistence();
+            for (PersistenceUnit unit : persistence.getPersistenceUnit()) {
+                if (CMP_PERSISTENCE_UNIT_NAME.equals(unit.getName())) {
+                    persistenceUnit = unit;
+                    break;
+                }
+
+            }
+        }
+
+        // todo scan existing persistence module for all entity mappings and don't generate mappings for them
+
+        // create mappings
+        EntityMappings cmpMappings = new EntityMappings();
+        cmpMappings.setVersion("1.0");
+        for (EjbModule ejbModule : appModule.getEjbModules()) {
+            EjbJar ejbJar = ejbModule.getEjbJar();
+            generateEntityMappings(ejbJar, appModule.getClassLoader(), cmpMappings);
+        }
+
+        if (!cmpMappings.getEntity().isEmpty()) {
+            // if not found create one
+            if (persistenceUnit == null) {
+                persistenceUnit = new PersistenceUnit();
+                persistenceUnit.setName(CMP_PERSISTENCE_UNIT_NAME);
+                persistenceUnit.setTransactionType(TransactionType.JTA);
+                persistenceUnit.setJtaDataSource("java:openejb/Connector/Default JDBC Database");
+                persistenceUnit.setNonJtaDataSource("java:openejb/Connector/Default JDBC Database");
+
+                Persistence persistence = new Persistence();
+                persistence.setVersion("1.0");
+                persistence.getPersistenceUnit().add(persistenceUnit);
+
+                PersistenceModule persistenceModule = new PersistenceModule(appModule.getJarLocation(), persistence);
+                appModule.getPersistenceModules().add(persistenceModule);
+            }
+            persistenceUnit.getMappingFile().add("META-INF/openejb-cmp-generated-orm.xml");
+            for (Entity entity : cmpMappings.getEntity()) {
+                persistenceUnit.getClazz().add(entity.getClazz());
+            }
+            try {
+                String cmpMappingsXml = JpaJaxbUtil.marshal(EntityMappings.class, cmpMappings);
+                appModule.setCmpMappingsXml(cmpMappingsXml);
+            } catch (JAXBException e) {
+                throw new OpenEJBException("Unable to marshal cmp entity mappings", e);
+            }
+        }
 
-public class CmpJpaConversion {
-    public EntityMappings generateEntityMappings(EjbJar ejbJar, ClassLoader classLoader) {
+        return appModule;
+    }
+
+    public EntityMappings generateEntityMappings(EjbJar ejbJar, ClassLoader classLoader) throws OpenEJBException {
         EntityMappings entityMappings = new EntityMappings();
+        generateEntityMappings(ejbJar, classLoader, entityMappings);
+        return entityMappings;
+    }
+
+    public void generateEntityMappings(EjbJar ejbJar, ClassLoader classLoader, EntityMappings entityMappings) throws OpenEJBException{
         Map<String, Entity> entitiesByName = new HashMap<String,Entity>();
         for (org.apache.openejb.jee.EnterpriseBean enterpriseBean : ejbJar.getEnterpriseBeans()) {
             // skip all non-CMP beans
@@ -58,13 +131,24 @@
             }
             EntityBean bean = (EntityBean) enterpriseBean;
 
+            // try to add a new persistence-context-ref for cmp
+            if (!addPersistenceContextRef(bean)) {
+                // Bean already has a persistence-context-ref for cmp
+                // which means it has a mapping, so skip this bean
+                continue;
+            }
+
             Entity entity = new Entity();
 
             // description: contains the name of the entity bean
             entity.setDescription(bean.getEjbName());
 
             // class: the java class for the entity
-            entity.setClazz(bean.getEjbClass());
+            if (bean.getCmpVersion() == CmpVersion.CMP2) {
+                entity.setClazz(bean.getEjbClass() + "_JPA");
+            } else {
+                entity.setClazz(bean.getEjbClass());
+            }
 
             // name: the name of the entity in queries
             if (bean.getAbstractSchemaName() != null) {
@@ -114,13 +198,10 @@
             entityMappings.getEntity().add(entity);
             entitiesByName.put(bean.getEjbName(), entity);
 
-            // add the persistence-context-ref
-            addPersistenceContextRef(bean);
-
             //
             // transient: non-persistent fields
             //
-            if (classLoader != null) {
+            if (classLoader != null && bean.getCmpVersion() == CmpVersion.CMP1) {
                 String ejbClassName = bean.getEjbClass();
                 try {
                     Class ejbClass = classLoader.loadClass(ejbClassName);
@@ -146,20 +227,40 @@
                     continue;
                 }
 
+                // get left entity
                 EjbRelationshipRole leftRole = roles.get(0);
                 RelationshipRoleSource leftRoleSource = leftRole.getRelationshipRoleSource();
+                // todo simplify role source using a wrapper
                 String leftEjbName = leftRoleSource == null ? null : leftRoleSource.getEjbName();
                 Entity leftEntity = entitiesByName.get(leftEjbName);
+
+                // get right entity
+                EjbRelationshipRole rightRole = roles.get(1);
+                RelationshipRoleSource rightRoleSource = rightRole.getRelationshipRoleSource();
+                String rightEjbName = rightRoleSource == null ? null : rightRoleSource.getEjbName();
+                Entity rightEntity = entitiesByName.get(rightEjbName);
+
+                // neither left or right have a mapping which is fine
+                if (leftEntity == null && rightEntity == null) {
+                    continue;
+                }
+                // left not found?
+                if (leftEntity == null) {
+                    throw new OpenEJBException("Role source " + leftEjbName + " defined in relationship role " +
+                            relation.getEjbRelationName() + "::" + leftRole.getEjbRelationshipRoleName() + " not found");
+                }
+                // right not found?
+                if (rightEntity == null) {
+                    throw new OpenEJBException("Role source " + rightEjbName + " defined in relationship role " +
+                            relation.getEjbRelationName() + "::" + rightRole.getEjbRelationshipRoleName() + " not found");
+                }
+
                 String leftFieldName = null;
                 if (leftRole.getCmrField() != null) {
                     leftFieldName = leftRole.getCmrField().getCmrFieldName();
                 }
                 boolean leftIsOne = leftRole.getMultiplicity() == Multiplicity.ONE;
 
-                EjbRelationshipRole rightRole = roles.get(1);
-                RelationshipRoleSource rightRoleSource = rightRole.getRelationshipRoleSource();
-                String rightEjbName = rightRoleSource == null ? null : rightRoleSource.getEjbName();
-                Entity rightEntity = entitiesByName.get(rightEjbName);
                 String rightFieldName = null;
                 if (rightRole.getCmrField() != null) {
                     rightFieldName = rightRole.getCmrField().getCmrFieldName();
@@ -297,20 +398,20 @@
                 }
             }
         }
-
-
-        return entityMappings;
     }
 
-    private void addPersistenceContextRef(EntityBean bean) {
+    private boolean addPersistenceContextRef(EntityBean bean) {
         for (PersistenceContextRef ref : bean.getPersistenceContextRef()) {
             // if a ref is already defined, skip this bean
-            if (ref.getName().equals("openejb/cmp")) return;
+            if (ref.getName().equals(JpaCmpEngine.CMP_PERSISTENCE_CONTEXT_REF_NAME)) {
+                return false;
+            }
         }
         PersistenceContextRef persistenceContextRef = new PersistenceContextRef();
-        persistenceContextRef.setName("openejb/cmp");
-        persistenceContextRef.setPersistenceUnitName("cmp");
+        persistenceContextRef.setName(JpaCmpEngine.CMP_PERSISTENCE_CONTEXT_REF_NAME);
+        persistenceContextRef.setPersistenceUnitName(CMP_PERSISTENCE_UNIT_NAME);
         bean.getPersistenceContextRef().add(persistenceContextRef);
+        return true;
     }
 
     private void setCascade(EjbRelationshipRole role, RelationField field) {

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java Tue Jan 30 11:36:37 2007
@@ -121,6 +121,8 @@
             chain.add(new GeronimoMappedName());
         }
 
+        chain.add(new CmpJpaConversion());
+        
         if (offline) {
             AutoConfigAndDeploy autoConfigAndDeploy = new AutoConfigAndDeploy(this);
             autoConfigAndDeploy.autoCreateConnectors(false);
@@ -357,6 +359,9 @@
             File file = new File(url.getPath());
             appInfo.libs.add(file.getAbsolutePath());
         }
+
+        appInfo.cmpMappingsXml = appModule.getCmpMappingsXml();
+
         return appInfo;
     }
 

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java Tue Jan 30 11:36:37 2007
@@ -549,12 +549,12 @@
         bean.reentrant = e.getReentrant() + "";
 
         CmpVersion cmpVersion = e.getCmpVersion();
-        if (cmpVersion != null && cmpVersion == CmpVersion.CMP2){
-            bean.cmpVersion = 2;
-        } else if (cmpVersion != null && cmpVersion == CmpVersion.CMP1){
-            bean.cmpVersion = 1;
-        } else if (e.getPersistenceType() == PersistenceType.CONTAINER) {
-            bean.cmpVersion = 1;
+        if (e.getPersistenceType() == PersistenceType.CONTAINER) {
+            if (cmpVersion != null && cmpVersion == CmpVersion.CMP1){
+                bean.cmpVersion = 1;
+            } else {
+                bean.cmpVersion = 2;
+            }
         }
 
         List<CmpField> cmpFields = e.getCmpField();

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbModule.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbModule.java?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbModule.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbModule.java Tue Jan 30 11:36:37 2007
@@ -36,7 +36,9 @@
     private String moduleId;
 
     public EjbModule(ClassLoader classLoader, String jarURI, EjbJar ejbJar, OpenejbJar openejbJar) {
-        if (classLoader == null) throw new NullPointerException("classLoader is null");
+        if (classLoader == null) {
+            throw new NullPointerException("classLoader is null");
+        }
         this.classLoader = classLoader;
         this.ejbJar = ejbJar;
         this.jarURI = jarURI;

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/jpa/JpaCmpEngine.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/jpa/JpaCmpEngine.java?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/jpa/JpaCmpEngine.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/jpa/JpaCmpEngine.java Tue Jan 30 11:36:37 2007
@@ -52,6 +52,8 @@
     private static final Logger logger = Logger.getInstance("OpenEJB", "org.apache.openejb.core.cmp");
     private static final Object[] NO_ARGS = new Object[0];
 
+    public static final String CMP_PERSISTENCE_CONTEXT_REF_NAME = "openejb/cmp";
+
     private final CmpCallback cmpCallback;
     private final WeakHashMap<EntityManager,Object> entityManagerListeners = new WeakHashMap<EntityManager,Object>();
 
@@ -100,7 +102,7 @@
     private EntityManager getEntityManager(CoreDeploymentInfo deploymentInfo) {
         EntityManager entityManager = null;
         try {
-            entityManager = (EntityManager) deploymentInfo.getJndiEnc().lookup("java:comp/env/openejb/cmp");
+            entityManager = (EntityManager) deploymentInfo.getJndiEnc().lookup("java:comp/env/" + CMP_PERSISTENCE_CONTEXT_REF_NAME);
         } catch (NamingException ignroed) {
         }
 

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/persistence/PersistenceUnitInfoImpl.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/persistence/PersistenceUnitInfoImpl.java?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/persistence/PersistenceUnitInfoImpl.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/persistence/PersistenceUnitInfoImpl.java Tue Jan 30 11:36:37 2007
@@ -251,6 +251,10 @@
         }
 
         public byte[] transform(ClassLoader classLoader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
+            if ("org/apache/openejb/test/entity/cmp/BasicCmpBean".equals(className) ||
+                    "org/apache/openejb/test/entity/cmp/BasicCmp2Bean_JPA".equals(className)) {
+                System.err.println("Loading " + className);
+            }
             byte[] bytes = classTransformer.transform(classLoader, className.replace('/', '.'), classBeingRedefined, protectionDomain, classfileBuffer);
             return bytes;
         }

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/resource/SharedLocalConnectionManager.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/resource/SharedLocalConnectionManager.java?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/resource/SharedLocalConnectionManager.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/resource/SharedLocalConnectionManager.java Tue Jan 30 11:36:37 2007
@@ -38,6 +38,8 @@
 import javax.transaction.SystemException;
 import javax.transaction.RollbackException;
 
+import org.apache.openejb.resource.jdbc.JdbcManagedConnectionFactory;
+
 /**
  * @org.apache.xbean.XBean element="sharedLocalConnectionManager"
  */
@@ -61,8 +63,12 @@
     }
 
     public Object allocateConnection(ManagedConnectionFactory factory, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
-        ConnectionCache connectionCache = threadConnectionCache.get();
-        ManagedConnection conn = connectionCache.getConnection(factory);
+        ConnectionCache connectionCache = null;
+        ManagedConnection conn = null;
+        if (!(factory instanceof JdbcManagedConnectionFactory) || !((JdbcManagedConnectionFactory) factory).isUnmanaged()) {
+            connectionCache = threadConnectionCache.get();
+            conn = connectionCache.getConnection(factory);
+        }
         if (conn == null) {
             conn = factory.matchManagedConnections(connSet, null, cxRequestInfo);
             if (conn != null) {
@@ -91,7 +97,9 @@
                 throw new ApplicationServerInternalException("Can not register org.apache.openejb.resource.LocalTransacton with transaciton manager. Transaction has already been rolled back" + re.getMessage());
             }
 
-            connectionCache.putConnection(factory, conn);
+            if (connectionCache != null) {
+                connectionCache.putConnection(factory, conn);
+            }
         }
 
         Object handle = conn.getConnection(null, cxRequestInfo);

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml Tue Jan 30 11:36:37 2007
@@ -277,6 +277,35 @@
     Unmanaged false
   </ServiceProvider>
 
+  <ServiceProvider
+          id="Default Unmanaged JDBC Database"
+          provider-type="Connector"
+          constructor="JdbcDriver,JdbcUrl,UserName,Password,Unmanaged"
+          class-name="org.apache.openejb.resource.jdbc.JdbcManagedConnectionFactory">
+
+    # Driver class name
+
+    #JdbcDriver org.apache.derby.jdbc.EmbeddedDriver
+    JdbcDriver org.hsqldb.jdbcDriver
+
+    # Url for creating connections
+
+    #JdbcUrl jdbc:derby:derbyDB;create=true
+    JdbcUrl jdbc:hsqldb:file:hsqldb
+
+    # Default user name
+
+    #UserName admin
+    UserName sa
+
+    # Default password
+
+    #Password pass
+    Password
+
+    Unmanaged true
+  </ServiceProvider>
+
   <!--
   # ================================================
   # Default JCA ConnectionManager

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/resources/default.openejb.conf
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/resources/default.openejb.conf?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/resources/default.openejb.conf (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/resources/default.openejb.conf Tue Jan 30 11:36:37 2007
@@ -150,6 +150,8 @@
 
 <Connector id="Default JDBC Database" />
 
+<Connector id="Default Unmanaged JDBC Database"/>
+
 <!--
 <Connector id="InstantDB Database">
     #  InstantDB example

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/RedeployTest.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/RedeployTest.java?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/RedeployTest.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/RedeployTest.java Tue Jan 30 11:36:37 2007
@@ -22,14 +22,13 @@
 import org.apache.openejb.test.stateful.AnnotatedFieldInjectionStatefulBean;
 import org.apache.openejb.test.stateless.EncStatelessHome;
 import org.apache.openejb.test.stateless.EncStatelessObject;
-import org.apache.openejb.test.TestFailureException;
+import org.apache.openejb.core.ivm.naming.InitContextFactory;
 
 import javax.naming.InitialContext;
 import javax.naming.Context;
 import javax.naming.NamingException;
 import java.io.File;
 import java.util.Properties;
-import java.rmi.RemoteException;
 
 /**
  * @version $Rev$ $Date$
@@ -39,6 +38,8 @@
         // create reference to openejb itests
         File file = new File(System.getProperty("user.home") + "/.m2/repository/org/apache/openejb/openejb-itests-beans/3.0-incubating-SNAPSHOT/openejb-itests-beans-3.0-incubating-SNAPSHOT.jar");
         if (!file.canRead()) return;
+
+        System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
 
         ConfigurationFactory config = new ConfigurationFactory();
         Assembler assembler = new Assembler();

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/daytrader/daytrader-orm.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/daytrader/daytrader-orm.xml?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/daytrader/daytrader-orm.xml (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/daytrader/daytrader-orm.xml Tue Jan 30 11:36:37 2007
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm">
-    <entity name="Holding" class="org.apache.geronimo.samples.daytrader.ejb.HoldingBean">
+    <entity name="Holding" class="org.apache.geronimo.samples.daytrader.ejb.HoldingBean_JPA">
         <description>HoldingEJB</description>
         <table name="HOLDINGEJB"/>
         <attributes>
@@ -27,7 +27,7 @@
             </many-to-one>
         </attributes>
     </entity>
-    <entity name="AccountProfile" class="org.apache.geronimo.samples.daytrader.ejb.AccountProfileBean">
+    <entity name="AccountProfile" class="org.apache.geronimo.samples.daytrader.ejb.AccountProfileBean_JPA">
         <description>AccountProfileEJB</description>
         <table name="AccountProfileEJB"/>
         <attributes>
@@ -56,7 +56,7 @@
             </one-to-one>
         </attributes>
     </entity>
-    <entity name="Quote" class="org.apache.geronimo.samples.daytrader.ejb.QuoteBean">
+    <entity name="Quote" class="org.apache.geronimo.samples.daytrader.ejb.QuoteBean_JPA">
         <description>QuoteEJB</description>
         <table name="QuoteEJB"/>
         <attributes>
@@ -87,7 +87,7 @@
             <one-to-many name="orders" mapped-by="quote"/>
         </attributes>
     </entity>
-    <entity name="KeyGen" class="org.apache.geronimo.samples.daytrader.ejb.KeyGenBean">
+    <entity name="KeyGen" class="org.apache.geronimo.samples.daytrader.ejb.KeyGenBean_JPA">
         <description>KeyGenEJB</description>
         <table name="KeyGenEJB"/>
         <attributes>
@@ -99,7 +99,7 @@
             </basic>
         </attributes>
     </entity>
-    <entity name="Account" class="org.apache.geronimo.samples.daytrader.ejb.AccountBean">
+    <entity name="Account" class="org.apache.geronimo.samples.daytrader.ejb.AccountBean_JPA">
         <description>AccountEJB</description>
         <table name="AccountEJB"/>
         <attributes>
@@ -131,7 +131,7 @@
             </one-to-one>
         </attributes>
     </entity>
-    <entity name="Orders" class="org.apache.geronimo.samples.daytrader.ejb.OrderBean">
+    <entity name="Orders" class="org.apache.geronimo.samples.daytrader.ejb.OrderBean_JPA">
         <description>OrderEJB</description>
         <table name="OrderEJB"/>
         <attributes>

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/itest-2.2/itest-2.2-orm.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/itest-2.2/itest-2.2-orm.xml?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/itest-2.2/itest-2.2-orm.xml (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/itest-2.2/itest-2.2-orm.xml Tue Jan 30 11:36:37 2007
@@ -92,7 +92,7 @@
             <transient name="ejbContext"/>
         </attributes>
     </entity>
-    <entity name="BasicCmp2" class="org.apache.openejb.test.entity.cmp.BasicCmp2Bean">
+    <entity name="BasicCmp2" class="org.apache.openejb.test.entity.cmp.BasicCmp2Bean_JPA">
         <description>BasicCmp2Bean</description>
         <table name="entity"/>
         <attributes>
@@ -106,11 +106,9 @@
             <basic name="lastName">
                 <column name="last_name"/>
             </basic>
-            <transient name="ejbContext"/>
-            <transient name="allowedOperationsTable"/>
         </attributes>
     </entity>
-    <entity name="AOBasicCmp2" class="org.apache.openejb.test.entity.cmp.AllowedOperationsCmp2Bean">
+    <entity name="AOBasicCmp2" class="org.apache.openejb.test.entity.cmp.AllowedOperationsCmp2Bean_JPA">
         <description>AOBasicCmp2Bean</description>
         <table name="entity"/>
         <attributes>
@@ -124,11 +122,9 @@
             <basic name="lastName">
                 <column name="last_name"/>
             </basic>
-            <transient name="ejbContext"/>
-            <transient name="allowedOperationsTable"/>
         </attributes>
     </entity>
-    <entity name="EncCmp2" class="org.apache.openejb.test.entity.cmp.EncCmp2Bean">
+    <entity name="EncCmp2" class="org.apache.openejb.test.entity.cmp.EncCmp2Bean_JPA">
         <description>EncCmp2Bean</description>
         <table name="entity"/>
         <attributes>
@@ -142,10 +138,9 @@
             <basic name="lastName">
                 <column name="last_name"/>
             </basic>
-            <transient name="ejbContext"/>
         </attributes>
     </entity>
-    <entity name="Cmp2RmiIiop" class="org.apache.openejb.test.entity.cmp.RmiIiopCmp2Bean">
+    <entity name="Cmp2RmiIiop" class="org.apache.openejb.test.entity.cmp.RmiIiopCmp2Bean_JPA">
         <description>Cmp2RMIIIOPBean</description>
         <table name="entity"/>
         <attributes>
@@ -159,10 +154,9 @@
             <basic name="lastName">
                 <column name="last_name"/>
             </basic>
-            <transient name="ejbContext"/>
         </attributes>
     </entity>
-    <entity name="Order" class="org.apache.openejb.test.entity.cmp2.cmrmapping.OneOwningSideBean">
+    <entity name="Order" class="org.apache.openejb.test.entity.cmp2.cmrmapping.OneOwningSideBean_JPA">
         <description>OneOwningSideBean</description>
         <table name="OneOwning"/>
         <attributes>
@@ -177,7 +171,7 @@
             </one-to-one>
         </attributes>
     </entity>
-    <entity name="Order" class="org.apache.openejb.test.entity.cmp2.cmrmapping.OneInverseSideBean">
+    <entity name="Order" class="org.apache.openejb.test.entity.cmp2.cmrmapping.OneInverseSideBean_JPA">
         <description>OneInverseSideBean</description>
         <table name="OneInverse"/>
         <attributes>
@@ -188,7 +182,7 @@
             <one-to-one name="oneOwningSide" mapped-by="oneInverseSide"/>
         </attributes>
     </entity>
-    <entity name="Order" class="org.apache.openejb.test.entity.cmp2.cmrmapping.ManyOwningSideBean">
+    <entity name="Order" class="org.apache.openejb.test.entity.cmp2.cmrmapping.ManyOwningSideBean_JPA">
         <description>ManyOwningSideBean</description>
         <table name="ManyOwning"/>
         <attributes>
@@ -203,7 +197,7 @@
             </many-to-one>
         </attributes>
     </entity>
-    <entity name="Address" class="org.apache.openejb.test.entity.cmp2.petstore.AddressEJB">
+    <entity name="Address" class="org.apache.openejb.test.entity.cmp2.petstore.AddressEJB_JPA">
         <description>AddressEJB</description>
         <table name="address"/>
         <attributes>
@@ -215,7 +209,7 @@
             </basic>
         </attributes>
     </entity>
-    <entity name="Storage" class="org.apache.openejb.test.entity.cmp2.model.StorageBean">
+    <entity name="Storage" class="org.apache.openejb.test.entity.cmp2.model.StorageBean_JPA">
         <description>StorageBean</description>
         <table name="storage"/>
         <attributes>

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/manytomany/simplepk/orm.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/manytomany/simplepk/orm.xml?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/manytomany/simplepk/orm.xml (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/manytomany/simplepk/orm.xml Tue Jan 30 11:36:37 2007
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm">
-    <entity name="manytomanyA" class="org.apache.openejb.deployment.entity.cmp.cmr.manytomany.ABean">
+    <entity name="manytomanyA" class="org.apache.openejb.deployment.entity.cmp.cmr.manytomany.ABean_JPA">
         <description>A</description>
         <table name="A"/>
         <attributes>
@@ -18,7 +18,7 @@
             </many-to-many>
         </attributes>
     </entity>
-    <entity name="manytomanyB" class="org.apache.openejb.deployment.entity.cmp.cmr.manytomany.BBean">
+    <entity name="manytomanyB" class="org.apache.openejb.deployment.entity.cmp.cmr.manytomany.BBean_JPA">
         <description>B</description>
         <table name="B"/>
         <attributes>

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/manytomany/simplepk/unidirectional-orm.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/manytomany/simplepk/unidirectional-orm.xml?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/manytomany/simplepk/unidirectional-orm.xml (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/manytomany/simplepk/unidirectional-orm.xml Tue Jan 30 11:36:37 2007
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm">
-    <entity name="manytomanyA" class="org.apache.openejb.deployment.entity.cmp.cmr.manytomany.ABean">
+    <entity name="manytomanyA" class="org.apache.openejb.deployment.entity.cmp.cmr.manytomany.ABean_JPA">
         <description>A</description>
         <table name="A"/>
         <attributes>
@@ -18,7 +18,7 @@
             </many-to-many>
         </attributes>
     </entity>
-    <entity name="manytomanyB" class="org.apache.openejb.deployment.entity.cmp.cmr.manytomany.BBean">
+    <entity name="manytomanyB" class="org.apache.openejb.deployment.entity.cmp.cmr.manytomany.BBean_JPA">
         <description>B</description>
         <table name="B"/>
         <attributes>

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetomany/simplepk/many-unidirectional-orm.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetomany/simplepk/many-unidirectional-orm.xml?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetomany/simplepk/many-unidirectional-orm.xml (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetomany/simplepk/many-unidirectional-orm.xml Tue Jan 30 11:36:37 2007
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm">
-    <entity name="onetomanyA" class="org.apache.openejb.deployment.entity.cmp.cmr.onetomany.ABean">
+    <entity name="onetomanyA" class="org.apache.openejb.deployment.entity.cmp.cmr.onetomany.ABean_JPA">
         <description>A</description>
         <table name="A"/>
         <attributes>
@@ -12,7 +12,7 @@
             </basic>
         </attributes>
     </entity>
-    <entity name="onetomanyB" class="org.apache.openejb.deployment.entity.cmp.cmr.onetomany.BBean">
+    <entity name="onetomanyB" class="org.apache.openejb.deployment.entity.cmp.cmr.onetomany.BBean_JPA">
         <description>B</description>
         <table name="B"/>
         <attributes>

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetomany/simplepk/one-unidirectional-orm.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetomany/simplepk/one-unidirectional-orm.xml?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetomany/simplepk/one-unidirectional-orm.xml (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetomany/simplepk/one-unidirectional-orm.xml Tue Jan 30 11:36:37 2007
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm">
-    <entity name="onetomanyA" class="org.apache.openejb.deployment.entity.cmp.cmr.onetomany.ABean">
+    <entity name="onetomanyA" class="org.apache.openejb.deployment.entity.cmp.cmr.onetomany.ABean_JPA">
         <description>A</description>
         <table name="A"/>
         <attributes>
@@ -13,7 +13,7 @@
             </one-to-many>
         </attributes>
     </entity>
-    <entity name="onetomanyB" class="org.apache.openejb.deployment.entity.cmp.cmr.onetomany.BBean">
+    <entity name="onetomanyB" class="org.apache.openejb.deployment.entity.cmp.cmr.onetomany.BBean_JPA">
         <description>B</description>
         <table name="B"/>
         <attributes>

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetomany/simplepk/orm.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetomany/simplepk/orm.xml?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetomany/simplepk/orm.xml (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetomany/simplepk/orm.xml Tue Jan 30 11:36:37 2007
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm">
-    <entity name="onetomanyA" class="org.apache.openejb.deployment.entity.cmp.cmr.onetomany.ABean">
+    <entity name="onetomanyA" class="org.apache.openejb.deployment.entity.cmp.cmr.onetomany.ABean_JPA">
         <description>A</description>
         <table name="A"/>
         <attributes>
@@ -11,7 +11,7 @@
             <one-to-many name="b" mapped-by="a"/>
         </attributes>
     </entity>
-    <entity name="onetomanyB" class="org.apache.openejb.deployment.entity.cmp.cmr.onetomany.BBean">
+    <entity name="onetomanyB" class="org.apache.openejb.deployment.entity.cmp.cmr.onetomany.BBean_JPA">
         <description>B</description>
         <table name="B"/>
         <attributes>

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetoone/simplepk/orm.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetoone/simplepk/orm.xml?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetoone/simplepk/orm.xml (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetoone/simplepk/orm.xml Tue Jan 30 11:36:37 2007
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm">
-    <entity name="OneToOneA" class="org.apache.openejb.deployment.entity.cmp.cmr.onetoone.ABean">
+    <entity name="OneToOneA" class="org.apache.openejb.deployment.entity.cmp.cmr.onetoone.ABean_JPA">
         <description>A</description>
         <table name="A"/>
         <attributes>
@@ -15,7 +15,7 @@
             </one-to-one>
         </attributes>
     </entity>
-    <entity name="OneToOneB" class="org.apache.openejb.deployment.entity.cmp.cmr.onetoone.BBean">
+    <entity name="OneToOneB" class="org.apache.openejb.deployment.entity.cmp.cmr.onetoone.BBean_JPA">
         <description>B</description>
         <table name="B"/>
         <attributes>

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetoone/simplepk/unidirectional-orm.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetoone/simplepk/unidirectional-orm.xml?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetoone/simplepk/unidirectional-orm.xml (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/resources/convert/oej2/cmp/onetoone/simplepk/unidirectional-orm.xml Tue Jan 30 11:36:37 2007
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm">
-    <entity name="OneToOneA" class="org.apache.openejb.deployment.entity.cmp.cmr.onetoone.ABean">
+    <entity name="OneToOneA" class="org.apache.openejb.deployment.entity.cmp.cmr.onetoone.ABean_JPA">
         <description>A</description>
         <table name="A"/>
         <attributes>
@@ -12,7 +12,7 @@
             </basic>
         </attributes>
     </entity>
-    <entity name="OneToOneB" class="org.apache.openejb.deployment.entity.cmp.cmr.onetoone.BBean">
+    <entity name="OneToOneB" class="org.apache.openejb.deployment.entity.cmp.cmr.onetoone.BBean_JPA">
         <description>B</description>
         <table name="B"/>
         <attributes>

Modified: incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/EntityBean.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/EntityBean.java?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/EntityBean.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/EntityBean.java Tue Jan 30 11:36:37 2007
@@ -183,8 +183,8 @@
     protected String primKeyClass;
     @XmlElement(required = true)
     protected boolean reentrant;
-    @XmlElement(name = "cmp-version")
-    protected CmpVersion cmpVersion;
+    @XmlElement(name = "cmp-version", defaultValue = "2.x")
+    protected CmpVersion cmpVersion = CmpVersion.CMP2;
     @XmlElement(name = "abstract-schema-name")
     protected String abstractSchemaName;
     @XmlElement(name = "cmp-field", required = true)

Modified: incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/resources/geronimo-openejb-jaxb-test.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/resources/geronimo-openejb-jaxb-test.xml?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/resources/geronimo-openejb-jaxb-test.xml (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/resources/geronimo-openejb-jaxb-test.xml Tue Jan 30 11:36:37 2007
@@ -79,20 +79,20 @@
         <n:persistence-unit-name>openjpa-test-unit</n:persistence-unit-name>
     </n:persistence-unit-ref>
 
-    <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
-        <persistence-unit transaction-type="JTA" name="cmp">
-            <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
-            <jta-data-source>?name=SystemDatasource</jta-data-source>
-            <non-jta-data-source>?name=NoTxDatasource</non-jta-data-source>
-            <mapping-file>META-INF/jpa.mapping.xml</mapping-file>
-            <class>org.apache.openejb.test.entity.cmp.BasicCmpBean</class>
-            <exclude-unlisted-classes>false</exclude-unlisted-classes>
-        </persistence-unit>
-        <persistence-unit transaction-type="JTA" name="openjpa-test-unit">
-            <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
-            <jta-data-source>?name=SystemDatasource</jta-data-source>
-            <non-jta-data-source>?name=NoTxDatasource</non-jta-data-source>
-            <class>org.apache.openejb.test.entity.Customer</class>
-        </persistence-unit>
-    </persistence>
+    <!--<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">-->
+        <!--<persistence-unit transaction-type="JTA" name="cmp">-->
+            <!--<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>-->
+            <!--<jta-data-source>?name=SystemDatasource</jta-data-source>-->
+            <!--<non-jta-data-source>?name=NoTxDatasource</non-jta-data-source>-->
+            <!--<mapping-file>META-INF/jpa.mapping.xml</mapping-file>-->
+            <!--<class>org.apache.openejb.test.entity.cmp.BasicCmpBean</class>-->
+            <!--<exclude-unlisted-classes>false</exclude-unlisted-classes>-->
+        <!--</persistence-unit>-->
+        <!--<persistence-unit transaction-type="JTA" name="openjpa-test-unit">-->
+            <!--<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>-->
+            <!--<jta-data-source>?name=SystemDatasource</jta-data-source>-->
+            <!--<non-jta-data-source>?name=NoTxDatasource</non-jta-data-source>-->
+            <!--<class>org.apache.openejb.test.entity.Customer</class>-->
+        <!--</persistence-unit>-->
+    <!--</persistence>-->
 </ejb-jar>

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml Tue Jan 30 11:36:37 2007
@@ -63,6 +63,15 @@
       <prim-key-class>java.lang.Integer</prim-key-class>
       <reentrant>false</reentrant>
       <primkey-field>primaryKey</primkey-field>
+      <cmp-field>
+        <field-name>primaryKey</field-name>
+      </cmp-field>
+      <cmp-field>
+        <field-name>firstName</field-name>
+      </cmp-field>
+      <cmp-field>
+        <field-name>lastName</field-name>
+      </cmp-field>
       <resource-ref>
         <description>This is a reference to a JDBC database.</description>
         <res-ref-name>jdbc/basic/entityDatabase</res-ref-name>
@@ -485,6 +494,7 @@
       <ejb-class>org.apache.openejb.test.entity.cmp.ContextLookupCmpBean</ejb-class>
       <persistence-type>Container</persistence-type>
       <prim-key-class>java.lang.Integer</prim-key-class>
+      <cmp-version>1.x</cmp-version>
       <reentrant>false</reentrant>
       <primkey-field>primaryKey</primkey-field>
       <env-entry>

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/persistence.xml?view=diff&rev=501528&r1=501527&r2=501528
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/persistence.xml (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/persistence.xml Tue Jan 30 11:36:37 2007
@@ -20,18 +20,18 @@
   <persistence-unit transaction-type="JTA" name="cmp">
     <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
     <jta-data-source>java:openejb/Connector/Default JDBC Database</jta-data-source>
-    <non-jta-data-source>java:openejb/Connector/Default JDBC Database</non-jta-data-source>
+    <non-jta-data-source>java:openejb/Connector/Default Unmanaged JDBC Database</non-jta-data-source>
     <mapping-file>META-INF/jpa.mapping.xml</mapping-file>
-    <class>org.apache.openejb.test.entity.cmp.BasicCmpBean</class>
     <exclude-unlisted-classes>false</exclude-unlisted-classes>
-    <!--<properties>-->
-    <!--<property name="openjpa.Log" value="DefaultLevel=TRACE"/>-->
-    <!--</properties>-->
+    <properties>
+        <!--<property name="openjpa.Log" value="DefaultLevel=TRACE"/>-->
+        <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+    </properties>
   </persistence-unit>
   <persistence-unit name="openjpa-test-unit">
     <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
     <jta-data-source>java:openejb/Connector/Default JDBC Database</jta-data-source>
-    <non-jta-data-source>java:openejb/Connector/Default JDBC Database</non-jta-data-source>
+    <non-jta-data-source>java:openejb/Connector/Default Unmanaged JDBC Database</non-jta-data-source>
     <class>org.apache.openejb.test.entity.Customer</class>
   </persistence-unit>
 </persistence>