Hi,
I get the below exception rarely;
[v.1.2-dev-2006-4-12 April 12 2006] Cannot set object as destination of
relationship personelRel because it is in a different DataContext.
But I use a single context so it is not a different context with the other
database objects. I think the reason of this exception is that I use the Object
Select Query(named "PersonelCard") on cayenne modeller. I think when this query
runs secondly after the first run, first query result refrences corrupted by
second query results.Query make resusult caching: DataContext cache, refresh
result and fetch limit,rows:1. Also I get this exception not the all of the run
Query, this occurs rarely.
What can I do prevent this exception?
Query code:
public static DbObject get(String trNo,Integer cardNo) {
try{
Map<String,Object> parameters = new HashMap<String,Object>();
parameters.put(TRANSPONDER_NO_PROPERTY, trNo);
parameters.put(BADGE_NO_PROPERTY, cardNo);
List cards = localContext.performQuery("PersonelCard", parameters, true);
return (cards.size() > 0) ? (DbObject) cards.get(0) : null;
}catch(Exception e){
logObj.error(e.getMessage(),e);
return null;
}
}