OPENJPA-1380: queryCache is not refreshed for cross-join jpql.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@835054 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Fay Wang 2009-11-11 20:40:18 +00:00
parent ab18db113b
commit 983b34b68e
4 changed files with 44 additions and 8 deletions

View File

@ -827,6 +827,8 @@ public class JPQLExpressionBuilder
// which is the desired candidate
if (ctx().schemaAlias == null)
setCandidate(cmd, alias);
else
addAccessPath(cmd);
return exp;
}

View File

@ -35,6 +35,7 @@ public class TestBulkJPQLAndDataCache
public void setUp() throws Exception {
setUp("openjpa.DataCache", "true",
"openjpa.RemoteCommitProvider", "sjvm",
CLEAR_TABLES,
AllFieldTypes.class, CascadeParent.class, CascadeChild.class);
OpenJPAEntityManager em = emf.createEntityManager();

View File

@ -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 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 class TestQueryResultSize
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 @@ public class TestQueryResultSize
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);
}
}

View File

@ -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>