Search in sources :

Example 46 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 47 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 48 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 49 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 50 with EntityResolver

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

the class ObjectDiff method getClassDescriptor.

ClassDescriptor getClassDescriptor() {
    // serialization
    if (classDescriptor == null) {
        EntityResolver entityResolver = object.getObjectContext().getEntityResolver();
        this.classDescriptor = entityResolver.getClassDescriptor(entityName);
    }
    return classDescriptor;
}
Also used : EntityResolver(org.apache.cayenne.map.EntityResolver)

Aggregations

EntityResolver (org.apache.cayenne.map.EntityResolver)87 Test (org.junit.Test)57 ObjEntity (org.apache.cayenne.map.ObjEntity)17 ObjectId (org.apache.cayenne.ObjectId)14 DataMap (org.apache.cayenne.map.DataMap)14 DbEntity (org.apache.cayenne.map.DbEntity)10 ArrayList (java.util.ArrayList)7 ClientMtTable1 (org.apache.cayenne.testdo.mt.ClientMtTable1)7 HashMap (java.util.HashMap)6 QueryResponse (org.apache.cayenne.QueryResponse)6 DataNode (org.apache.cayenne.access.DataNode)6 RowReaderFactory (org.apache.cayenne.access.jdbc.reader.RowReaderFactory)6 JdbcAdapter (org.apache.cayenne.dba.JdbcAdapter)6 MockEventManager (org.apache.cayenne.event.MockEventManager)5 ClassDescriptor (org.apache.cayenne.reflect.ClassDescriptor)5 GenericResponse (org.apache.cayenne.util.GenericResponse)5 List (java.util.List)4 MappingNamespace (org.apache.cayenne.map.MappingNamespace)4 Artist (org.apache.cayenne.testdo.testmap.Artist)4 Map (java.util.Map)3