cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: Different DataContext Exception
Date Mon, 10 Jul 2006 15:02:17 GMT
Well, the error still happens because the DataContexts are different  
at the time when you set the relationship. The question is why.

> I think when this query runs secondly after the first run, first  
> query result refrences corrupted by second query results.

I don't preclude a possibility of a bug in the caching mechanism, but  
it seems very unlikely that the objects from another context will  
leak in a given context's cache.

I guess all I can recommend is upgrading to RC2 and debugging it  
further on your end to get to the cause.

Andrus


On Jul 10, 2006, at 2:39 AM, Emre Yılmaz wrote:
> 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;
>   }
>     }


Mime
View raw message