openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fayw...@apache.org
Subject svn commit: r835054 - in /openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/ openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persis...
Date Wed, 11 Nov 2009 20:40:18 GMT
Author: faywang
Date: Wed Nov 11 20:40:18 2009
New Revision: 835054

URL: http://svn.apache.org/viewvc?rev=835054&view=rev
Log:
OPENJPA-1380: queryCache is not refreshed for cross-join jpql.

Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/JPQLExpressionBuilder.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestBulkJPQLAndDataCache.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestQueryResultSize.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/datacache/common/apps/META-INF/persistence.xml

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/JPQLExpressionBuilder.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/JPQLExpressionBuilder.java?rev=835054&r1=835053&r2=835054&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/JPQLExpressionBuilder.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/JPQLExpressionBuilder.java
Wed Nov 11 20:40:18 2009
@@ -827,6 +827,8 @@
         // which is the desired candidate
         if (ctx().schemaAlias == null)
             setCandidate(cmd, alias);
+        else  
+            addAccessPath(cmd);
 
         return exp;
     }

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestBulkJPQLAndDataCache.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestBulkJPQLAndDataCache.java?rev=835054&r1=835053&r2=835054&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestBulkJPQLAndDataCache.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestBulkJPQLAndDataCache.java
Wed Nov 11 20:40:18 2009
@@ -35,6 +35,7 @@
     public void setUp() throws Exception {
         setUp("openjpa.DataCache", "true",
             "openjpa.RemoteCommitProvider", "sjvm",
+            CLEAR_TABLES,
             AllFieldTypes.class, CascadeParent.class, CascadeChild.class);
 
         OpenJPAEntityManager em = emf.createEntityManager();

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestQueryResultSize.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestQueryResultSize.java?rev=835054&r1=835053&r2=835054&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestQueryResultSize.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestQueryResultSize.java
Wed Nov 11 20:40:18 2009
@@ -19,20 +19,17 @@
 package org.apache.openjpa.persistence.datacache;
 
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import javax.persistence.EntityManagerFactory;
-import org.apache.openjpa.datacache.*;
-import javax.persistence.*;
-import org.apache.openjpa.persistence.*;
-
 
-import org.apache.openjpa.persistence.datacache.common.apps.CacheObjectE;
-import org.apache.openjpa.persistence.common.utils.AbstractTestCase;
+import javax.persistence.EntityManagerFactory;
 
+import org.apache.openjpa.datacache.ConcurrentQueryCache;
 import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.OpenJPAPersistence;
 import org.apache.openjpa.persistence.OpenJPAQuery;
+import org.apache.openjpa.persistence.common.utils.AbstractTestCase;
+import org.apache.openjpa.persistence.datacache.common.apps.CacheObjectE;
 
 public class TestQueryResultSize
     extends AbstractTestCase {
@@ -47,6 +44,8 @@
     public void setUp() {
         System.out.println("****Deleted Records "
             + deleteAll(CacheObjectE.class));
+        deleteAll(CascadeParent.class);
+        deleteAll(CascadeChild.class);
         Map propsMap = new HashMap();
         propsMap.put("openjpa.DataCache", "true");
         propsMap.put("openjpa.QueryCache", "true");
@@ -81,4 +80,36 @@
             pm.getEntityManagerFactory()).getQueryResultCache().getDelegate())).
             getCacheMap().size());
     }
+
+    public void testCrossJoinQueryCache() {
+        pm = (OpenJPAEntityManager) _pmf.createEntityManager();
+        // create
+        startTx(pm);
+        CascadeParent p = new CascadeParent();
+        p.setName("p1");
+        CascadeChild c = new CascadeChild();
+        c.setName("p1");
+        p.setChild(c);
+        pm.persist(p);
+        endTx(pm);
+
+        // query
+        String jpql = "select p.name, c.name from CascadeParent p, CascadeChild c where p.name
= c.name "
+                + "and p.name = 'p1'";
+        javax.persistence.Query query = pm.createQuery(jpql);
+        List result1 = query.getResultList();
+        assertEquals(1, result1.size());
+
+        // update
+        startTx(pm);
+        c.setName("c1");
+        endTx(pm);
+
+        // query again
+        List result2 = query.getResultList();
+        assertEquals(0, result2.size());
+        endEm(pm);
+    }
+
+
 }

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/datacache/common/apps/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/datacache/common/apps/META-INF/persistence.xml?rev=835054&r1=835053&r2=835054&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/datacache/common/apps/META-INF/persistence.xml
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/datacache/common/apps/META-INF/persistence.xml
Wed Nov 11 20:40:18 2009
@@ -22,6 +22,8 @@
 	<persistence-unit name="TestConv" transaction-type="RESOURCE_LOCAL">
 		<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
 		
+		<class>org.apache.openjpa.persistence.datacache.CascadeChild</class>
+		<class>org.apache.openjpa.persistence.datacache.CascadeParent</class>
 		<class>org.apache.openjpa.persistence.datacache.common.apps.AppIdCacheObject</class>
 		<class>org.apache.openjpa.persistence.datacache.common.apps.AttachA</class>
 		<class>org.apache.openjpa.persistence.datacache.common.apps.AttachB</class>



Mime
View raw message