openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r701407 - in /openjpa/branches/1.2.x: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/kernel/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/relations/
Date Fri, 03 Oct 2008 15:16:42 GMT
Author: mikedd
Date: Fri Oct  3 08:16:41 2008
New Revision: 701407

URL: http://svn.apache.org/viewvc?rev=701407&view=rev
Log:
OPENJPA-731 merging revision 699156 to 1.2.x branch. 

Added:
    openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/relations/TblChild.java
      - copied unchanged from r699156, openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/relations/TblChild.java
    openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/relations/TblGrandChild.java
      - copied unchanged from r699156, openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/relations/TblGrandChild.java
    openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/relations/TblParent.java
      - copied unchanged from r699156, openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/relations/TblParent.java
Modified:
    openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java
    openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/kernel/TestQuerySQLCache.java

Modified: openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java?rev=701407&r1=701406&r2=701407&view=diff
==============================================================================
--- openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java
(original)
+++ openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java
Fri Oct  3 08:16:41 2008
@@ -391,7 +391,7 @@
         }
 
         return getEagerResult(conn, stmnt, rs, store, fetch, forUpdate, 
-            _sql.getSQL());
+            _sql.getSQL(), params);
     }
     
     private boolean isForUpdate(JDBCStore store, int lockLevel) {
@@ -409,7 +409,7 @@
      * to the given result.
      */
     private static void addEagerResults(SelectResult res, SelectImpl sel,
-        JDBCStore store, JDBCFetchConfiguration fetch)
+        JDBCStore store, JDBCFetchConfiguration fetch, List params)
         throws SQLException {
         if (sel._eager == null)
             return;
@@ -428,7 +428,7 @@
                 eres = res;
             else
                 eres = ((SelectExecutor) entry.getValue()).execute(store,
-                    fetch);
+                    fetch, params);
 
             eager = res.getEagerMap(false);
             if (eager == null) {
@@ -511,14 +511,15 @@
      */
     protected Result getEagerResult(Connection conn, 
         PreparedStatement stmnt, ResultSet rs, JDBCStore store, 
-        JDBCFetchConfiguration fetch, boolean forUpdate, String sqlStr) 
+        JDBCFetchConfiguration fetch, boolean forUpdate, String sqlStr,
+        List params) 
         throws SQLException {
         SelectResult res = new SelectResult(conn, stmnt, rs, _dict);
         res.setSelect(this);
         res.setStore(store);
         res.setLocking(forUpdate);
         try {
-            addEagerResults(res, this, store, fetch);
+            addEagerResults(res, this, store, fetch, params);
         } catch (SQLException se) {
             res.close();
             throw se;

Modified: openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/kernel/TestQuerySQLCache.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/kernel/TestQuerySQLCache.java?rev=701407&r1=701406&r2=701407&view=diff
==============================================================================
--- openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/kernel/TestQuerySQLCache.java
(original)
+++ openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/kernel/TestQuerySQLCache.java
Fri Oct  3 08:16:41 2008
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.kernel;
 
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -34,6 +35,9 @@
 import org.apache.openjpa.persistence.EntityManagerImpl;
 import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
 import org.apache.openjpa.persistence.OpenJPAPersistence;
+import org.apache.openjpa.persistence.relations.TblChild;
+import org.apache.openjpa.persistence.relations.TblGrandChild;
+import org.apache.openjpa.persistence.relations.TblParent;
 import org.apache.openjpa.persistence.simple.Person;
 
 /*
@@ -271,6 +275,72 @@
         runMultiEMCaching(props);
     }
 
+    /*
+     * Verify QuerySQLCacheValue setting "true" uses the expected cache
+     * implementation and is caching.
+     */
+    public void testEagerFetch() {
+        Map props = new HashMap(System.getProperties());
+        props.put("openjpa.MetaDataFactory", "jpa(Types="
+            + TblChild.class.getName() + ";"
+            + TblGrandChild.class.getName() + ";"
+            + TblParent.class.getName() + ")");
+        props.put("openjpa.jdbc.QuerySQLCache", "true");
+        OpenJPAEntityManagerFactorySPI emf = (OpenJPAEntityManagerFactorySPI)
+            OpenJPAPersistence.cast(
+                Persistence.createEntityManagerFactory("test", props));
+        
+        EntityManagerImpl em = (EntityManagerImpl)emf.createEntityManager();
+        
+        em.getTransaction().begin();
+        for (int i = 0; i < 2; i++) {
+        	TblParent p = new TblParent();
+        	p.setParentId(i);
+    		TblChild c = new TblChild();
+    		c.setChildId(i);
+            c.setTblParent(p);
+            p.addTblChild(c);
+     		em.persist(p);
+    		em.persist(c);
+
+    		TblGrandChild gc = new TblGrandChild();
+    		gc.setGrandChildId(i);
+    		gc.setTblChild(c);
+    		c.addTblGrandChild(gc);
+    		
+    		em.persist(p);
+    		em.persist(c);
+    		em.persist(gc);
+        }
+        em.flush();
+        em.getTransaction().commit();
+        em.clear();
+        
+        for (int i = 0; i < 2; i++) {
+        	TblParent p = em.find(TblParent.class, i);
+        	int pid = p.getParentId();
+        	assertEquals(pid, i);
+        	Collection<TblChild> children = p.getTblChildren();
+        	boolean hasChild = false;
+        	for (TblChild c : children) {
+        		hasChild = true;
+        		Collection<TblGrandChild> gchildren = c.getTblGrandChildren();
+        		int cid = c.getChildId();
+        		assertEquals(cid, i);
+	        	boolean hasGrandChild = false;
+        		for (TblGrandChild gc : gchildren) {
+        			hasGrandChild = true;
+        			int gcId = gc.getGrandChildId();
+        			assertEquals(gcId, i);
+        		}
+        		assertTrue(hasGrandChild);
+        	}
+        	assertTrue(hasChild);
+        }
+        em.close();
+        emf.close();
+    }
+
     private void runMultiEMCaching(Map props) {
 
         EntityManagerFactory emfac = 



Mime
View raw message