openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r627979 [19/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/jdbc/mapping/TestCompositeIdTraversalInSQLMapping.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/mapping/TestCompositeIdTraversalInSQLMapping.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/mapping/TestCompositeIdTraversalInSQLMapping.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/mapping/TestCompositeIdTraversalInSQLMapping.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,264 @@
+/*
+ * 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.jdbc.mapping;
+
+import java.util.List;
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.openjpa.persistence.jdbc.common.apps.mappingApp.*;
+import org.apache.openjpa.persistence.common.utils.*;
+import junit.framework.*;
+
+
+public class TestCompositeIdTraversalInSQLMapping extends AbstractTestCase 
+{
+	
+	
+	public TestCompositeIdTraversalInSQLMapping(String name)
+	{
+		super(name, "jdbccactusapp");
+	}
+
+	
+	public void setUp()
+	{
+		deleteAll(OwnerOfEntityWithCompositeId.class);
+		deleteAll(EntityWithCompositeId.class);
+	}
+	private void persist(Integer uniqueId, String uniqueName, String relName)
+	{
+		OwnerOfEntityWithCompositeId owner = new OwnerOfEntityWithCompositeId();
+		EntityWithCompositeId relative = new EntityWithCompositeId();
+		owner.setName(uniqueName);
+		relative.setId(uniqueId);
+		relative.setName(relName);
+		relative.setValue("foo");
+		owner.setRelation(relative);
+		
+		EntityManager em = currentEntityManager();
+		startTx(em);
+		em.persist(owner);
+		endTx(em);
+		endEm(em);
+	}
+	public void testTraversalWhenSQLSelectsBothEndOfTheRelation ()
+	{
+		EntityManager em = currentEntityManager();
+		Integer uid  = new Integer((int) (System.currentTimeMillis()%100000));
+		String uName = "P"+uid;
+		String rName = "R"+uName;
+		
+		persist(uid, uName, rName);
+		
+		String sql = "SELECT a.NAME as OWNER_NAME, a.RELATION_ID as REL_ID," +
+		             "a.RELATION_NAME as REL_NAME, b.ID as C_ID," +
+					 "b.NAME as C_NAME, b.VALUE as C_VALUE " +
+		             "FROM OWNER_OF_COMPOSITE_ID a, COMPOSITE_ID b " +
+		             "WHERE a.RELATION_ID=b.ID AND a.RELATION_NAME=b.NAME " +
+		             "AND a.NAME='" + uName + "'";
+		
+		Query query = em.createNativeQuery(sql, 
+			"SQLSelectsBothEndOfTheRelation");
+		
+		List result = query.getResultList();
+		
+		assertEquals(1,result.size());
+		Object object = result.get(0);
+		assertEquals(Object[].class, object.getClass());
+		Object[] array = (Object[])object;
+		assertEquals(2,array.length);
+		assertEquals(OwnerOfEntityWithCompositeId.class,array[0].getClass());
+		assertEquals(EntityWithCompositeId.class,array[1].getClass());
+		
+		OwnerOfEntityWithCompositeId owner = (OwnerOfEntityWithCompositeId)
+			array[0];
+		
+		EntityWithCompositeId relative = (EntityWithCompositeId)array[1];
+		
+		assertEquals(uName, owner.getName());
+		assertEquals(owner.getRelation(), relative);
+		assertEquals(relative.getId(),uid);
+		assertEquals(relative.getName(), rName);
+		assertEquals("foo", relative.getValue());
+		endEm(em);
+	}
+
+	public void testTraversalWhenSQLSelectsOnlyOneEndOfTheRelation ()
+	{
+		EntityManager em = currentEntityManager();
+		Integer uid  = new Integer((int) (System.currentTimeMillis()%100000));
+		String uName = "P"+uid;
+		String rName = "R"+uName;
+		
+		persist (uid, uName, rName);
+		String sql = "SELECT a.NAME as OWNER_NAME, a.RELATION_ID as REL_ID," +
+		             "a.RELATION_NAME as REL_NAME "+
+		             "FROM OWNER_OF_COMPOSITE_ID a " +
+		             "WHERE  a.NAME='" + uName + "'";
+		
+		Query query = em.createNativeQuery(sql, 
+			"SQLSelectsOnlyOneEndOfTheRelation");
+		
+		List result = query.getResultList();
+		
+		assertEquals(1,result.size());
+		Object object = result.get(0);
+		assertEquals(OwnerOfEntityWithCompositeId.class,object.getClass());
+		
+		OwnerOfEntityWithCompositeId owner = (OwnerOfEntityWithCompositeId)
+			object;
+		
+		EntityWithCompositeId relative = owner.getRelation();
+		
+		assertEquals(uName, owner.getName());
+		assertEquals(relative.getId(),uid);
+		assertEquals(relative.getName(), rName);
+		assertEquals("foo", relative.getValue());
+		endEm(em);
+	}
+	public void testTraversalWhenSQLSelectsUnrelatedInstances ()
+	{
+		EntityManager em = currentEntityManager();
+		Integer uid1  = new Integer((int) (System.currentTimeMillis()%100000));
+		Integer uid2  = new Integer(uid1.intValue()+1);
+		String uName1 = "P"+uid1;
+		String rName1 = "R"+uName1;
+		String uName2 = "P"+uid2;
+		String rName2 = "R"+uName2;
+		
+		persist(uid1, uName1, rName1);
+		persist(uid2, uName2, rName2);
+		
+		String sql = "SELECT a.NAME as OWNER_NAME, a.RELATION_ID AS REL_ID," +
+        "a.RELATION_NAME AS REL_NAME, " +
+        "b.ID AS C_ID, b.NAME AS C_NAME, b.VALUE AS C_VALUE "+
+        "FROM OWNER_OF_COMPOSITE_ID a, COMPOSITE_ID b " +
+        "WHERE b.NAME='"+ rName2 +"' " +
+        "AND a.NAME='" + uName1 + "'";
+		
+		Query query = em.createNativeQuery(sql, 
+				"SQLSelectsUnrelatedInstances");
+		
+		List result = query.getResultList();
+		
+		assertEquals(1,result.size());
+		Object object = result.get(0);
+		assertEquals(Object[].class, object.getClass());
+		Object[] array = (Object[])object;
+		assertEquals(2,array.length);
+		assertEquals(OwnerOfEntityWithCompositeId.class,array[0].getClass());
+		assertEquals(EntityWithCompositeId.class,array[1].getClass());
+		
+		OwnerOfEntityWithCompositeId owner1 = (OwnerOfEntityWithCompositeId)
+			array[0];
+		EntityWithCompositeId relative1 = owner1.getRelation();
+		
+		EntityWithCompositeId relative2 = (EntityWithCompositeId)array[1];
+		
+		assertEquals(uName1, owner1.getName());
+		assertEquals(uid1, relative1.getId());
+		assertEquals(rName1, relative1.getName());
+		assertEquals(uid2, relative2.getId());
+		assertEquals(rName2, relative2.getName());
+		endEm(em); 
+	}
+	
+	public void testRecursiveTraversal () 
+	{
+		Integer rootId  = new Integer((int)(System.currentTimeMillis()%100000));
+		
+		int depth = 3;
+		persistChainedRelative(rootId, depth);
+		
+		String sql = createSelfJoinSQL("RECURSIVE_ENTITY",
+				depth,rootId);
+		
+		EntityManager em = currentEntityManager();
+		Query query = em.createNativeQuery(sql, "SQLSelectsChainedRelation");
+
+		List result = query.getResultList();
+		
+		assertEquals(1, result.size());
+		assertEquals(RecursiveEntityWithCompositeId.class,
+				result.get(0).getClass());
+		
+		RecursiveEntityWithCompositeId root = (RecursiveEntityWithCompositeId)
+												result.get(0);
+		assertEquals(rootId,root.getId());
+		assertEquals("P"+rootId,root.getName());
+		for (int i=1; i<depth;i++){
+			RecursiveEntityWithCompositeId relative = root.getRelation();
+			Integer expecetedId = root.getId()+1;
+			assertEquals (expecetedId,relative.getId());
+			assertEquals ("P"+expecetedId, relative.getName());
+			root = relative;
+		}
+		 
+	}
+	
+	void persistChainedRelative(Integer rootId, int depth)
+	{
+		RecursiveEntityWithCompositeId root = 
+			new RecursiveEntityWithCompositeId();
+		root.setId(rootId);
+		root.setName("P"+rootId);
+		RecursiveEntityWithCompositeId head = root;
+		for (int i=1; i<=depth; i++)
+		{
+			RecursiveEntityWithCompositeId relation = 
+				new RecursiveEntityWithCompositeId();
+			relation.setId(rootId+i);
+			relation.setName("P"+(rootId+i));
+			head.setRelation(relation);
+			head = relation;
+		}
+		EntityManager em = currentEntityManager();
+		startTx(em);
+		em.persist(root);
+		endTx(em);
+		endEm(em);
+	}
+	
+	String createSelfJoinSQL(String table, int depth, int id)
+	{
+		
+		StringBuffer sql = new StringBuffer("SELECT ");
+		for (int i=0; i<depth; i++)
+			sql.append("t"+i+".ID AS T"+i+"_ID, ")
+			   .append("t"+i+".NAME AS T"+i+"_NAME, ")
+			   .append("t"+i+".RELATION_ID AS T"+i+"_REL_ID, ")
+			   .append("t"+i+".RELATION_NAME AS T"+i+"_REL_NAME")
+			   .append((i==(depth-1))?" " : ", ");
+		
+		sql.append(" FROM ");
+		for (int i=0; i<depth; i++)
+			sql.append(table + " t"+i)
+			   .append((i==(depth-1))?" " : ", ");
+		
+		sql.append(" WHERE ");
+		for (int i=0; i<(depth-1); i++)
+			sql.append("t"+i+".RELATION_ID=t"+(i+1)+".ID AND ")
+			   .append("t"+i+".RELATION_NAME=t"+(i+1)+".NAME AND " );
+		
+		sql.append("t0.ID="+id);
+		
+		return sql.toString();
+	}
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/mapping/TestNativeQueries.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/mapping/TestNativeQueries.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/mapping/TestNativeQueries.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/mapping/TestNativeQueries.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,170 @@
+/*
+ * 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.jdbc.mapping;
+
+
+import javax.persistence.*;
+import java.util.*;
+
+import org.apache.openjpa.persistence.jdbc.common.apps.mappingApp.*;
+import org.apache.openjpa.persistence.common.utils.*;
+import junit.framework.*;
+
+
+public class TestNativeQueries	extends AbstractTestCase
+{
+	
+	public TestNativeQueries(String name)
+	{
+		super(name, "jdbccactusapp");
+	}
+
+    public void setUp ()
+	{
+		deleteAll (Entity1.class);
+	}
+
+	public void testSimple ()
+	{
+		deleteAll (Entity1.class);
+
+		// test create
+		{
+			EntityManager em = currentEntityManager( );
+			startTx(em);
+			em.persist (new Entity1 (0, "testSimple", 12));
+			endTx(em);
+			endEm(em);
+		}
+
+		// test Query
+		{
+/*			JDBCConfiguration conf = (JDBCConfiguration)getConfiguration ();
+			DBDictionary dict = conf.getDBDictionaryInstance ();*/
+
+/*			String tableName = dict.getFullName (conf.getMappingRepository ().
+				getMapping (Entity1.class, getClass ().getClassLoader (), true).
+				getTable (), false);*/
+
+			EntityManager em = currentEntityManager( );
+			startTx(em);
+			String tableName = "entity_1";
+			assertSize (1, em.createNativeQuery
+				("SELECT * FROM " + tableName, Entity1.class).
+				getResultList ());
+			assertSize (1, em.createNativeQuery ("SELECT * FROM " + tableName
+				+ " WHERE INTFIELD = 12", Entity1.class).
+				getResultList ());
+
+			assertSize (1, em.createNativeQuery ("SELECT * FROM " + tableName
+				+ " WHERE INTFIELD = ?1", Entity1.class).
+				setParameter (1, 12).
+				getResultList ());
+
+			// make sure that out-of-order parameters work
+			assertSize (1, em.createNativeQuery ("SELECT * FROM " + tableName
+				+ " WHERE INTFIELD = ?2 AND STRINGFIELD = ?1", Entity1.class).
+				setParameter (2, 12).
+				setParameter (1, "testSimple").
+				getResultList ());
+
+			// make sure duplicate parameters work
+			assertSize (1, em.createNativeQuery ("SELECT * FROM " + tableName
+				+ " WHERE INTFIELD = ?1 AND INTFIELD = ?1", Entity1.class).
+				setParameter (1, 12).
+				getResultList ());
+
+			assertSize (1, em.createNativeQuery ("SELECT * FROM " + tableName
+				+ " WHERE INTFIELD = ?1 OR INTFIELD = ?2", Entity1.class).
+				setParameter (1, 12).
+				setParameter (2, 13).
+				getResultList ());
+
+			// make sure that quoted parameters are ignored as expected
+			assertSize (1, em.createNativeQuery ("SELECT * FROM " + tableName
+				+ " WHERE INTFIELD = ?1 OR STRINGFIELD = '?5'", Entity1.class).
+				setParameter (1, 12).
+				getResultList ());
+
+			// test without spaces
+			assertSize (1, em.createNativeQuery ("SELECT * FROM " + tableName
+				+ " WHERE INTFIELD=?1 OR STRINGFIELD='?5'", Entity1.class).
+				setParameter (1, 12).
+				getResultList ());
+
+/*			assertSize (1, ((QueryImpl)em.createNativeQuery
+				("SELECT * FROM " + tableName
+					+ " WHERE INTFIELD = ?1 OR INTFIELD = ?2", Entity1.class)).
+				setParameters (12, 1).
+				getResultList ());
+
+			assertSize (0, ((QueryImpl)em.createNativeQuery
+				("SELECT * FROM " + tableName
+					+ " WHERE INTFIELD = ?1 AND INTFIELD = ?2", Entity1.class)).
+				setParameters (12, 1).
+				getResultList ());
+*/
+			assertSize (0, em.createNativeQuery ("SELECT * FROM " + tableName
+				+ " WHERE INTFIELD = ?1 AND INTFIELD = ?2", Entity1.class).
+				setParameter (1, 12).
+				setParameter (2, 13).
+				getResultList ());
+
+			try
+			{
+				em.createNativeQuery ("SELECT * FROM " + tableName
+					+ " WHERE INTFIELD = ?1", Entity1.class).
+					setParameter (0, 12).
+					getResultList ();
+				fail ("Should not have been able to use param index 0");
+			}
+			catch (Exception e)
+			{
+				// as expected
+			}
+
+
+			/*
+			 * Named parameters are not supported according to 19 June 3.5.2:
+			 *
+			 * The use of named parameters is not defined for
+			 * native queries. Only positional parameter binding
+			 * for SQL queries may be used by portable applications.
+			 *
+			assertSize (1, em.createNativeQuery ("SELECT * FROM " + tableName
+				+ " WHERE INTFIELD = :p",  Entity1.class).
+				setParameter ("p", 12).
+				getResultList ());
+			assertSize (1, em.createNativeQuery ("SELECT * FROM " + tableName
+				+ " WHERE INTFIELD = :p OR INTFIELD = :p", Entity1.class).
+				setParameter ("p", 12).
+				getResultList ());
+			*/
+
+			endTx(em);
+			endEm(em);
+		}
+	}
+	
+	public boolean assertSize(int num, List l)
+	{
+		return(num == l.size());
+	}
+}
+

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestBuildSchema.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestBuildSchema.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestBuildSchema.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestBuildSchema.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,99 @@
+/*
+ * TestBuildSchema.java
+ *
+ * Created on October 4, 2006, 4:52 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+/*
+ * 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.jdbc.meta;
+
+import com.sun.org.apache.regexp.internal.REUtil;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.StringWriter;
+import java.util.*;
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
+import org.apache.openjpa.jdbc.meta.MappingTool;
+
+import org.apache.openjpa.persistence.jdbc.common.apps.*;
+
+
+import java.lang.annotation.Annotation;
+import junit.framework.*;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+
+
+public class TestBuildSchema extends org.apache.openjpa.persistence.jdbc.kernel.BaseJDBCTest{
+       
+    /** Creates a new instance of TestBuildSchema */
+    public TestBuildSchema() {
+    }
+    public TestBuildSchema(String test) {
+        super(test);
+    }
+
+    public void testSchema()
+        throws Exception {
+        StringWriter out = new StringWriter();
+
+        MappingTool tool = new MappingTool((JDBCConfiguration)
+            getConfiguration(), MappingTool.ACTION_BUILD_SCHEMA, false);
+        tool.setMappingWriter(new StringWriter());    // throw away
+        tool.setSchemaWriter(out);
+        tool.run(BuildSchemaPC.class);
+        tool.record();
+
+        BufferedReader in = new BufferedReader(new InputStreamReader
+            (getClass().getResourceAsStream("TestBuildSchema-schema.rsrc")));
+        StringBuffer buf = new StringBuffer();
+        for (int ch; (ch = in.read()) != -1;)
+            buf.append((char) ch);
+        in.close();
+
+        // the <schema> sometimes has a name (depending on whether the database
+        // reports a schema name or not). If there is a
+        // <scheme name="something">, then replace it with <schema> so
+        // the match is successful.
+        String schema = out.toString();
+        schema = REUtil.createRE
+            ("<schema name=\"*\">").subst(schema, "<schema>");
+
+        // convert CRLF to CR so we pass on Windows
+        assertEquals(fixNewline(buf.toString()).trim(),
+            fixNewline(schema).trim());
+    }
+
+    private String fixNewline(String str) {
+        //FIXME 
+        /*
+        return serp.util.Strings.join
+            (serp.util.Strings.split
+                (str, "\r\n", -1), "\n");
+         */
+        return "";
+    }
+    
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestDFG.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestDFG.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestDFG.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestDFG.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,115 @@
+/*
+ * TestDFG.java
+ *
+ * Created on October 2, 2006, 5:55 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+/*
+ * 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.jdbc.meta;
+
+import java.util.*;
+import javax.persistence.EntityTransaction;
+import org.apache.openjpa.kernel.OpenJPAStateManager;
+import org.apache.openjpa.meta.FieldMetaData;
+
+import org.apache.openjpa.persistence.jdbc.common.apps.*;
+
+
+import java.lang.annotation.Annotation;
+import junit.framework.*;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+
+
+
+public class TestDFG extends org.apache.openjpa.persistence.jdbc.kernel.BaseJDBCTest{
+    
+    private Object oid;
+    /** Creates a new instance of TestDFG */
+    public TestDFG(String name)
+    {
+    	super(name);
+    }
+    
+    public void setUp() {
+       deleteAll(DFGTest.class);
+        OpenJPAEntityManager pm = (OpenJPAEntityManager)currentEntityManager();
+        EntityTransaction t= pm.getTransaction();
+        t.begin();
+        DFGTest a = new DFGTest();
+        pm.persist(a);
+        a.setNonDFGField(2);
+        t.commit();
+        
+        // modify a field so that if we're examining sql we can see
+        // how much is flushed.
+        t.begin();
+        a.setDFGField(1);
+        t.commit();
+        
+        oid = pm.getObjectId(a);
+        pm.close();
+    }
+    
+    public void testDFG() {
+        OpenJPAEntityManager pm = (OpenJPAEntityManager)currentEntityManager();
+        
+        DFGTest a = (DFGTest) pm.getObjectId(oid);
+        
+        // check the non-dfg fields
+        
+        OpenJPAStateManager sm = getStateManager(a,pm);
+        FieldMetaData fmd = sm.getMetaData().getField("nonDFGField");
+        assertTrue("nonDFGField should not be loaded",
+                !sm.getLoaded().get(fmd.getIndex()));
+        
+        fmd = sm.getMetaData().getField("dfgField");
+        assertTrue("dfgField should be loaded",
+                sm.getLoaded().get(fmd.getIndex()));
+        
+        int val = a.getNonDFGField();
+        assertTrue("nonDFGField should be loaded",
+                sm.getLoaded().get(fmd.getIndex()));
+        assertEquals(2, val);
+        
+        pm.close();
+    }
+    
+    // it'd be nice if we could actually automate this test. As it
+    // stands, this is just here so that there's an easy place to look
+    // at the SQL.
+    public void testDFGWrites() {
+        OpenJPAEntityManager pm = (OpenJPAEntityManager)currentEntityManager();
+        startTx(pm);
+        
+        
+        DFGTest a = (DFGTest) pm.getObjectId(oid);
+        a.setDFGField(3);
+        endTx(pm);
+        
+        pm.close();
+    }
+    
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBByteArray.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBByteArray.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBByteArray.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBByteArray.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,140 @@
+/*
+ * 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.jdbc.meta;
+
+import javax.persistence.EntityManager;
+
+import org.apache.openjpa.persistence.common.utils.*;
+
+import org.apache.openjpa.persistence.kernel.common.apps.*;
+
+import junit.framework.*;
+
+public class TestEJBByteArray extends org.apache.openjpa.persistence.jdbc.kernel.BaseJDBCTest
+{
+	private int _null;
+	private int _empty;
+	private int _small;
+	private int _large;
+
+
+	public TestEJBByteArray(String name)
+	{
+		super(name);
+	}
+
+	public void setUp() throws Exception
+	{
+		deleteAll(ByteArray.class);
+
+		EntityManager pm = currentEntityManager();
+		startTx(pm);
+
+		ByteArray pc = new ByteArray ("Null", 1);
+		pm.persist (pc);
+		_null = 1;
+
+		pc = new ByteArray ("Empty", 2);
+		pc.setBytes (new byte[0]);
+		pm.persist (pc);
+		_empty = 2;
+
+		pc = new ByteArray ("Small", 3);
+		pc.setBytes (pc.getString ().getBytes ());
+		pm.persist (pc);
+		_small = 3;
+
+		byte[] bytes = new byte [10000];
+		for (int i = 0; i < bytes.length; i++)
+			bytes[i] = (byte) (i % 8);
+
+		pc = new ByteArray ("Large", 4);
+		pc.setBytes (bytes);
+		pm.persist (pc);
+		_large = 4;
+
+		endTx(pm);
+		endEm(pm);
+	}
+
+	public void testNull ()
+	{
+		EntityManager pm = currentEntityManager();
+		startTx(pm);
+
+		ByteArray pc = pm.find(ByteArray.class, _null);
+		assertNull (pc.getBytes ());
+
+
+		pc.setBytes ("Not Null".getBytes ());
+		endTx(pm);
+		endEm(pm);
+
+		pm = currentEntityManager();
+		startTx(pm);
+		pc = pm.find(ByteArray.class, _null);
+
+		assertEquals ("Not Null", new String (pc.getBytes ()));
+
+		endTx(pm);
+		endEm(pm);
+	}
+
+	public void testEmpty ()
+	{
+		EntityManager pm = currentEntityManager();
+		startTx(pm);
+
+		ByteArray pc = pm.find(ByteArray.class, _empty);
+		byte [] bytes = pc.getBytes ();
+		assertNotNull (bytes);
+		assertEquals (0, bytes.length);
+
+		pc.setBytes ("Not Empty".getBytes ());
+		endTx(pm);
+		endEm(pm);
+
+		pm = currentEntityManager();
+		startTx(pm);
+		pc = pm.find(ByteArray.class, _empty);
+		assertEquals ("Not Empty", new String (pc.getBytes ()));
+		endTx(pm);
+		endEm(pm);
+	}
+
+	public void testLarge ()
+	{
+		EntityManager pm = currentEntityManager();
+		startTx(pm);
+		ByteArray pc = pm.find(ByteArray.class, _large);
+		byte [] bytes = pc.getBytes ();
+		assertNotNull (bytes);
+		assertEquals (10000, bytes.length);
+		for (int i = 0; i < bytes.length; i++)
+			assertEquals (bytes[i], (byte) (i % 8));
+		endTx(pm);
+		endEm(pm);
+	}
+
+
+
+
+
+
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBColumnIOMappings.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBColumnIOMappings.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBColumnIOMappings.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBColumnIOMappings.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,165 @@
+/*
+ * 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.jdbc.meta;
+
+import javax.persistence.EntityManager;
+
+import org.apache.openjpa.persistence.common.utils.*;
+
+import org.apache.openjpa.persistence.kernel.common.apps.*;
+import junit.framework.*;
+
+public class TestEJBColumnIOMappings extends org.apache.openjpa.persistence.jdbc.kernel.BaseJDBCTest
+{
+	public TestEJBColumnIOMappings(String name)
+	{
+		super(name);
+	}
+
+	public void setUp()
+	{
+		deleteAll(ColumnIOPC.class);
+	}
+
+	public void testIgnoreInsert ()
+	{
+		ColumnIOPC pc = new ColumnIOPC (2);
+		pc.setName ("pc");
+		pc.setIgnoreInsert (10);
+
+		EntityManager pm = currentEntityManager();
+		startTx(pm);
+		pm.persist(pc);
+		assertEquals (10, pc.getIgnoreInsert ());
+		endTx(pm);
+
+		startTx(pm);
+		assertEquals (10, pc.getIgnoreInsert ());
+		int oid = pc.getId();
+        endTx(pm);
+		endEm(pm);
+
+		pm = currentEntityManager();
+		startTx(pm);
+		pc = pm.find(ColumnIOPC.class, oid);
+		assertNotNull (pc);
+		assertEquals (10, pc.getIgnoreInsert ());
+		pc.setIgnoreInsert (10);
+		endTx(pm);
+		startTx(pm);
+		assertEquals (10, pc.getIgnoreInsert ());
+		endTx(pm);
+		endEm(pm);
+
+		pm = currentEntityManager();
+		startTx(pm);
+		pc = pm.find(ColumnIOPC.class, oid);
+		assertNotNull (pc);
+		assertEquals (10, pc.getIgnoreInsert ());
+		endTx(pm);
+		endEm(pm);
+	}
+
+	public void testIgnoreUpdate ()
+	{
+		ColumnIOPC pc = new ColumnIOPC (3);
+		pc.setName ("pc");
+		pc.setIgnoreUpdate (10);
+
+		EntityManager pm = currentEntityManager();
+		startTx(pm);
+		pm.persist(pc);
+		assertEquals (10, pc.getIgnoreUpdate ());
+		endTx(pm);
+
+		Object oid = pc.getId();
+		endEm(pm);
+
+		pm = currentEntityManager();
+		startTx(pm);
+		pc = pm.find(ColumnIOPC.class, oid);
+		assertNotNull (pc);
+		assertEquals (10, pc.getIgnoreUpdate ());
+		endTx(pm);
+
+		startTx(pm);
+		pc.setIgnoreUpdate (100);
+		assertEquals (100, pc.getIgnoreUpdate ());
+		endTx(pm);
+		endEm(pm);
+
+		pm = currentEntityManager();
+		startTx(pm);
+		pc = pm.find(ColumnIOPC.class, oid);
+		assertNotNull (pc);
+		assertEquals (10, pc.getIgnoreUpdate ());
+		endTx(pm);
+		endEm(pm);
+	}
+
+
+	public void testPrimitiveMappedToFieldOfForeignKey ()
+	{
+		// have to make rel persistent before setting ident field b/c not
+		// insertable
+		ColumnIOPC rel = new ColumnIOPC (1);
+		rel.setName ("rel");
+		EntityManager pm = currentEntityManager();
+		startTx(pm);
+		pm.persist(rel);
+		endTx(pm);
+
+		startTx(pm);
+		ColumnIOPC pc = new ColumnIOPC (2);
+		pc.setName ("pc");
+		rel = pm.find(ColumnIOPC.class, 1);
+		pc.setRel (rel);
+		rel.setIdent (10);
+		pm.persist(pc);
+		endTx(pm);
+
+		endEm(pm);
+
+		pm = currentEntityManager();
+		startTx(pm);
+		pc = pm.find(ColumnIOPC.class, 2);
+		assertNotNull (pc);
+		assertEquals (0, pc.getIdent ());
+		assertNotNull (pc.getRel ());
+		assertEquals ("rel", pc.getRel ().getName ());
+
+		pc.setIdent (50);
+		pc.setRel (new ColumnIOPC (3));
+		endTx(pm);
+		endEm(pm);
+
+		pm = currentEntityManager();
+		startTx(pm);
+		pc = pm.find(ColumnIOPC.class, 2);
+		assertNotNull (pc);
+		assertEquals (50, pc.getIdent());
+		assertNotNull (pc.getRel());
+		endTx(pm);
+		endEm(pm);
+	}
+
+
+
+
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBConstantJoinOnSameRefTable.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBConstantJoinOnSameRefTable.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBConstantJoinOnSameRefTable.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBConstantJoinOnSameRefTable.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,110 @@
+/*
+ * 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.jdbc.meta;
+
+import java.util.Iterator;
+
+import javax.persistence.EntityManager;
+
+import org.apache.openjpa.persistence.common.utils.*;
+
+import org.apache.openjpa.persistence.jdbc.common.apps.ConstantJoinPC4;
+import org.apache.openjpa.persistence.jdbc.common.apps.ConstantJoinPC5;
+
+import junit.framework.*;
+
+public class TestEJBConstantJoinOnSameRefTable extends org.apache.openjpa.persistence.jdbc.kernel.BaseJDBCTest
+{
+	private int oid;
+	
+	public TestEJBConstantJoinOnSameRefTable(String name)
+	{
+		super(name);
+	}
+
+	@SuppressWarnings("unchecked")
+	public void setUp ()
+	{
+		deleteAll(ConstantJoinPC4.class);
+		deleteAll(ConstantJoinPC5.class);
+
+		ConstantJoinPC4 pc4 = new ConstantJoinPC4 ("pc4-1", 1);
+		pc4.setOneToOne1 (new ConstantJoinPC5 ("pc5-one-to-one-1"));
+		//### see note in testConstantOneToOne2
+		//### pc4.setOneToOne2 (new ConstantJoinPC5 ("pc5-one-to-one-2"));
+		pc4.getManyToMany ().add (new ConstantJoinPC5 ("pc5-many-to-many-1"));
+		pc4.getManyToMany ().add (new ConstantJoinPC5 ("pc5-many-to-many-2"));
+
+		EntityManager pm = currentEntityManager();
+		startTx(pm);
+		pm.persist(pc4);
+		endTx(pm);
+		oid = pc4.getId();
+		endEm(pm);
+	}
+
+	public void testConstantManyToMany ()
+	{
+		EntityManager pm = currentEntityManager();
+		startTx(pm);
+		ConstantJoinPC4 pc4 = pm.find(ConstantJoinPC4.class, oid);
+		assertEquals (2, pc4.getManyToMany ().size ());
+		Iterator iter = pc4.getManyToMany ().iterator ();
+		ConstantJoinPC5 pc5_1 = (ConstantJoinPC5) iter.next ();
+		ConstantJoinPC5 pc5_2 = (ConstantJoinPC5) iter.next ();
+		if ("pc5-many-to-many-2".equals (pc5_1.getName ()))
+		{
+			ConstantJoinPC5 other = pc5_1;
+			pc5_1 = pc5_2;
+			pc5_2 = other;
+		}
+		assertEquals ("pc5-many-to-many-1", pc5_1.getName ());
+		assertEquals ("pc5-many-to-many-2", pc5_2.getName ());
+		endTx(pm);
+		endEm(pm);
+	}
+
+
+	public void testConstantOneToOne1 ()
+	{
+		EntityManager pm = currentEntityManager();
+		startTx(pm);
+		ConstantJoinPC4 pc4 =  pm.find(ConstantJoinPC4.class, oid);
+		assertEquals (2, pc4.getManyToMany ().size ());
+		assertEquals ("pc5-one-to-one-1", pc4.getOneToOne1 ().getName ());
+
+		endTx(pm);
+		endEm(pm);
+	}
+
+	public void testSharedJoinTableModifications ()
+	{
+		EntityManager pm = currentEntityManager();
+		ConstantJoinPC4 pc4 = pm.find(ConstantJoinPC4.class, oid);
+		startTx(pm);
+		pc4.getManyToMany ().clear ();
+		endTx(pm);
+
+		EntityManager pm2 = currentEntityManager();
+		pc4 = pm2.find(ConstantJoinPC4.class, oid);
+		assertNotNull (pc4.getOneToOne1 ());
+		assertEquals (0, pc4.getManyToMany ().size ());
+	}
+
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBCustomMapping.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBCustomMapping.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBCustomMapping.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBCustomMapping.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,85 @@
+/*
+ * 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.jdbc.meta;
+
+import javax.persistence.EntityManager;
+
+import org.apache.openjpa.persistence.common.utils.*;
+
+import org.apache.openjpa.persistence.jdbc.common.apps.CustomMappingPC;
+import junit.framework.*;
+
+
+public class TestEJBCustomMapping extends org.apache.openjpa.persistence.jdbc.kernel.BaseJDBCTest
+{
+	private int _oid;
+
+	public TestEJBCustomMapping(String name)
+	{
+		super(name);
+	}
+
+	public void setUp ()
+	{
+		deleteAll(CustomMappingPC.class);
+
+		CustomMappingPC pc = new CustomMappingPC (2);
+		pc.setName ("name");
+		pc.setFemale (true);
+
+		EntityManager pm = currentEntityManager();
+		startTx(pm);
+		pm.persist(pc);
+		endTx(pm);
+		_oid = pc.getId();
+		endEm(pm);
+	}
+
+	public void testInsert ()
+	{
+		EntityManager pm = currentEntityManager();
+		CustomMappingPC pc = pm.find(CustomMappingPC.class, _oid);
+		assertNotNull (pc);
+
+		assertEquals ("name", pc.getName ());
+		assertEquals (true, pc.isFemale ());
+		endEm(pm);
+	}
+
+	public void testUpdate ()
+	{
+		EntityManager pm = currentEntityManager();
+		startTx(pm);
+		CustomMappingPC pc = pm.find(CustomMappingPC.class, _oid);
+
+		pc.setName ("name2");
+		pc.setFemale (false);
+		endTx(pm);
+		endEm(pm);
+
+		pm = currentEntityManager();
+		startTx(pm);
+		pc = pm.find(CustomMappingPC.class, _oid);
+		assertEquals ("name2", pc.getName ());
+		assertTrue (!pc.isFemale ());
+		endTx(pm);
+		endEm(pm);
+	}
+
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBDateVersion.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBDateVersion.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBDateVersion.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBDateVersion.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,119 @@
+/*
+ * 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.jdbc.meta;
+
+import javax.persistence.EntityManager;
+
+import org.apache.openjpa.persistence.common.utils.*;
+
+import org.apache.openjpa.persistence.kernel.common.apps.DateVersion;
+import junit.framework.*;
+
+public class TestEJBDateVersion extends org.apache.openjpa.persistence.jdbc.kernel.BaseJDBCTest
+{
+	private int oid;
+
+	public TestEJBDateVersion(String name)
+	{
+		super(name);
+	}
+
+	public void setUp() throws Exception
+	{
+		deleteAll(DateVersion.class);
+
+		DateVersion pc = new DateVersion ("pc1", 1);
+
+		EntityManager pm = currentEntityManager();
+		startTx(pm);
+		pm.persist(pc);
+
+		oid = pc.getId();
+
+		endTx(pm);
+		endEm(pm);
+	}
+
+	public void testOptLock ()	throws InterruptedException
+{
+	EntityManager pm1 = currentEntityManager();
+	EntityManager pm2 = currentEntityManager();
+
+
+	startTx(pm1);
+	startTx(pm2);
+	DateVersion pc1 = (DateVersion) pm1.find(DateVersion.class, oid);
+	DateVersion pc2 = (DateVersion) pm2.find(DateVersion.class, oid);
+
+	pc1.setString ("pc-2-1");
+	pc2.setString ("pc-2-2");
+
+	// some DBs do not distinguish dates unless there is 1 sec diff
+	Thread.currentThread ().sleep (1 * 1000);
+	endTx(pm1);
+	try
+	{
+		Thread.currentThread ().sleep (1 * 1000);
+		endTx(pm2);
+		fail ("Should have caused OL exception.");
+	}
+	catch (Exception jfe)
+	{
+		startTx(pm2);
+		pm2.refresh (pc2);
+		pc2.setString ("pc-3-2");
+		endTx(pm2);
+	}
+
+	// make sure the next transaction works too
+	startTx(pm2);
+	pc2.setString ("pc-string-4-2");
+	endTx(pm2);
+
+	startTx(pm1);
+	pm1.refresh (pc1);
+	pc1.setString ("pc-string-3-1");
+
+	startTx(pm2);
+	pc2.setString ("pc-string-5-2");
+
+	Thread.currentThread ().sleep (1 * 1000);
+	endTx(pm1);
+	try
+	{
+		Thread.currentThread ().sleep (1 * 1000);
+		endTx(pm2);
+		fail ("Should have caused OL exception2.");
+	}
+	catch (Exception jfe)
+	{
+		startTx(pm2);
+		pm2.refresh (pc2);
+		pc2.setString ("pc-string-6-2");
+		endTx(pm2);
+	}
+	endEm(pm1);
+	endEm(pm2);
+
+	EntityManager pm = currentEntityManager();
+	DateVersion pc = pm.find(DateVersion.class, oid);
+	assertEquals ("pc-string-6-2", pc.toString ());
+	endEm(pm);
+  }
+}
\ No newline at end of file

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBEager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBEager.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBEager.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBEager.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,153 @@
+/*
+ * 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.jdbc.meta;
+
+import javax.persistence.EntityManager;
+
+import org.apache.openjpa.persistence.common.utils.*;
+
+import org.apache.openjpa.persistence.jdbc.common.apps.*;
+import junit.framework.*;
+
+public class TestEJBEager extends org.apache.openjpa.persistence.jdbc.kernel.BaseJDBCTest
+{
+	private int _oid;
+
+	public TestEJBEager(String name)
+	{
+		super(name);
+	}
+
+	@SuppressWarnings("unchecked")
+	public void setUp()
+	{
+		deleteAll(EagerPCSub.class);
+		deleteAll(EagerPC.class);
+		deleteAll(HelperPC.class);
+		deleteAll(HelperPC2.class);
+		deleteAll(HelperPC4.class);
+		deleteAll(HelperPC3.class);
+
+		EagerPCSub pc = new EagerPCSub (1);
+		pc.setStringField ("string1");
+		EagerPCSub pc2 = new EagerPCSub (2);
+		pc2.setStringField ("string2");
+
+		HelperPC helper1 = new HelperPC (4);
+		helper1.setStringField ("helper1");
+		pc.setHelper (helper1);
+
+		HelperPC2 helperCollection1 = new HelperPC2 ();
+		helperCollection1.setStringField ("helperCollection1");
+		helperCollection1.getHelperCollection ().add (new HelperPC (5));
+		HelperPC2 helperCollection2 = new HelperPC2 (6);
+		helperCollection2.setStringField ("helperCollection2");
+		pc.getHelperCollection ().add (helperCollection1);
+		pc.getHelperCollection ().add (helperCollection2);
+
+		HelperPC eager = new HelperPC (7);
+		eager.setStringField ("eager");
+		pc.setEager (eager);
+
+		HelperPC4 eagerSub = new HelperPC4 ();
+		eagerSub.setStringField ("eagerSub");
+		eagerSub.setIntField (1);
+		pc.setEagerSub (eagerSub);
+
+		HelperPC eagerCollection1 = new HelperPC (8);
+		eagerCollection1.setStringField ("eagerCollection1");
+		HelperPC eagerCollection2 = new HelperPC (9);
+		eagerCollection2.setStringField ("eagerCollection2");
+		pc.getEagerCollection ().add (eagerCollection1);
+		pc.getEagerCollection ().add (eagerCollection2);
+		eagerCollection1.setEager (pc);
+		eagerCollection2.setEager (pc);
+		pc.getEagerCollection2 ().add (eagerCollection1);
+		pc.getEagerCollection2 ().add (eagerCollection2);
+
+		HelperPC eagerCollection3 = new HelperPC (10);
+		eagerCollection3.setStringField ("eagerCollection3");
+		pc2.getEagerCollection ().add (eagerCollection3);
+
+		HelperPC2 recurse = new HelperPC2 (11);
+		recurse.setStringField ("recurse");
+		HelperPC3 helper3 = new HelperPC3 (12);
+		helper3.setStringField ("helper3");
+		recurse.setHelper (helper3);
+		eager.setHelper (helper1);
+		pc.setRecurse (recurse);
+
+		HelperPC2 recurseCollection1 = new HelperPC2 (13);
+		recurseCollection1.setStringField ("recurseCollection1");
+		HelperPC2 recurseCollection2 = new HelperPC2 (14);
+		recurseCollection2.setStringField ("recurseCollection2");
+		pc.getRecurseCollection ().add (recurseCollection1);
+		pc.getRecurseCollection ().add (recurseCollection2);
+		recurseCollection1.getHelperCollection ().add (helper1);
+		HelperPC helper2 = new HelperPC (15);
+		helper2.setStringField ("helper2");
+		recurseCollection1.getHelperCollection ().add (helper2);
+
+		EntityManager pm = currentEntityManager();
+		startTx(pm);
+		pm.persist(pc);
+		pm.persist(pc2);
+		endTx(pm);
+		_oid = pc.getId();
+		endEm(pm);
+	}
+
+	public void testOuterJoin ()
+	{
+		EntityManager pm = currentEntityManager();
+		startTx(pm);
+		EagerPCSub pc = pm.find(EagerPCSub.class, _oid);
+		pc.setEager (null);
+		endTx(pm);
+		endEm(pm);
+
+		pm = currentEntityManager();
+		pc = pm.find(EagerPCSub.class, _oid);
+		assertNull (pc.getEager());
+		assertNotNull (pc.getRecurse ());
+		assertEquals ("helper3", pc.getRecurse ().getHelper ().
+			getStringField ());
+		endEm(pm);
+	}
+
+	public void testOuterJoinToSubclass ()
+	{
+		EntityManager pm = currentEntityManager();
+		startTx(pm);
+		EagerPCSub pc = pm.find(EagerPCSub.class, _oid);
+		pc.setEagerSub (null);
+		endTx(pm);
+		endEm(pm);
+
+		pm = currentEntityManager();
+		startTx(pm);
+		pc = pm.find(EagerPCSub.class, _oid);
+		assertNull (pc.getEagerSub ());
+		assertNotNull (pc.getRecurse ());
+		assertEquals ("helper3", pc.getRecurse ().getHelper ().getStringField ());
+		endTx(pm);
+		endEm(pm);
+	}
+
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBInverseOneToOne.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBInverseOneToOne.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBInverseOneToOne.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBInverseOneToOne.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,83 @@
+/*
+ * 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.jdbc.meta;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityTransaction;
+
+import org.apache.openjpa.persistence.common.utils.*;
+
+import org.apache.openjpa.persistence.jdbc.common.apps.InvertA;
+import org.apache.openjpa.persistence.jdbc.common.apps.InvertB;
+import junit.framework.*;
+
+public class TestEJBInverseOneToOne extends org.apache.openjpa.persistence.jdbc.kernel.BaseJDBCTest
+{
+	public TestEJBInverseOneToOne(String name)
+	{
+		super(name);
+	}
+
+	public void setUp ()
+	{
+		deleteAll(InvertA.class);
+		deleteAll(InvertB.class);
+	}
+
+
+	private static Object insertData (EntityManager pm)
+	{
+		InvertA a;
+		InvertB b;
+		a = new InvertA (1);
+		b = new InvertB (2);
+		a.setTest ("testA");
+		b.setTest ("testB");
+		b.setInvertA (a);
+
+		EntityTransaction t = pm.getTransaction ();
+		t.begin ();
+		pm.persist(b);
+		//pm.makeTransactional (b);
+
+		return (pm.find(InvertB.class, 2));
+	}
+
+
+	public void testLoad ()
+	{
+		InvertA a;
+		InvertB b;
+		Object aId;
+		Object bId;
+
+		EntityManager pm = currentEntityManager();
+		aId = insertData (pm);
+		endTx(pm);
+		endEm(pm);
+
+		pm = currentEntityManager();
+		startTx(pm);
+		b = (InvertB) aId;
+
+		assertNotNull(b.getInvertA().getTest());
+		assertEquals (b.getInvertA().getTest (), "testA");
+	}
+
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBOuterJoinValues.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBOuterJoinValues.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBOuterJoinValues.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEJBOuterJoinValues.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,101 @@
+/*
+ * 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.jdbc.meta;
+
+import javax.persistence.EntityManager;
+
+import org.apache.openjpa.persistence.common.utils.*;
+
+import org.apache.openjpa.persistence.kernel.common.apps.OuterJoinValuePC;
+import junit.framework.*;
+
+public class TestEJBOuterJoinValues extends org.apache.openjpa.persistence.jdbc.kernel.BaseJDBCTest
+{
+	public int oid = 0;
+
+	public TestEJBOuterJoinValues(String name)
+	{
+		super(name);
+	}
+
+	public void setUp()
+	{
+		deleteAll(OuterJoinValuePC.class);
+
+		OuterJoinValuePC pc = new OuterJoinValuePC (10);
+		pc.setStringField ("pc");
+		pc.setValue1 (1);
+		pc.setValue2 (2);
+
+		EntityManager pm = currentEntityManager();
+		startTx(pm);
+		pm.persist(pc);
+		endTx(pm);
+
+		oid = pc.getId();
+		endEm(pm);
+	}
+
+	public void testNull ()
+	{
+		EntityManager pm = currentEntityManager();
+		startTx(pm);
+		OuterJoinValuePC pc = pm.find(OuterJoinValuePC.class, oid);
+
+		pc.setValue1 (0);
+		pc.setValue2 (0);
+		endTx(pm);
+		endEm(pm);
+
+		pm = currentEntityManager();
+		pc = pm.find(OuterJoinValuePC.class, oid);
+		assertEquals (0, pc.getValue1 ());
+		assertEquals (0, pc.getValue2 ());
+		endEm(pm);
+	}
+
+	public void testUpdate ()
+	{
+		EntityManager pm = currentEntityManager();
+		startTx(pm);
+		OuterJoinValuePC pc = pm.find(OuterJoinValuePC.class, oid);
+		pc.setValue1 (3);
+		pc.setValue2 (0);
+		endTx(pm);
+		endEm(pm);
+
+		pm = currentEntityManager();
+		pc = pm.find(OuterJoinValuePC.class, oid);
+		assertEquals (3, pc.getValue1 ());
+		assertEquals (0, pc.getValue2 ());
+		endEm(pm);
+	}
+
+	public void testInsert ()
+	{
+		// just tests the values inserted in the setup method
+		EntityManager pm = currentEntityManager();
+		OuterJoinValuePC pc = pm.find(OuterJoinValuePC.class, oid);
+		assertEquals ("pc", pc.getStringField ());
+		assertEquals (1, pc.getValue1 ());
+		assertEquals (2, pc.getValue2 ());
+		endEm(pm);
+	}
+
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEagerDistinct.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEagerDistinct.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEagerDistinct.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/meta/TestEagerDistinct.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,242 @@
+/*
+ * TestEagerDistinct.java
+ *
+ * Created on October 4, 2006, 4:27 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+/*
+ * 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.jdbc.meta;
+
+import java.util.*;
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
+import org.apache.openjpa.jdbc.sql.Join;
+import org.apache.openjpa.persistence.OpenJPAQuery;
+
+import org.apache.openjpa.persistence.jdbc.common.apps.*;
+
+
+import java.lang.annotation.Annotation;
+import junit.framework.*;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+
+
+public class TestEagerDistinct extends org.apache.openjpa.persistence.jdbc.kernel.TestSQLListenerTestCase 
+{
+        
+    /** Creates a new instance of TestEagerDistinct */
+    public TestEagerDistinct(String name) 
+    {
+    	super(name);
+    }
+    
+    public boolean skipTest() {
+        return ((JDBCConfiguration) getConfiguration()).
+                getDBDictionaryInstance().joinSyntax == Join.SYNTAX_TRADITIONAL;
+    }
+    
+    public void setUpTestCase() {
+       deleteAll(EagerPC.class);
+       deleteAll(HelperPC.class);
+       deleteAll(HelperPC2.class);
+        
+        HelperPC shared = new HelperPC();
+        shared.setStringField("shared");
+        
+        HelperPC2 pc1 = new HelperPC2();
+        pc1.setStringField("pc1");
+        pc1.getHelperCollection().add(shared);
+        pc1.getHelperCollection().add(new HelperPC());
+        
+        HelperPC2 pc2 = new HelperPC2();
+        pc2.setStringField("pc2");
+        pc2.getHelperCollection().add(shared);
+        pc2.getHelperCollection().add(new HelperPC());
+        
+        OpenJPAEntityManager pm =(OpenJPAEntityManager)currentEntityManager();
+        startTx(pm);;
+        pm.persist(pc1);
+        pm.persist(pc2);
+        endTx(pm);;
+        
+        // to make sure subclasses are selected, etc
+        //FIXME jthomas
+        //pm.createNativeQuery("",HelperPC.class).execute();
+        //pm.newQuery(HelperPC2.class).execute();
+        pm.close();
+    }
+    
+    public OpenJPAEntityManager getPM() {
+        OpenJPAEntityManager pm = (OpenJPAEntityManager)currentEntityManager();
+        pm.getFetchPlan().setMaxFetchDepth(-1);
+        return pm;
+    }
+    
+    public void testEagerParallelWithNonDistinctQuery()
+    throws Exception {
+        eagerParallelWithNonDistinctQuery(-1);
+    }
+    
+    public void testPagingEagerParallelWithNonDistinctQuery()
+    throws Exception {
+        eagerParallelWithNonDistinctQuery(0);
+    }
+    
+    private void eagerParallelWithNonDistinctQuery(int fetchSize)
+    throws Exception {
+        OpenJPAEntityManager pm = getPM();
+        OpenJPAQuery q = pm.createNativeQuery("stringField.startsWith ('pc')",HelperPC2.class);
+        //FIXME jthomas
+        //q.setOrdering("stringField ascending");
+        q.getFetchPlan().setFetchBatchSize(fetchSize);
+        List res = (List) q.getResultList();
+        
+        if (fetchSize == -1)
+            assertEquals(2, sql.size());
+        
+        assertEquals(2, res.size());
+        assertHelperPC2("pc1", (HelperPC2) res.get(0));
+        assertHelperPC2("pc2", (HelperPC2) res.get(1));
+        
+        assertNotSQL("DISTINCT");
+        pm.close();
+    }
+    
+    private void assertHelperPC2(String stringField, HelperPC2 pc) {
+        assertEquals(stringField, pc.getStringField());
+        assertEquals(2, pc.getHelperCollection().size());
+        assertEquals("shared", ((HelperPC) pc.getHelperCollection().get(0)).
+                getStringField());
+        assertNull(((HelperPC) pc.getHelperCollection().get(1)).
+                getStringField());
+    }
+    
+    public void testEagerParallelWithDistinctQuery()
+    throws Exception {
+        eagerParallelWithDistinctQuery(-1);
+    }
+    
+    public void testPagingEagerParallelWithDistinctQuery()
+    throws Exception {
+        eagerParallelWithDistinctQuery(0);
+    }
+    
+    private void eagerParallelWithDistinctQuery(int fetchSize)
+    throws Exception {
+        OpenJPAEntityManager pm = getPM();
+        OpenJPAQuery q =  pm.createNativeQuery("helperCollection.contains (h) && h.stringField == 'shared'",HelperPC2.class);
+        //FIXME  jthomas
+        //q.setOrdering("stringField ascending");
+        q.getFetchPlan().setFetchBatchSize(fetchSize);
+        List res = (List) q.getResultList();
+        
+        if (fetchSize == -1) {
+            sql.remove(0);    // orig sel
+            assertSQL("DISTINCT");
+        }
+        
+        assertEquals(2, res.size());
+        assertHelperPC2("pc1", (HelperPC2) res.get(0));
+        assertHelperPC2("pc2", (HelperPC2) res.get(1));
+        pm.close();
+    }
+    
+    public void testNestedEagerParallel()
+    throws Exception {
+        nestedEagerParallel(-1);
+    }
+    
+    public void testPagingNestedEagerParallel()
+    throws Exception {
+        nestedEagerParallel(0);
+    }
+    
+    private void nestedEagerParallel(int fetchSize)
+    throws Exception {
+        OpenJPAEntityManager pm = getPM();
+        OpenJPAQuery q = pm.createNativeQuery("",HelperPC2.class);
+        //FIXME jthomas
+        //q.setOrdering("stringField ascending");
+        List helpers = (List) q.getResultList();
+        
+        EagerPC eager1 = new EagerPC();
+        eager1.setStringField("eager1");
+        eager1.getRecurseCollection().addAll(helpers);
+        
+        EagerPC eager2 = new EagerPC();
+        eager2.setStringField("eager2");
+        eager2.getRecurseCollection().addAll(helpers);
+        HelperPC2 pc3 = new HelperPC2();
+        pc3.setStringField("pc3");
+        pc3.getHelperCollection().add(new HelperPC());
+        pc3.getHelperCollection().add(new HelperPC());
+        pc3.getHelperCollection().add(new HelperPC());
+        eager2.getRecurseCollection().add(pc3);
+        
+        startTx(pm);;
+        pm.persist(eager1);
+        pm.persist(eager2);
+        endTx(pm);;
+        // make sure subclasses selected, etc
+        //FIXME jthomas
+        pm.createNativeQuery("",EagerPC.class).getResultList();
+        pm.close();
+        sql.clear();
+        
+        pm = getPM();
+        q = pm.createNativeQuery("stringField.startsWith ('eager')",EagerPC.class);
+        //FIXME jthomas
+        //q.setOrdering("stringField ascending");
+        q.getFetchPlan().setFetchBatchSize(fetchSize);
+        List res = (List) q.getResultList();
+        
+        if (fetchSize == -1) {
+            sql.remove(0); // orig sel
+            assertSQL("DISTINCT");
+        }
+        
+        assertEquals(2, res.size());
+        eager1 = (EagerPC) res.get(0);
+        assertEquals("eager1", eager1.getStringField());
+        assertEquals(2, eager1.getRecurseCollection().size());
+        assertHelperPC2("pc1", (HelperPC2) eager1.getRecurseCollection().
+                get(0));
+        assertHelperPC2("pc2", (HelperPC2) eager1.getRecurseCollection().
+                get(1));
+        
+        eager2 = (EagerPC) res.get(1);
+        assertEquals("eager2", eager2.getStringField());
+        assertEquals(3, eager2.getRecurseCollection().size());
+        assertHelperPC2("pc1", (HelperPC2) eager2.getRecurseCollection().
+                get(0));
+        assertHelperPC2("pc2", (HelperPC2) eager2.getRecurseCollection().
+                get(1));
+        pc3 = (HelperPC2) eager2.getRecurseCollection().get(2);
+        assertEquals("pc3", pc3.getStringField());
+        assertEquals(3, pc3.getHelperCollection().size());
+        pm.close();
+    }
+    
+}



Mime
View raw message