Search in sources :

Example 41 with EntityResolver

use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.

the class ProcedureQueryCacheKeyIT method testCacheFetchOffsetAndLimit.

@Test
public void testCacheFetchOffsetAndLimit() {
    EntityResolver resolver = runtime.getDataDomain().getEntityResolver();
    ProcedureQuery q1 = new ProcedureQuery("ABC", Artist.class);
    q1.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
    q1.setFetchOffset(5);
    q1.setFetchLimit(3);
    ProcedureQuery q2 = new ProcedureQuery("ABC", Artist.class);
    q2.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
    q2.setFetchOffset(5);
    q2.setFetchLimit(3);
    assertEquals(q1.getMetaData(resolver).getCacheKey(), q2.getMetaData(resolver).getCacheKey());
}
Also used : EntityResolver(org.apache.cayenne.map.EntityResolver) Test(org.junit.Test)

Example 42 with EntityResolver

use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.

the class ProcedureQueryCacheKeyIT method testNamedQuery.

@Test
public void testNamedQuery() {
    EntityResolver resolver = runtime.getDataDomain().getEntityResolver();
    ProcedureQuery query = new ProcedureQuery("ABC", Artist.class);
    query.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
    QueryMetadata md1 = query.getMetaData(resolver);
    assertEquals(QueryCacheStrategy.SHARED_CACHE, md1.getCacheStrategy());
    assertEquals("proc:", md1.getCacheKey());
}
Also used : EntityResolver(org.apache.cayenne.map.EntityResolver) Test(org.junit.Test)

Example 43 with EntityResolver

use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.

the class ProcedureQueryCacheKeyIT method testNoCache.

@Test
public void testNoCache() {
    EntityResolver resolver = runtime.getDataDomain().getEntityResolver();
    ProcedureQuery query = new ProcedureQuery("ABC", Artist.class);
    QueryMetadata md1 = query.getMetaData(resolver);
    assertEquals(QueryCacheStrategy.NO_CACHE, md1.getCacheStrategy());
    assertNull(md1.getCacheKey());
    QueryMetadata md2 = query.getMetaData(resolver);
    assertEquals(QueryCacheStrategy.NO_CACHE, md2.getCacheStrategy());
    assertNull(md2.getCacheKey());
}
Also used : EntityResolver(org.apache.cayenne.map.EntityResolver) Test(org.junit.Test)

Example 44 with EntityResolver

use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.

the class ProcedureQueryCacheKeyIT method testLocalCache.

@Test
public void testLocalCache() {
    EntityResolver resolver = runtime.getDataDomain().getEntityResolver();
    ProcedureQuery query = new ProcedureQuery("ABC", Artist.class);
    query.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
    QueryMetadata md1 = query.getMetaData(resolver);
    assertEquals(QueryCacheStrategy.LOCAL_CACHE, md1.getCacheStrategy());
    assertNotNull(md1.getCacheKey());
}
Also used : EntityResolver(org.apache.cayenne.map.EntityResolver) Test(org.junit.Test)

Example 45 with EntityResolver

use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.

the class SQLSelectTest method testGetMetadata_ParamsArray_Multiple_Cache.

@Test
public void testGetMetadata_ParamsArray_Multiple_Cache() {
    EntityResolver resolver = mock(EntityResolver.class);
    QueryMetadata md0 = SQLSelect.dataRowQuery("bla").localCache().getMetaData(resolver);
    QueryMetadata md1 = SQLSelect.dataRowQuery("bla").localCache().paramsArray("a").getMetaData(resolver);
    QueryMetadata md2 = SQLSelect.dataRowQuery("bla").localCache().paramsArray("a", "b").getMetaData(resolver);
    QueryMetadata md3 = SQLSelect.dataRowQuery("bla").localCache().paramsArray(null, "b").getMetaData(resolver);
    assertNotNull(md0.getCacheKey());
    assertNotNull(md1.getCacheKey());
    assertNotNull(md2.getCacheKey());
    assertNotNull(md3.getCacheKey());
    assertNotEquals(md0.getCacheKey(), md1.getCacheKey());
    assertNotEquals(md0.getCacheKey(), md2.getCacheKey());
    assertNotEquals(md1.getCacheKey(), md2.getCacheKey());
    assertNotEquals(md3.getCacheKey(), md2.getCacheKey());
}
Also used : EntityResolver(org.apache.cayenne.map.EntityResolver) Test(org.junit.Test)

Aggregations

EntityResolver (org.apache.cayenne.map.EntityResolver)78 Test (org.junit.Test)53 ObjectId (org.apache.cayenne.ObjectId)13 ObjEntity (org.apache.cayenne.map.ObjEntity)13 DataMap (org.apache.cayenne.map.DataMap)11 ClientMtTable1 (org.apache.cayenne.testdo.mt.ClientMtTable1)7 DataNode (org.apache.cayenne.access.DataNode)6 RowReaderFactory (org.apache.cayenne.access.jdbc.reader.RowReaderFactory)6 JdbcAdapter (org.apache.cayenne.dba.JdbcAdapter)6 DbEntity (org.apache.cayenne.map.DbEntity)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 QueryResponse (org.apache.cayenne.QueryResponse)5 MockEventManager (org.apache.cayenne.event.MockEventManager)5 SelectQuery (org.apache.cayenne.query.SelectQuery)5 ClassDescriptor (org.apache.cayenne.reflect.ClassDescriptor)5 GenericResponse (org.apache.cayenne.util.GenericResponse)5 MappingNamespace (org.apache.cayenne.map.MappingNamespace)4 ObjRelationship (org.apache.cayenne.map.ObjRelationship)4 List (java.util.List)3