openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r627979 [36/39] - in /openjpa/trunk: openjpa-lib/src/test/java/org/apache/openjpa/lib/test/ openjpa-persistence-jdbc/ openjpa-persistence-jdbc/src/test/java/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/ openjpa-per...
Date Fri, 15 Feb 2008 09:20:40 GMT
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestExternalValues.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestExternalValues.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestExternalValues.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestExternalValues.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta;
+
+
+import org.apache.openjpa.persistence.meta.common.apps.ExternalValues;
+import org.apache.openjpa.persistence.common.utils.AbstractTestCase;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+
+/**
+ * <p>Tests the {@link ExternalValuesFieldMapping}.</p>
+ *
+ * @author Abe White
+ */
+public class TestExternalValues
+    extends AbstractTestCase {
+
+    public TestExternalValues(String test) {
+        super(test, "metacactusapp");
+    }
+
+    public void setUp()
+        throws Exception {
+        deleteAll(ExternalValues.class);
+    }
+
+    public void testInsert() {
+        OpenJPAEntityManager pm =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+
+        ExternalValues pc = new ExternalValues();
+        pc.setBooleanToShort(true);
+        pc.setByteToDouble((byte) 4);
+        pc.setIntToFloat(4);
+        pc.setLongToChar(4);
+        pc.setShortToString((short) 4);
+        pc.setFloatToBoolean(4.5f);
+        pc.setDoubleToByte(4.5);
+        pc.setCharToInt('f');
+        pc.setStringToLong("foo");
+
+        pm.persist(pc);
+        Object oid = pm.getObjectId(pc);
+        endTx(pm);
+        endEm(pm);
+
+        pm = (OpenJPAEntityManager) currentEntityManager();
+        pc = (ExternalValues) pm.find(ExternalValues.class, oid);
+
+        assertTrue(pc.getBooleanToShort());
+        assertEquals((byte) 4, pc.getByteToDouble());
+        assertEquals(4, pc.getIntToFloat());
+        assertEquals(4, pc.getLongToChar());
+        assertEquals((short) 4, pc.getShortToString());
+        assertTrue(4.5f == pc.getFloatToBoolean());
+        assertTrue(4.5 == pc.getDoubleToByte());
+        assertEquals('f', pc.getCharToInt());
+        assertEquals("foo", pc.getStringToLong());
+
+        endEm(pm);
+    }
+
+    public void testComplexStrings() {
+        OpenJPAEntityManager pm =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+
+        ExternalValues pc = new ExternalValues();
+        pc.setShortToString((short) 3);
+        pc.setStringToLong("long string");
+
+        pm.persist(pc);
+        Object oid = pm.getObjectId(pc);
+        endTx(pm);
+        endEm(pm);
+
+        pm = (OpenJPAEntityManager) currentEntityManager();
+        pc = (ExternalValues) pm.find(ExternalValues.class, oid);
+        assertEquals(3, pc.getShortToString());
+        endEm(pm);
+    }
+
+    public void testAllNull() {
+        OpenJPAEntityManager pm =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+
+        ExternalValues pc = new ExternalValues();
+        pm.persist(pc);
+        Object oid = pm.getObjectId(pc);
+        endTx(pm);
+        endEm(pm);
+
+        pm = (OpenJPAEntityManager) currentEntityManager();
+        pc = (ExternalValues) pm.find(ExternalValues.class, oid);
+        endEm(pm);
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestFieldDeclarationOrder.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestFieldDeclarationOrder.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestFieldDeclarationOrder.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestFieldDeclarationOrder.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta;
+
+
+import org.apache.openjpa.persistence.meta.common.apps.FieldOrderPC;
+import org.apache.openjpa.persistence.meta.common.apps.FieldOrderPCSubclass;
+import org.apache.openjpa.persistence.common.utils.AbstractTestCase;
+import org.apache.openjpa.meta.ClassMetaData;
+import org.apache.openjpa.meta.FieldMetaData;
+import org.apache.openjpa.persistence.JPAFacadeHelper;
+
+public class TestFieldDeclarationOrder
+    extends AbstractTestCase {
+
+    public TestFieldDeclarationOrder(String test) {
+        super(test, "metacactusapp");
+    }
+
+    public void testSubclass() {
+        ClassMetaData meta = JPAFacadeHelper
+            .getMetaData(getEmf(),
+                FieldOrderPCSubclass.class);
+        FieldMetaData[] fmds = meta.getFieldsInListingOrder();
+
+        assertEquals(11, fmds.length);
+        assertEquals("firstField", fmds[0].getName());
+        assertEquals("secondField", fmds[1].getName());
+        assertEquals("thirdField", fmds[2].getName());
+        assertEquals("unmanagedField", fmds[3].getName());
+        assertEquals("intField", fmds[4].getName());
+        assertEquals("oneToOneField", fmds[5].getName());
+        assertEquals("sub1", fmds[6].getName());
+        assertEquals("sub2", fmds[7].getName());
+        assertEquals("sub3", fmds[8].getName());
+        assertEquals("unmanagedSubField", fmds[9].getName());
+        assertEquals("undeclaredSubField", fmds[10].getName());
+    }
+
+    public void testSuperclass() {
+        ClassMetaData meta = JPAFacadeHelper
+            .getMetaData(getEmf(),
+                FieldOrderPC.class);
+        FieldMetaData[] fmds = meta.getFieldsInListingOrder();
+
+        assertEquals(6, fmds.length);
+        assertEquals("firstField", fmds[0].getName());
+        assertEquals("secondField", fmds[1].getName());
+        assertEquals("thirdField", fmds[2].getName());
+        assertEquals("unmanagedField", fmds[3].getName());
+        assertEquals("intField", fmds[4].getName());
+        assertEquals("oneToOneField", fmds[5].getName());
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestNonPersistentFields.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestNonPersistentFields.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestNonPersistentFields.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestNonPersistentFields.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta;
+
+
+import org.apache.openjpa.persistence.meta.common.apps.NonPersistentFieldsPC;
+import org.apache.openjpa.persistence.common.utils.AbstractTestCase;
+import org.apache.openjpa.conf.OpenJPAConfigurationImpl;
+import org.apache.openjpa.meta.ClassMetaData;
+import org.apache.openjpa.meta.FieldMetaData;
+import org.apache.openjpa.meta.MetaDataRepository;
+
+/**
+ * <p>Tests that fields that should not be persistent actually aren't.</p>
+ *
+ * @author Abe White
+ */
+public class TestNonPersistentFields
+    extends AbstractTestCase {
+
+    private ClassMetaData _meta = null;
+
+    public TestNonPersistentFields(String test) {
+        super(test, "metacactusapp");
+    }
+
+    public void setUp() {
+        MetaDataRepository repos = new OpenJPAConfigurationImpl().
+            newMetaDataRepositoryInstance();
+        _meta = repos.getMetaData(NonPersistentFieldsPC.class, null, true);
+    }
+
+    public void testNonPersistentFields() {
+        FieldMetaData[] fmds = _meta.getFields();
+        assertEquals(5, fmds.length);
+        assertEquals("persistentField", fmds[0].getName());
+        assertEquals("persistentInterfaceField", fmds[1].getName());
+        assertEquals("persistentObjectField", fmds[2].getName());
+        assertEquals("persistentUserInterfaceField", fmds[3].getName());
+        assertEquals("persistentUserObjectField", fmds[4].getName());
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestOrderBy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestOrderBy.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestOrderBy.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestOrderBy.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,283 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta;
+
+import java.util.Arrays;
+import java.util.List;
+
+
+import org.apache.openjpa.persistence.meta.common.apps.OrderByPC;
+import org.apache.openjpa.persistence.meta.common.apps.OrderByPCRel;
+import org.apache.openjpa.persistence.meta.common.apps.OrderByPCRelSub;
+import org.apache.openjpa.persistence.common.utils.AbstractTestCase;
+import org.apache.openjpa.persistence.FetchPlan;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.OpenJPAQuery;
+
+/**
+ * <p>Test the <code>order-by</code> field extension.</p>
+ *
+ * @author Abe White
+ */
+public class TestOrderBy
+    extends AbstractTestCase {
+
+    public TestOrderBy(String test) {
+        super(test, "metacactusapp");
+    }
+
+    public void setUp() {
+        deleteAll(OrderByPCRel.class);
+        deleteAll(OrderByPC.class);
+    }
+
+    public void testStringList() {
+        stringListTest(false, false);
+    }
+
+    public void testEagerParallelStringList() {
+        stringListTest(true, true);
+    }
+
+    public void testEagerJoinStringList() {
+        stringListTest(true, false);
+    }
+
+    private void stringListTest(boolean eager, boolean parallel) {
+        String[] strs = new String[]{
+            "9", "0", "5", "1", "3", "7", "8", "2", "6", "4",
+        };
+        OrderByPC pc = new OrderByPC();
+        pc.setId(1L);
+        pc.getStringListAsc().addAll(Arrays.asList(strs));
+
+        OpenJPAEntityManager pm =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+        pm.persist(pc);
+        endTx(pm);
+        Object oid = pm.getObjectId(pc);
+        endEm(pm);
+
+        pm = (OpenJPAEntityManager) currentEntityManager();
+        if (eager)
+            ((FetchPlan) pm.getFetchPlan()).addField(OrderByPC.class,
+                "stringListAsc");
+        if (parallel) {
+
+            OpenJPAQuery q = pm.createQuery(
+                "select a FROM " + OrderByPC.class.getSimpleName());
+            List res = (List) q.getResultList();
+            assertEquals(1, res.size());
+            pc = (OrderByPC) res.get(0);
+        } else
+            pc = (OrderByPC) pm.find(OrderByPC.class, oid);
+        List stringList = pc.getStringListAsc();
+        for (int i = 0; i < 10; i++)
+            assertEquals(String.valueOf(i), stringList.get(i));
+        endEm(pm);
+    }
+
+    public void testIntArray() {
+        int[] ints = new int[]{ 9, 0, 5, 1, 3, 7, 8, 2, 6, 4, };
+        OrderByPC pc = new OrderByPC();
+        pc.setId(1L);
+        pc.setIntArrayDesc(ints);
+
+        OpenJPAEntityManager pm =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+        pm.persist(pc);
+        endTx(pm);
+        Object oid = pm.getObjectId(pc);
+        endEm(pm);
+
+        pm = (OpenJPAEntityManager) currentEntityManager();
+        pc = (OrderByPC) pm.find(OrderByPC.class, oid);
+        int[] intArray = pc.getIntArrayDesc();
+        for (int i = 0; i < 10; i++)
+            assertEquals(9 - i, intArray[i]);
+        endEm(pm);
+    }
+
+    public void testOrderByPK() {
+        orderByPKTest(false, false, false);
+    }
+
+    public void testEagerJoinOrderByPK() {
+        orderByPKTest(true, false, false);
+    }
+
+    public void testEagerParallelOrderByPK() {
+        orderByPKTest(true, true, false);
+    }
+
+    public void testOneToManyOrderByPK() {
+        orderByPKTest(false, false, true);
+    }
+
+    public void testEagerJoinOneToManyOrderByPK() {
+        orderByPKTest(true, false, true);
+    }
+
+    public void testEagerParallelOneToManyOrderByPK() {
+        orderByPKTest(true, true, true);
+    }
+
+    private void orderByPKTest(boolean eager, boolean parallel,
+        boolean oneToMany) {
+        long[] ids = new long[]{ 9, 0, 5, 1, 3, 7, 8, 2, 6, 4, };
+        OrderByPC pc = new OrderByPC();
+        pc.setId(1L);
+        OrderByPC pc2 = new OrderByPC();
+        pc2.setId(2L);
+        for (int i = 0; i < ids.length; i++) {
+            OrderByPCRel rel = (i % 2 == 0) ? new OrderByPCRel()
+                : new OrderByPCRelSub();
+            rel.setId(ids[i]);
+            if (oneToMany) {
+                pc.getOneToManyAsc().add(rel);
+                rel.setToOne(pc);
+            } else
+                pc.getOrderByPKAsc().add(rel);
+
+            if (parallel)
+                pc2.getOrderByPKAsc().add(rel);
+        }
+        OpenJPAEntityManager pm =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+        pm.persist(pc);
+        pm.persist(pc2);
+        endTx(pm);
+        Object oid = pm.getObjectId(pc);
+        endEm(pm);
+
+        pm = (OpenJPAEntityManager) currentEntityManager();
+        if (eager)
+            ((FetchPlan) pm.getFetchPlan()).addField(OrderByPC.class,
+                "orderByPKAsc");
+        if (parallel) {
+
+            OpenJPAQuery q = pm.createQuery("select a FROM " +
+                OrderByPC.class.getSimpleName() + " select order by id asc");
+            pc = (OrderByPC) ((List) q.getResultList()).get(0);
+            q.closeAll();
+        } else
+            pc = (OrderByPC) pm.find(OrderByPC.class, oid);
+
+        List orderByPK = (oneToMany) ? pc.getOneToManyAsc()
+            : pc.getOrderByPKAsc();
+        for (int i = 0; i < 10; i++)
+            assertEquals(i, ((OrderByPCRel) orderByPK.get(i)).getId());
+        endEm(pm);
+    }
+
+    public void testOrderByRelatedField() {
+        String[] strs = new String[]{
+            "9", "0", "5", "1", "3", "7", "8", "2", "6", "4",
+        };
+        OrderByPC pc = new OrderByPC();
+        pc.setId(1L);
+        for (int i = 0; i < strs.length; i++) {
+            OrderByPCRel rel = (i % 2 == 0) ? new OrderByPCRel()
+                : new OrderByPCRelSub();
+            rel.setId(i);
+            rel.setString(strs[i]);
+            pc.getOrderByStringDesc().add(rel);
+        }
+        OpenJPAEntityManager pm =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+        pm.persist(pc);
+        endTx(pm);
+        Object oid = pm.getObjectId(pc);
+        endEm(pm);
+
+        pm = (OpenJPAEntityManager) currentEntityManager();
+        pc = (OrderByPC) pm.find(OrderByPC.class, oid);
+        List orderByRelField = pc.getOrderByStringDesc();
+        for (int i = 0; i < 10; i++)
+            assertEquals(String.valueOf(9 - i), ((OrderByPCRel)
+                orderByRelField.get(i)).getString());
+        endEm(pm);
+    }
+
+    public void testOrderByPKAndRelatedField() {
+        orderByPKAndRelatedFieldTest(false, false);
+    }
+
+    public void testEagerJoinOrderByPKAndRelatedField() {
+        orderByPKAndRelatedFieldTest(true, false);
+    }
+
+    public void testEagerParallelOrderByPKAndRelatedField() {
+        orderByPKAndRelatedFieldTest(true, true);
+    }
+
+    private void orderByPKAndRelatedFieldTest(boolean eager, boolean parallel) {
+        OrderByPC pc = new OrderByPC();
+        pc.setId(1L);
+        OrderByPC pc2 = new OrderByPC();
+        pc.setId(2L);
+
+        OrderByPCRel rel1 = new OrderByPCRel();
+        rel1.setId(1L);
+        rel1.setString("1");
+        OrderByPCRel rel2 = new OrderByPCRelSub();
+        rel2.setId(2L);
+        rel2.setString("1");
+        OrderByPCRel rel3 = new OrderByPCRel();
+        rel3.setId(3L);
+        rel3.setString("2");
+        OrderByPCRel rel4 = new OrderByPCRelSub();
+        rel4.setId(4L);
+        rel4.setString("2");
+        pc.getOrderByStringAndPKDesc().addAll(Arrays.asList
+            (new Object[]{ rel1, rel2, rel4, rel3, }));
+        if (parallel)
+            pc2.getOrderByStringAndPKDesc().addAll(Arrays.asList
+                (new Object[]{ rel1, rel2, rel4, rel3, }));
+
+        OpenJPAEntityManager pm =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+        pm.persist(pc);
+        pm.persist(pc2);
+        endTx(pm);
+        Object oid = pm.getObjectId(pc);
+        endEm(pm);
+
+        pm = (OpenJPAEntityManager) currentEntityManager();
+        if (eager)
+            ((FetchPlan) pm.getFetchPlan()).addField(OrderByPC.class,
+                "orderByStringAndPKDesc");
+        if (parallel) {
+            OpenJPAQuery q = pm.createQuery("select a FROM " +
+                OrderByPC.class.getSimpleName() + " select order by id asc");
+            pc = (OrderByPC) ((List) q.getResultList()).get(0);
+            q.closeAll();
+        } else
+            pc = (OrderByPC) pm.find(OrderByPC.class, oid);
+        List multiOrder = pc.getOrderByStringAndPKDesc();
+        for (int i = 0; i < 4; i++)
+            assertEquals(4 - i, ((OrderByPCRel) multiOrder.get(i)).getId());
+        endEm(pm);
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestPersistentClasses.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestPersistentClasses.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestPersistentClasses.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestPersistentClasses.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.openjpa.persistence.meta.common.apps.RuntimeTest1;
+import org.apache.openjpa.persistence.meta.common.apps.RuntimeTest2;
+import org.apache.openjpa.persistence.meta.common.apps.RuntimeTest3;
+import org.apache.openjpa.persistence.common.utils.*;
+import org.apache.openjpa.conf.OpenJPAConfiguration;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
+
+public class TestPersistentClasses
+    extends AbstractTestCase {
+
+    public TestPersistentClasses(String test) {
+        super(test, "metacactusapp");
+    }
+
+    private void assertClass(Class cls, OpenJPAConfiguration conf,
+        boolean shouldExist) {
+        assertClass(cls.getName(), conf, shouldExist);
+    }
+
+    private void assertClass(String clsName, OpenJPAConfiguration conf,
+        boolean shouldExist) {
+
+        Collection names = conf.getMetaDataRepositoryInstance().
+            getPersistentTypeNames(false, null);
+
+        if (shouldExist)
+            assertTrue("expected element " + clsName + " was not found in "
+                + names, names.contains(clsName));
+        else
+            assertTrue("unexpected element " + clsName + " was found in "
+                + names, !names.contains(clsName));
+    }
+
+    public void testNoneConfigured() {
+
+        Map map = new HashMap();
+        map.put("openjpa.MetaDataFactory", "jpa");
+        OpenJPAEntityManagerFactory pmf = getEmf(map);
+
+        assertNull(((OpenJPAEntityManagerFactorySPI) pmf).getConfiguration()
+            .getMetaDataRepositoryInstance().
+
+            getPersistentTypeNames(false, null));
+
+        pmf.close();
+    }
+
+    public void testJPAClasspathScanner() {
+        Map map = new HashMap();
+        map.put("openjpa.MetaDataFactory", "jpa(ClasspathScan=src;jdk1.5-test)");
+        OpenJPAEntityManagerFactory pmf = getEmf(map);
+
+        assertClass(RuntimeTest1.class,
+            ((OpenJPAEntityManagerFactorySPI) pmf).getConfiguration(), false);
+
+        assertClass(RuntimeTest2.class,
+            ((OpenJPAEntityManagerFactorySPI) pmf).getConfiguration(), false);
+
+        assertClass("openjpa.meta.GenericFields",
+            ((OpenJPAEntityManagerFactorySPI) pmf).getConfiguration(), true);
+
+        pmf.close();
+    }
+
+    public void testTypes() {
+
+        Map map = new HashMap();
+
+        map.put("openjpa.MetaDataFactory",
+            "jpa(Types=org.apache.openjpa.persistence.kernel.RuntimeTest1;" +
+                "org.apache.openjpa.persistence.kernel.RuntimeTest2)");
+
+        OpenJPAEntityManagerFactory pmf = getEmf(map);
+        assertClass(RuntimeTest1.class,
+            ((OpenJPAEntityManagerFactorySPI) pmf).getConfiguration(), true);
+
+        assertClass(RuntimeTest2.class,
+            ((OpenJPAEntityManagerFactorySPI) pmf).getConfiguration(), true);
+
+        assertClass(RuntimeTest3.class,
+            ((OpenJPAEntityManagerFactorySPI) pmf).getConfiguration(), false);
+
+        pmf.close();
+    }
+}
+

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestSequenceAssigned.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestSequenceAssigned.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestSequenceAssigned.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestSequenceAssigned.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta;
+
+
+import org.apache.openjpa.persistence.meta.common.apps.SequenceAssigned;
+import org.apache.openjpa.persistence.meta.common.apps.SequenceAssigned2;
+import org.apache.openjpa.persistence.meta.common.apps.SequenceAssigned3;
+import org.apache.openjpa.persistence.common.utils.AbstractTestCase;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+
+public class TestSequenceAssigned
+    extends AbstractTestCase {
+
+    public TestSequenceAssigned(String testName) {
+        super(testName, "metacactusapp");
+    }
+
+    public void setUp() {
+        deleteAll(SequenceAssigned.class);
+        deleteAll(SequenceAssigned3.class);
+    }
+
+    public void testGetObjectId() {
+        SequenceAssigned pc = new SequenceAssigned();
+        OpenJPAEntityManager pm =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+        pm.persist(pc);
+        SequenceAssigned.Id id = (SequenceAssigned.Id)
+            pm.getObjectId(pc);
+        assertTrue(0 != id.pk);
+        assertTrue(0 != pc.getPK());
+        assertEquals(pc.getPK(), id.pk);
+        endTx(pm);
+        endEm(pm);
+    }
+
+    public void testGetValue() {
+        SequenceAssigned pc = new SequenceAssigned();
+        OpenJPAEntityManager pm =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+        assertEquals(0, pc.getPK());
+        pm.persist(pc);
+        assertTrue(0 != pc.getPK());
+        endTx(pm);
+        endEm(pm);
+    }
+
+    public void testPrimitive() {
+        SequenceAssigned pc = new SequenceAssigned();
+        SequenceAssigned pc2 = new SequenceAssigned();
+        OpenJPAEntityManager pm =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+        pm.persist(pc);
+        pm.persist(pc2);
+        pm.flush();
+        assertTrue(0 != pc.getPK());
+        assertTrue(0 != pc2.getPK());
+        assertTrue(pc.getPK() != pc2.getPK());
+        endTx(pm);
+        endEm(pm);
+    }
+
+    public void testManualAssign() {
+        SequenceAssigned pc = new SequenceAssigned();
+        SequenceAssigned3 pc2 = new SequenceAssigned3();
+        OpenJPAEntityManager pm =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+        pc.setPK(-100);
+        pc2.setPK(new Long(-100));
+        pm.persist(pc);
+        pm.persist(pc2);
+        pm.flush();
+        endTx(pm);
+        Object oid = pm.getObjectId(pc);
+        Object oid2 = pm.getObjectId(pc2);
+        endEm(pm);
+        pm = (OpenJPAEntityManager) currentEntityManager();
+        pc = (SequenceAssigned) pm.find(SequenceAssigned.class, oid);
+        pc2 = (SequenceAssigned3) pm.find(SequenceAssigned3.class, oid2);
+        assertEquals(-100, pc.getPK());
+        assertEquals(new Long(-100), pc2.getPK());
+        endEm(pm);
+    }
+
+    public void testInheritance() {
+        SequenceAssigned2 pc = new SequenceAssigned2();
+        SequenceAssigned2 pc2 = new SequenceAssigned2();
+        OpenJPAEntityManager pm =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+        pm.persist(pc);
+        pm.persist(pc2);
+        pm.flush();
+        assertTrue(0 != pc.getPK());
+        assertTrue(0 != pc2.getPK());
+        assertTrue(pc.getPK() != pc2.getPK());
+        endTx(pm);
+        endEm(pm);
+    }
+
+    public void testWrapper() {
+        SequenceAssigned3 pc = new SequenceAssigned3();
+        SequenceAssigned3 pc2 = new SequenceAssigned3();
+        OpenJPAEntityManager pm =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+        pm.persist(pc);
+        pm.persist(pc2);
+        pm.flush();
+        assertNotNull(pc.getPK());
+        assertNotNull(pc2.getPK());
+        assertTrue(0 != pc.getPK().longValue());
+        assertTrue(0 != pc2.getPK().longValue());
+        assertNotEquals(pc.getPK(), pc2.getPK());
+        endTx(pm);
+        endEm(pm);
+    }
+
+    public void testGetObjectById() {
+        OpenJPAEntityManager pm =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+        SequenceAssigned pc = new SequenceAssigned();
+        pm.persist(pc);
+        Object oid = pm.getObjectId(pc);
+        assertTrue(0 != ((SequenceAssigned.Id) oid).pk);
+        endTx(pm);
+        endEm(pm);
+
+        pm = (OpenJPAEntityManager) currentEntityManager();
+        pm.find(SequenceAssigned.class, oid);
+        endEm(pm);
+    }
+
+    public void testReachability() {
+        SequenceAssigned pc = new SequenceAssigned();
+        SequenceAssigned pc2 = new SequenceAssigned();
+        pc.setOther(pc2);
+        OpenJPAEntityManager pm =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+        pm.persist(pc);
+        endTx(pm);
+        SequenceAssigned.Id id = (SequenceAssigned.Id)
+            pm.getObjectId(pc2);
+        assertTrue(0 != id.pk);
+        assertTrue(0 != pc2.getPK());
+        assertEquals(pc2.getPK(), id.pk);
+        endEm(pm);
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestValueStrategies.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestValueStrategies.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestValueStrategies.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestValueStrategies.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,404 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.persistence.EntityManagerFactory;
+
+
+import org.apache.openjpa.persistence.meta.common.apps.ValueStrategyPC;
+import org.apache.openjpa.persistence.common.utils.AbstractTestCase;
+import org.apache.openjpa.meta.ClassMetaData;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.util.OpenJPAException;
+
+/**
+ * <p>Test value and update strategies.  Also tests version fields, which
+ * are represented in JDO as a value strategy.</p>
+ *
+ * @author Abe White
+ */
+public class TestValueStrategies
+    extends AbstractTestCase {
+
+    public TestValueStrategies(String test) {
+        super(test, "metacactusapp");
+    }
+
+    public void setUp() {
+        deleteAll(ValueStrategyPC.class);
+    }
+
+    public void testIgnoreUpdate() {
+        ValueStrategyPC pc = new ValueStrategyPC();
+        pc.setName("pc");
+        pc.setIgnoreUpdate(10);
+
+        OpenJPAEntityManager pm =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+        pm.persist(pc);
+        assertEquals(10, pc.getIgnoreUpdate());
+        endTx(pm);
+        Object oid = pm.getObjectId(pc);
+        endEm(pm);
+
+        //pm = getPM(false, false);
+        pm = (OpenJPAEntityManager) currentEntityManager();
+        pc = (ValueStrategyPC) pm.find(ValueStrategyPC.class, oid);
+        assertNotNull(pc);
+        assertEquals(10, pc.getIgnoreUpdate());
+        startTx(pm);
+        pc.setIgnoreUpdate(100);
+        assertFalse(pm.isDirty(pc));
+        pm.transactional(pc, false);
+        endTx(pm);
+        assertEquals(10, pc.getIgnoreUpdate());
+        endEm(pm);
+
+        pm = (OpenJPAEntityManager) currentEntityManager();
+        pc = (ValueStrategyPC) pm.find(ValueStrategyPC.class, oid);
+        assertNotNull(pc);
+        assertEquals(10, pc.getIgnoreUpdate());
+        endEm(pm);
+    }
+
+    public void testRestrictUpdate() {
+        ValueStrategyPC pc = new ValueStrategyPC();
+        pc.setName("pc");
+        pc.setRestrictUpdate(10);
+
+        OpenJPAEntityManager pm =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+        pm.persist(pc);
+        assertEquals(10, pc.getRestrictUpdate());
+        endTx(pm);
+        Object oid = pm.getObjectId(pc);
+        endEm(pm);
+
+        //pm = getPM(false, false);
+        pm = (OpenJPAEntityManager) currentEntityManager();
+        pc = (ValueStrategyPC) pm.find(ValueStrategyPC.class, oid);
+        assertNotNull(pc);
+        assertEquals(10, pc.getRestrictUpdate());
+        startTx(pm);
+        try {
+            pc.setRestrictUpdate(100);
+            fail("Allowed update of restricted field.");
+        } catch (RuntimeException re) {
+        }
+        endTx(pm);
+        assertEquals(10, pc.getRestrictUpdate());
+        endEm(pm);
+    }
+
+    public void testUUID() {
+        ValueStrategyPC pc = new ValueStrategyPC();
+        ValueStrategyPC pc2 = new ValueStrategyPC();
+        pc.setName("pc");
+        pc2.setName("pc2");
+        assertNull(pc.getUUID());
+        assertNull(pc2.getUUID());
+        assertNull(pc.getUUIDHex());
+        assertNull(pc2.getUUIDHex());
+
+        OpenJPAEntityManager pm =
+            (OpenJPAEntityManager) currentEntityManager();
+        pm.setOptimistic(true);
+        startTx(pm);
+        pm.persist(pc);
+        pm.persist(pc2);
+        String str = pc.getUUID();
+        String hex = pc.getUUIDHex();
+        assertTrue(!pm.isStoreActive());    // no flush needed
+        endTx(pm);
+        String str2 = pc2.getUUID();
+        String hex2 = pc2.getUUIDHex();
+        Object oid = pm.getObjectId(pc);
+        Object oid2 = pm.getObjectId(pc2);
+        endEm(pm);
+
+        assertNotNull(str);
+        assertNotNull(str2);
+        assertTrue(!str.equals(str2));
+        assertNotNull(hex);
+        assertNotNull(hex2);
+        assertTrue(!hex.equals(hex2));
+
+        pm = (OpenJPAEntityManager) currentEntityManager();
+        pc = (ValueStrategyPC) pm.find(ValueStrategyPC.class, oid);
+        pc2 = (ValueStrategyPC) pm.find(ValueStrategyPC.class, oid2);
+        assertEquals(str, pc.getUUID());
+        assertEquals(str2, pc2.getUUID());
+        assertEquals(hex, pc.getUUIDHex());
+        assertEquals(hex2, pc2.getUUIDHex());
+        startTx(pm);
+        pc.setUUIDHex("foo");
+        pc2.setUUIDHex("bar");
+        endTx(pm);
+        endEm(pm);
+
+        pm = (OpenJPAEntityManager) currentEntityManager();
+        pc = (ValueStrategyPC) pm.find(ValueStrategyPC.class, oid);
+        pc2 = (ValueStrategyPC) pm.find(ValueStrategyPC.class, oid2);
+        assertEquals("foo", pc.getUUIDHex());
+        assertEquals("bar", pc2.getUUIDHex());
+        endEm(pm);
+    }
+
+    public void testSequence() {
+        ValueStrategyPC pc = new ValueStrategyPC();
+        ValueStrategyPC pc2 = new ValueStrategyPC();
+        pc.setName("pc");
+        pc2.setName("pc2");
+        assertEquals(0, pc.getSequence());
+        assertEquals(0, pc2.getSequence());
+
+        OpenJPAEntityManager pm =
+            (OpenJPAEntityManager) currentEntityManager();
+        pm.setOptimistic(true);
+        startTx(pm);
+        pm.persist(pc);
+        pm.persist(pc2);
+        int seq = pc.getSequence();
+        assertTrue(!pm.isStoreActive());    // no flush needed
+        endTx(pm);
+        int seq2 = pc2.getSequence();
+        Object oid = pm.getObjectId(pc);
+        Object oid2 = pm.getObjectId(pc2);
+        endEm(pm);
+
+        assertTrue(seq > 0);
+        assertTrue(seq2 > 0);
+        assertTrue(seq != seq2);
+
+        pm = (OpenJPAEntityManager) currentEntityManager();
+        pc = (ValueStrategyPC) pm.find(ValueStrategyPC.class, oid);
+        pc2 = (ValueStrategyPC) pm.find(ValueStrategyPC.class, oid2);
+        assertEquals(seq, pc.getSequence());
+        assertEquals(seq2, pc2.getSequence());
+        startTx(pm);
+        pc.setSequence(99);
+        pc2.setSequence(100);
+        endTx(pm);
+        endEm(pm);
+
+        pm = (OpenJPAEntityManager) currentEntityManager();
+        pc = (ValueStrategyPC) pm.find(ValueStrategyPC.class, oid);
+        pc2 = (ValueStrategyPC) pm.find(ValueStrategyPC.class, oid2);
+        assertEquals(99, pc.getSequence());
+        assertEquals(100, pc2.getSequence());
+        endEm(pm);
+    }
+
+    public void testVersion() {
+        versionTest(getEmf());
+    }
+
+    public void testVersionDataCache() {
+
+        Map map = new HashMap();
+        map.put("openjpa.DataCache", "true");
+        map.put("openjpa.RemoteCommitProvider", "sjvm");
+        versionTest(getEmf(map));
+    }
+
+    private void versionTest(EntityManagerFactory pmf) {
+        ValueStrategyPC pc = new ValueStrategyPC();
+        pc.setName("pc");
+
+        OpenJPAEntityManager pm = (OpenJPAEntityManager)
+            pmf.createEntityManager();
+        startTx(pm);
+        pm.persist(pc);
+        ClassMetaData meta = getConfiguration()
+            .getMetaDataRepositoryInstance().
+            getMetaData(pc.getClass(), null, false);
+        assertNotNull(meta.getVersionField());
+        assertEquals("version", meta.getVersionField().getName());
+        assertEquals(0, pc.getVersion());
+        endTx(pm);
+        assertEquals(1, pc.getVersion());
+        Object oid = pm.getObjectId(pc);
+        endEm(pm);
+
+        // do no-op commit
+        pm = (OpenJPAEntityManager) pmf.createEntityManager();
+        pc = (ValueStrategyPC) pm.find(ValueStrategyPC.class, oid);
+        assertNotNull(pc);
+        assertEquals(1, pc.getVersion());
+        startTx(pm);
+        try {
+            pc.setVersion(10);
+            fail("Allowed change to version field.");
+        } catch (RuntimeException re) {
+        }
+        endTx(pm);
+        assertEquals(1, pc.getVersion());
+        endEm(pm);
+
+        // do real commit
+        pm = (OpenJPAEntityManager) pmf.createEntityManager();
+        pc = (ValueStrategyPC) pm.find(ValueStrategyPC.class, oid);
+        assertNotNull(pc);
+        assertEquals(1, pc.getVersion());
+        startTx(pm);
+        pc.setName("changed");
+        pm.flush();
+        assertEquals(1, pc.getVersion());
+        endTx(pm);
+        assertEquals("changed", pc.getName());
+        assertEquals(2, pc.getVersion());
+        endEm(pm);
+
+        // rollback
+        pm = (OpenJPAEntityManager) pmf.createEntityManager();
+        pc = (ValueStrategyPC) pm.find(ValueStrategyPC.class, oid);
+        assertNotNull(pc);
+        assertEquals(2, pc.getVersion());
+        startTx(pm);
+        pc.setName("changed2");
+        pm.flush();
+        assertEquals(2, pc.getVersion());
+        rollbackTx(pm);
+        assertEquals(2, pc.getVersion());
+        endEm(pm);
+    }
+
+    public void testVersionDetach() {
+        ValueStrategyPC pc = new ValueStrategyPC();
+        ValueStrategyPC pc2 = new ValueStrategyPC();
+        pc.setName("pc");
+        pc2.setName("pc2");
+
+        OpenJPAEntityManager pm =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+        pm.persist(pc);
+        pm.persist(pc2);
+        endTx(pm);
+        startTx(pm);
+        pc.setName("changed");
+        pc2.setName("changed2");
+        endTx(pm);
+        assertEquals(2, pc.getVersion());
+        assertEquals(2, pc2.getVersion());
+        ValueStrategyPC detached = (ValueStrategyPC) pm.detach(pc);
+        ValueStrategyPC detached2 = (ValueStrategyPC) pm.detach(pc2);
+        endEm(pm);
+
+        // clean attach
+        pm = (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+        pc = (ValueStrategyPC) pm.merge(detached);
+        assertEquals(2, pc.getVersion());
+        endTx(pm);
+        assertEquals(2, pc.getVersion());
+        endEm(pm);
+
+        // dirty attach
+        detached.setName("changed-detached");
+        pm = (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+        pc = (ValueStrategyPC) pm.merge(detached);
+        assertEquals(2, pc.getVersion());
+        endTx(pm);
+        assertEquals(3, pc.getVersion());
+        endEm(pm);
+
+        // stale attach
+        detached.setName("stale");
+        pm = (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+        try {
+            pm.merge(detached);
+            endTx(pm);
+            fail("Committed stale version.");
+        } catch (OpenJPAException je) {
+        }
+        if (isActiveTx(pm))
+            rollbackTx(pm);
+        endEm(pm);
+
+        // modify version field in detached; allow either exception or
+        // allow the update to be ignored
+        detached2.setName("changed2-detached");
+        detached2.setVersion(99);
+        pm = (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+        try {
+            pc2 = (ValueStrategyPC) pm.merge(detached2);
+            assertEquals(2, pc2.getVersion());
+            endTx(pm);
+            assertEquals(3, pc2.getVersion());
+        } catch (OpenJPAException je) {
+        }
+        if (isActiveTx(pm))
+            rollbackTx(pm);
+        ;
+        endEm(pm);
+    }
+
+    public void testVersionRefresh() {
+        ValueStrategyPC pc = new ValueStrategyPC();
+        pc.setName("pc");
+
+        OpenJPAEntityManager pm =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm);
+        pm.persist(pc);
+        endTx(pm);
+        startTx(pm);
+        pc.setName("changed");
+        endTx(pm);
+        assertEquals(2, pc.getVersion());
+
+        // clean refresh
+        startTx(pm);
+        pm.refresh(pc);
+        assertEquals(2, pc.getVersion());
+
+        // concurrent mod
+        OpenJPAEntityManager pm2 =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(pm2);
+        ValueStrategyPC pc2 = (ValueStrategyPC) pm2.find
+            (ValueStrategyPC.class, pm2.getObjectId(pc));
+        pc2.setName("changed2");
+        endTx(pm2);
+        assertEquals(3, pc2.getVersion());
+        endEm(pm2);
+
+        // stale refresh
+        pm.refresh(pc);
+        assertEquals(3, pc.getVersion());
+
+        // dirty refresh
+        pc.setName("changed-1");
+        pm.refresh(pc);
+        assertEquals(3, pc.getVersion());
+
+        pc.setName("changed-2");
+        endTx(pm);
+        assertEquals(4, pc.getVersion());
+        endEm(pm);
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestXMLPersistenceMetaDataSerializer.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestXMLPersistenceMetaDataSerializer.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestXMLPersistenceMetaDataSerializer.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestXMLPersistenceMetaDataSerializer.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+
+
+import org.apache.openjpa.persistence.meta.common.apps.MetaTest1;
+import org.apache.openjpa.persistence.meta.common.apps.MetaTest2;
+import org.apache.openjpa.persistence.meta.common.apps.MetaTest3;
+import org.apache.openjpa.persistence.meta.common.apps.MetaTest5;
+import org.apache.openjpa.persistence.meta.common.apps.MetaTest6;
+import org.apache.openjpa.conf.OpenJPAConfiguration;
+import org.apache.openjpa.conf.OpenJPAConfigurationImpl;
+import org.apache.openjpa.meta.MetaDataRepository;
+import org.apache.openjpa.persistence.XMLPersistenceMetaDataParser;
+import org.apache.openjpa.persistence.XMLPersistenceMetaDataSerializer;
+
+/**
+ * <p>Tests the {@link MetaDataSerializer} by parsing all the metadata
+ * files, serializing them to a buffer, then deserializing them from the
+ * buffer and invoking the tests defined by {@link TestClassMetaData}.</p>
+ *
+ * @author Abe White
+ */
+public class TestXMLPersistenceMetaDataSerializer
+    extends TestClassMetaData {
+
+    public TestXMLPersistenceMetaDataSerializer(String test) {
+        super(test);
+    }
+
+    protected MetaDataRepository getRepository()
+        throws Exception {
+        OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
+        MetaDataRepository repos = conf.newMetaDataRepositoryInstance();
+        repos.getMetaData(MetaTest5.class, null, true);
+        repos.getMetaData(MetaTest3.class, null, true);
+        repos.getMetaData(MetaTest2.class, null, true);
+        repos.getMetaData(MetaTest1.class, null, true);
+        repos.getMetaData(MetaTest6.class, null, true);
+
+        XMLPersistenceMetaDataSerializer ser =
+            new XMLPersistenceMetaDataSerializer(conf);
+        ser.addAll(repos);
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        ser.serialize(new OutputStreamWriter(out), ser.PRETTY);
+        byte[] bytes = out.toByteArray();
+
+        XMLPersistenceMetaDataParser parser =
+            new XMLPersistenceMetaDataParser(conf);
+        parser.parse(new InputStreamReader
+            (new ByteArrayInputStream(bytes)), "bytes");
+        return parser.getRepository();
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/ExternalValues.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/ExternalValues.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/ExternalValues.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/ExternalValues.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta.common.apps;
+
+
+import javax.persistence.Entity;
+
+@Entity
+public class ExternalValues {
+
+    private boolean booleanToShort;
+    private byte byteToDouble;
+    private int intToFloat;
+    private long longToChar;
+    private short shortToString;
+    private float floatToBoolean;
+    private double doubleToByte;
+    private char charToInt;
+    private String stringToLong;
+
+    public boolean getBooleanToShort() {
+        return booleanToShort;
+    }
+
+    public void setBooleanToShort(boolean b) {
+        booleanToShort = b;
+    }
+
+    public byte getByteToDouble() {
+        return byteToDouble;
+    }
+
+    public void setByteToDouble(byte b) {
+        byteToDouble = b;
+    }
+
+    public int getIntToFloat() {
+        return intToFloat;
+    }
+
+    public void setIntToFloat(int i) {
+        intToFloat = i;
+    }
+
+    public long getLongToChar() {
+        return longToChar;
+    }
+
+    public void setLongToChar(long l) {
+        longToChar = l;
+    }
+
+    public short getShortToString() {
+        return shortToString;
+    }
+
+    public void setShortToString(short s) {
+        shortToString = s;
+    }
+
+    public double getDoubleToByte() {
+        return doubleToByte;
+    }
+
+    public void setDoubleToByte(double d) {
+        doubleToByte = d;
+    }
+
+    public float getFloatToBoolean() {
+        return floatToBoolean;
+    }
+
+    public void setFloatToBoolean(float f) {
+        floatToBoolean = f;
+    }
+
+    public char getCharToInt() {
+        return charToInt;
+    }
+
+    public void setCharToInt(char c) {
+        charToInt = c;
+    }
+
+    public String getStringToLong() {
+        return stringToLong;
+    }
+
+    public void setStringToLong(String s) {
+        stringToLong = s;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/FieldOrderPC.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/FieldOrderPC.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/FieldOrderPC.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/FieldOrderPC.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta.common.apps;
+
+import javax.persistence.Entity;
+
+@Entity
+public class FieldOrderPC {
+
+    private transient String firstField;
+    private static char staticField;
+    private int intField;
+    private int thirdField;
+    private int unmanagedField;
+    private final Long finalField = null;
+    private Double secondField;
+    private FieldOrderPC oneToOneField;
+}
\ No newline at end of file

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/FieldOrderPCSubclass.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/FieldOrderPCSubclass.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/FieldOrderPCSubclass.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/FieldOrderPCSubclass.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta.common.apps;
+
+import javax.persistence.Entity;
+
+@Entity
+public class FieldOrderPCSubclass
+    extends FieldOrderPC {
+
+    private transient String sub1;
+    private int sub2;
+    private Double sub3;
+    private int unmanagedSubField;
+    private int undeclaredSubField;
+}
\ No newline at end of file

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest1.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest1.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest1.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest1.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta.common.apps;
+
+import javax.persistence.Entity;
+
+import org.apache.openjpa.persistence.PersistentCollection;
+
+@Entity
+public class MetaTest1 {
+
+    // these should not be persistent
+    private static int staticField;
+    private final String finalField = null;
+    private transient char transientField;
+    private MetaTest4 metaTest4Field;
+    //@OneToMany(mappedBy="MetaTest4", fetch=FetchType.LAZY)
+    @PersistentCollection
+    private java.util.Set<MetaTest4> metaTest4ArrayField;
+    //private MetaTest4[] metaTest4ArrayField;
+    private Object objectField;
+    private Long longWrapperField;
+    private double doubleField;
+
+    // persistent fields -- see metadata
+    private String stringField;
+    private Integer intWrapperField;
+    private int intField;
+    private MetaTest2 metaTest2Field;
+    //@OneToMany(mappedBy="MetaTest2", fetch=FetchType.LAZY)
+    @PersistentCollection
+    private java.util.Set<MetaTest2> metaTest2ArrayField;
+    //private MetaTest2[] metaTest2ArrayField;
+    @PersistentCollection
+    private int[] intArrayField;
+
+    @Entity
+    public static class Inner {
+
+        private long longField;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest2.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest2.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest2.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest2.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta.common.apps;
+
+import java.util.Collection;
+import java.util.Map;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.ManyToOne;
+
+@Entity
+public class MetaTest2
+    extends MetaTest1 {
+
+    private Collection collectionField1;
+    private Collection collectionField2;
+    private Map mapField1;
+    private Map mapField2;
+    @ManyToOne(fetch = FetchType.LAZY)
+    private MetaTest2 metaTest2Field;
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest3.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest3.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest3.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest3.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta.common.apps;
+
+import java.util.Map;
+import javax.persistence.Entity;
+
+@Entity
+public class MetaTest3
+    extends MetaTest2 {
+
+    private Object pcField;
+    private Object externalField;
+    private Object metaField;
+
+    public static Map toMap(Object fieldValue) {
+        // dummy method
+        return null;
+    }
+
+    public static Object fromMap(Map externalValue) {
+        // dummy method
+        return null;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest4.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest4.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest4.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest4.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta.common.apps;
+
+import javax.persistence.Entity;
+
+@Entity
+public class MetaTest4 {
+
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest5.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest5.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest5.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest5.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta.common.apps;
+
+import javax.persistence.Entity;
+
+@Entity
+/**
+ * <p>Persistent type used in the testing of the JDO metadata.</p>
+ *
+ * @author Abe White
+ */
+public abstract class MetaTest5 {
+
+    private long id;
+
+    public static class MetaTest5Id {
+
+        public long id;
+
+        public MetaTest5Id() {
+        }
+
+        public MetaTest5Id(String str) {
+            id = Long.parseLong(str);
+        }
+
+        public String toString() {
+            return String.valueOf(id);
+        }
+
+        public boolean equals(Object other) {
+            return other instanceof MetaTest5Id
+                && ((MetaTest5Id) other).id == id;
+        }
+
+        public int hashCode() {
+            return (int) (id % Integer.MAX_VALUE);
+        }
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest6.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest6.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest6.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/MetaTest6.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta.common.apps;
+
+import javax.persistence.Entity;
+
+@Entity
+public class MetaTest6
+    extends MetaTest5 {
+
+    private String name;
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/NonPersistentFieldsPC.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/NonPersistentFieldsPC.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/NonPersistentFieldsPC.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/NonPersistentFieldsPC.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta.common.apps;
+
+import java.io.Serializable;
+import javax.persistence.Entity;
+
+import org.apache.openjpa.meta.ClassMetaData;
+
+@Entity
+public class NonPersistentFieldsPC {
+
+    private String persistentField;
+    private String nonPersistentField;
+    private Object objectField;
+    private Serializable interfaceField;
+    private ClassMetaData userObjectField;
+    private ClassMetaData userInterfaceField;
+    private Object explicitObjectField;
+    private Serializable explicitInterfaceField;
+    private ClassMetaData explicitUserObjectField;
+    private ClassMetaData explicitUserInterfaceField;
+    private Object persistentObjectField;
+    private Serializable persistentInterfaceField;
+    private ClassMetaData persistentUserObjectField;
+    private ClassMetaData persistentUserInterfaceField;
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/OrderByPC.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/OrderByPC.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/OrderByPC.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/OrderByPC.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta.common.apps;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.persistence.Entity;
+
+import org.apache.openjpa.persistence.PersistentCollection;
+
+@Entity
+public class OrderByPC {
+
+    private long id;
+
+    private List stringListAsc = new ArrayList();
+    @PersistentCollection
+    private int[] intArrayDesc;
+    private List orderByPKAsc = new ArrayList();
+    private List orderByStringDesc = new ArrayList();
+    private List orderByStringAndPKDesc = new ArrayList();
+
+    private List oneToManyAsc = new ArrayList();
+
+    public long getId() {
+        return this.id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public List getStringListAsc() {
+        return this.stringListAsc;
+    }
+
+    public int[] getIntArrayDesc() {
+        return this.intArrayDesc;
+    }
+
+    public void setIntArrayDesc(int[] intArrayDesc) {
+        this.intArrayDesc = intArrayDesc;
+    }
+
+    public List getOrderByPKAsc() {
+        return this.orderByPKAsc;
+    }
+
+    public List getOrderByStringDesc() {
+        return this.orderByStringDesc;
+    }
+
+    public List getOrderByStringAndPKDesc() {
+        return this.orderByStringAndPKDesc;
+    }
+
+    public List getOneToManyAsc() {
+        return this.oneToManyAsc;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/OrderByPCRel.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/OrderByPCRel.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/OrderByPCRel.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/OrderByPCRel.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta.common.apps;
+
+import javax.persistence.Entity;
+
+@Entity
+public class OrderByPCRel {
+
+    private long id;
+    private String string;
+    private OrderByPC toOne;
+
+    public long getId() {
+        return this.id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public String getString() {
+        return this.string;
+    }
+
+    public void setString(String string) {
+        this.string = string;
+    }
+
+    public OrderByPC getToOne() {
+        return this.toOne;
+    }
+
+    public void setToOne(OrderByPC toOne) {
+        this.toOne = toOne;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/OrderByPCRelSub.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/OrderByPCRelSub.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/OrderByPCRelSub.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/OrderByPCRelSub.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta.common.apps;
+
+import javax.persistence.Entity;
+
+@Entity
+public class OrderByPCRelSub
+    extends OrderByPCRel {
+
+    private int sub;
+
+    public int getSub() {
+        return this.sub;
+    }
+
+    public void setSub(int sub) {
+        this.sub = sub;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/RuntimeTest1.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/RuntimeTest1.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/RuntimeTest1.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/RuntimeTest1.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,268 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta.common.apps;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+import javax.persistence.Entity;
+
+@Entity
+public class RuntimeTest1
+    implements Serializable {
+
+    public static final String someStaticField = "someField";
+
+    private byte byteField;
+    private boolean booleanField;
+    private char charField;
+    private double doubleField;
+    private float floatField;
+    private int intField;
+    private long longField;
+    private short shortField;
+    private String stringField;
+    private BigInteger bigIntegerField;
+    private BigDecimal bigDecimalField;
+    private Date dateField;
+    private Locale localeField;
+    private Byte byteObjfield;
+    private Boolean booleanObjField;
+    private Character charObjField;
+    private Double doubleObjField;
+    private Float floatObjField;
+    private Integer intObjField;
+    private Long longObjField;
+    private Short shortObjField;
+
+    // transactional only
+    private TransactionalClassPC transField;
+    public String transString;
+
+    // relations
+    private RuntimeTest1 selfOneOne;
+    private Set selfOneMany = new HashSet();
+
+    public RuntimeTest1() {
+    }
+
+    public RuntimeTest1(String str, int i) {
+        stringField = str;
+        intField = i;
+        //FIXME Seetha Oct 25,2006
+        //mySQL 0.0 float issue
+        floatField = 1.0f;
+    }
+
+    public byte getByteField() {
+        return this.byteField;
+    }
+
+    public void setByteField(byte byteField) {
+        this.byteField = byteField;
+    }
+
+    public boolean getBooleanField() {
+        return this.booleanField;
+    }
+
+    public void setBooleanField(boolean booleanField) {
+        this.booleanField = booleanField;
+    }
+
+    public char getCharField() {
+        return this.charField;
+    }
+
+    public void setCharField(char charField) {
+        this.charField = charField;
+    }
+
+    public double getDoubleField() {
+        return this.doubleField;
+    }
+
+    public void setDoubleField(double doubleField) {
+        this.doubleField = doubleField;
+    }
+
+    public float getFloatField() {
+        return this.floatField;
+    }
+
+    public void setFloatField(float floatField) {
+        this.floatField = floatField;
+    }
+
+    public int getIntField() {
+        return this.intField;
+    }
+
+    public void setIntField(int intField) {
+        this.intField = intField;
+    }
+
+    public long getLongField() {
+        return this.longField;
+    }
+
+    public void setLongField(long longField) {
+        this.longField = longField;
+    }
+
+    public short getShortField() {
+        return this.shortField;
+    }
+
+    public void setShortField(short shortField) {
+        this.shortField = shortField;
+    }
+
+    public String getStringField() {
+        return this.stringField;
+    }
+
+    public void setStringField(String stringField) {
+        this.stringField = stringField;
+    }
+
+    public BigInteger getBigIntegerField() {
+        return this.bigIntegerField;
+    }
+
+    public void setBigIntegerField(BigInteger bigIntegerField) {
+        this.bigIntegerField = bigIntegerField;
+    }
+
+    public BigDecimal getBigDecimalField() {
+        return this.bigDecimalField;
+    }
+
+    public void setBigDecimalField(BigDecimal bigDecimalField) {
+        this.bigDecimalField = bigDecimalField;
+    }
+
+    public Date getDateField() {
+        return this.dateField;
+    }
+
+    public void setDateField(Date dateField) {
+        this.dateField = dateField;
+    }
+
+    public Locale getLocaleField() {
+        return this.localeField;
+    }
+
+    public void setLocaleField(Locale localeField) {
+        this.localeField = localeField;
+    }
+
+    public Byte getByteObjfield() {
+        return this.byteObjfield;
+    }
+
+    public void setByteObjfield(Byte byteObjfield) {
+        this.byteObjfield = byteObjfield;
+    }
+
+    public Boolean getBooleanObjField() {
+        return this.booleanObjField;
+    }
+
+    public void setBooleanObjField(Boolean booleanObjField) {
+        this.booleanObjField = booleanObjField;
+    }
+
+    public Character getCharObjField() {
+        return this.charObjField;
+    }
+
+    public void setCharObjField(Character charObjField) {
+        this.charObjField = charObjField;
+    }
+
+    public Double getDoubleObjField() {
+        return this.doubleObjField;
+    }
+
+    public void setDoubleObjField(Double doubleObjField) {
+        this.doubleObjField = doubleObjField;
+    }
+
+    public Float getFloatObjField() {
+        return this.floatObjField;
+    }
+
+    public void setFloatObjField(Float floatObjField) {
+        this.floatObjField = floatObjField;
+    }
+
+    public Integer getIntObjField() {
+        return this.intObjField;
+    }
+
+    public void setIntObjField(Integer intObjField) {
+        this.intObjField = intObjField;
+    }
+
+    public Long getLongObjField() {
+        return this.longObjField;
+    }
+
+    public void setLongObjField(Long longObjField) {
+        this.longObjField = longObjField;
+    }
+
+    public Short getShortObjField() {
+        return this.shortObjField;
+    }
+
+    public void setShortObjField(Short shortObjField) {
+        this.shortObjField = shortObjField;
+    }
+
+    public TransactionalClassPC getTransField() {
+        return this.transField;
+    }
+
+    public void setTransField(TransactionalClassPC transField) {
+        this.transField = transField;
+    }
+
+    public RuntimeTest1 getSelfOneOne() {
+        return this.selfOneOne;
+    }
+
+    public void setSelfOneOne(RuntimeTest1 selfOneOne) {
+        this.selfOneOne = selfOneOne;
+    }
+
+    public Set getSelfOneMany() {
+        return this.selfOneMany;
+    }
+
+    public void setSelfOneMany(Set selfOneMany) {
+        this.selfOneMany = selfOneMany;
+    }
+}



Mime
View raw message