cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Artyom Kravchenko (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CAY-2349) Cayenne cache issue: 'SelectQuery' with prefetches loses relationships (null)
Date Wed, 16 Aug 2017 06:53:00 GMT
Artyom Kravchenko created CAY-2349:
--------------------------------------

             Summary: Cayenne cache issue: 'SelectQuery' with prefetches loses relationships
(null)
                 Key: CAY-2349
                 URL: https://issues.apache.org/jira/browse/CAY-2349
             Project: Cayenne
          Issue Type: Bug
          Components: Core Library
    Affects Versions: 4.0.B1
         Environment: JCacheModule, ehcache.
            Reporter: Artyom Kravchenko


I have faced with the problem when SelectQuery returns wrong query result: returned object
 lost some of the  relationships - they are null.

I have used prefetches (to load several number of objects in one go) and shared cache (to
put query result to cache). I have found an use case where it always reproduces, see my test:



{code:java}
class CayenneJCacheTest {

    def cayenneRuntime

    @Test
    void test() {
        
        cayenneRuntime = new ServerRuntime("cayenne-project.xml", new JCacheModule())

        selectFew()
        List<CourseClass> classes =  selectMore()
        assertNotNull(classes[0].course)
        assertNotNull(classes[0].course.fieldConfigurationScheme)

    }


    List<CourseClass> selectFew() {

        (ObjectSelect.query(CourseClass)
                .where(ExpressionFactory.inDbExp(CourseClass.ID_PK_COLUMN, '1001'))
                & CourseClass.COLLEGE.eq(college))
                .prefetch(CourseClass.COURSE.joint())
                .cacheStrategy(QueryCacheStrategy.SHARED_CACHE)
                .cacheGroup(CourseClass.class.simpleName)
                .select(cayenneRuntime.newContext())
    }
    
    List<CourseClass> selectMore() {
        
        (ObjectSelect.query(CourseClass)
                .where(ExpressionFactory.inDbExp(CourseClass.ID_PK_COLUMN, '1001'))
                & CourseClass.COLLEGE.eq(college))
                .prefetch(CourseClass.COURSE.joint())
                .prefetch(CourseClass.COURSE.dot(Course.FIELD_CONFIGURATION_SCHEME).joint())
                .cacheStrategy(QueryCacheStrategy.SHARED_CACHE)
                .cacheGroup(CourseClass.class.simpleName)
                .select(cayenneRuntime.newContext())
    }
    
}
{code}




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message