You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Marcin Skladaniec <ma...@jcu.edu.au> on 2009/05/11 03:23:22 UTC

problems in setting reverse relationship

Hello

I have noticed a problem in ROP cayenne. It seems like the reverse  
relationship is not set until the actual relation is faulted.
Simple example:

this works correctly:
logger.warn(artist.getPaintings().size()); -> prints 0
painting.setArtist(artist);
logger.warn(artist.getPaintings().size()); -> prints 1

this does not work correctly:
//logger.warn(artist.getPaintings().size()); -> commented out, no output
painting.setArtist(artist);
logger.warn(artist.getPaintings().size()); -> prints 0

Regardless of which of the examples are the objects are committed to  
db in both cases, and all seems well after a new select query.


additionally for this setup I found another issue which might be  
related. when calling artist.addToPaintings(painting) on client I get  
following exception on server:

[java] Caused by: java.lang.Exception: [v.3.0-SNAPSHOT $ 
{project.build.date} ${project.build.time}] Can't build a query for  
relationship 'artist' for temporary id: <ObjectId:Painting, TEMP: 
0000023B1C5C0005>
is that related?

does anyone have any clues on what might be wrong?
I'm baffled with this one...

Best regards
Marcin



Re: problems in setting reverse relationship

Posted by Marcin Skladaniec <ma...@ish.com.au>.
I'm using quite recent build, svn 762177
Marcin

On 11/05/2009, at 4:41 PM, Andrey Razumovsky wrote:

> I think I've seen something similiar. Is this the latest Cayenne  
> build?
> Could you open a JIRA bug (and possibly provide a JUnit test)?
>
> 2009/5/11 Marcin Skladaniec <ma...@jcu.edu.au>
>
>> Hello
>>
>> I have noticed a problem in ROP cayenne. It seems like the reverse
>> relationship is not set until the actual relation is faulted.
>> Simple example:
>>
>> this works correctly:
>> logger.warn(artist.getPaintings().size()); -> prints 0
>> painting.setArtist(artist);
>> logger.warn(artist.getPaintings().size()); -> prints 1
>>
>> this does not work correctly:
>> //logger.warn(artist.getPaintings().size()); -> commented out, no  
>> output
>> painting.setArtist(artist);
>> logger.warn(artist.getPaintings().size()); -> prints 0
>>
>> Regardless of which of the examples are the objects are committed  
>> to db in
>> both cases, and all seems well after a new select query.
>>
>>
>> additionally for this setup I found another issue which might be  
>> related.
>> when calling artist.addToPaintings(painting) on client I get  
>> following
>> exception on server:
>>
>> [java] Caused by: java.lang.Exception: [v.3.0-SNAPSHOT
>> ${project.build.date} ${project.build.time}] Can't build a query for
>> relationship 'artist' for temporary id: <ObjectId:Painting,
>> TEMP:0000023B1C5C0005>
>> is that related?
>>
>> does anyone have any clues on what might be wrong?
>> I'm baffled with this one...
>>
>> Best regards
>> Marcin
>>
>>
>>


Re: problems in setting reverse relationship

Posted by Andrey Razumovsky <ra...@gmail.com>.
I think I've seen something similiar. Is this the latest Cayenne build?
Could you open a JIRA bug (and possibly provide a JUnit test)?

2009/5/11 Marcin Skladaniec <ma...@jcu.edu.au>

> Hello
>
> I have noticed a problem in ROP cayenne. It seems like the reverse
> relationship is not set until the actual relation is faulted.
> Simple example:
>
> this works correctly:
> logger.warn(artist.getPaintings().size()); -> prints 0
> painting.setArtist(artist);
> logger.warn(artist.getPaintings().size()); -> prints 1
>
> this does not work correctly:
> //logger.warn(artist.getPaintings().size()); -> commented out, no output
> painting.setArtist(artist);
> logger.warn(artist.getPaintings().size()); -> prints 0
>
> Regardless of which of the examples are the objects are committed to db in
> both cases, and all seems well after a new select query.
>
>
> additionally for this setup I found another issue which might be related.
> when calling artist.addToPaintings(painting) on client I get following
> exception on server:
>
> [java] Caused by: java.lang.Exception: [v.3.0-SNAPSHOT
> ${project.build.date} ${project.build.time}] Can't build a query for
> relationship 'artist' for temporary id: <ObjectId:Painting,
> TEMP:0000023B1C5C0005>
> is that related?
>
> does anyone have any clues on what might be wrong?
> I'm baffled with this one...
>
> Best regards
> Marcin
>
>
>