cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "" <>
Subject Cayenne does not find object in his graph after SelectQuery.
Date Wed, 09 Sep 2009 13:41:57 GMT
Hello everybody,

    I have a strange problem, that is difficult to reproduce so I would 
like to gather information about the cayenne internals.

In my database I have an object JOB that has ID, NAME, PRIORITY as PKs. 
I have a method
getJobByID(ID, NAME) that returns the unique job without specifying the 
PRIORITY PK using a SelectQuery.

The main problem is when I use the 'getJobByID(ID, NAME)' Cayenne do the 
database request, but the job does not seems to be refreshed in the 
cayenne cache (object graph). If I make the request using the ObjectID, 
the job is refreshed. The only differences is that using the ObjectID 
Cayenne specifies the PRIORITY field.

Both requests returns the same job (cause PRIORITY is never used and 
always 0), but cayenne seems to not find it in his object graph.

The question is : is it possible that Cayenne does not find back this 
job in his object graph because I do not specify the PRIORITY PK in my 
request ? or this can be a bug ? This behavior should be strange cause 
cayenne should always update the job in his graph...

I do not use any caching system.

Laurent Marchal.


public static DailyJob getById(ObjectContext context, IDailyJobKey key)  {
        HashMap<String, Object> ExpressionMap = new HashMap<String, 

        ExpressionMap.put(DailyJob.ID_PROPERTY, key.getId());
        ExpressionMap.put(DailyJob.JOB_NAME_PROPERTY, key.getJobName());

        Expression expr = ExpressionFactory.matchAllExp(ExpressionMap, 
        SelectQuery qGetJob = new SelectQuery(DailyJob.class, expr);

        if (job != null && job.size() > 0) {
                return job.get(0);
       return null;

View raw message