cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurent Marchal <lmarc...@smaeur.com>
Subject Re: Unique persistent object and caching issue
Date Tue, 15 Jul 2008 13:49:39 GMT
Thanks Andrus, i have tried and Cayenne alone works well : I don't see 
one request per access.

I have one-to-many relationship between Artist and Artist_AUX called 
"getRelatedArtistAux()" but the problem is as soon i delete one of this 
Artist_AUX row, the Artist relationships are not refreshed. I had this 
problem before and i remember i had to do a RefreshQuery to invalidate 
the relationships.

But the thing I don't understand is why when i refetch the Artist object 
the relationships are not invalidated.

Is Cayenne considering that the relationships of Artist are still good 
even if the Artist snapshot version changed ?
Must i do a RefreshQuery for each of my SelectQueries to be sure the 
data in cayenne correspond to the database ?

Thanks.

Laurent.

Andrus Adamchik wrote:
> Hi,
>
> If I understand correctly your setup, you can map a one-to-many 
> relationship between Artist and Artist_AUX and let Cayenne handle 
> faulting automatically behind the scenes.
>
> Andrus
>
> On Jul 15, 2008, at 3:25 PM, Laurent Marchal wrote:
>
>> Hi all,
>>
>>
>>   I have a problem that i cannot solve. My customer has a strange
>> database schema : each table has a related "AUX" table where extended
>> properties are stored in rows. For example
>>
>> .----------------------.
>> |         Artist       |
>> +----+-----------------+
>> | Id | Name            |
>> +----+-----------------+
>> |  1 | John Smith      |
>> '----+-----------------'
>>
>> .----------------------------------.
>> |          Artist_AUX              |
>> +----+-----------------+-----------+
>> | Id | Name            |   Value   |
>> +----+-----------------+-----------+
>> |  1 | DateOfBirth     |  18/02/70 |
>> |  1 | Gender          |  Male     |
>> |  1 | NickName        |  JSmith   |
>> '----+-----------------+-----------'
>>
>>
>> It was a solution for my customer to store a lot of extended properties
>> for Artist without adding/removing columns in the Artist table...
>>
>> To deal with this, i do not want to make a SQL request each time the
>> user want to set/get an AUX property.
>> So i created an AuxManager which basically fetch all aux rows in the AUX
>> table the first time the user want to get/set a value in the AUX.
>> This way only one request is made to fetch all extended properties.
>>
>> A simplified Artist class looks like :
>>
>>   class Artist {
>>      //extended properties list
>>      private list<Artist_AUX> _auxList;
>>
>>      public getDateOfBirth() {
>>           if (_auxList == null) {
>>                  _auxList = Artist.fetchAllArtistAux();
>>            }
>>            return _auxList.get("DateOfBirth");
>>       }
>>   }
>>
>>   The getDateOfBirth() is an extended property, so if the aux row list
>> is null, I fetch all the Artist_AUX rows in one time and then do the 
>> stuff.
>>
>>   My problem is : since cayenne has only 1 instance of each unique
>> persistent object, the persistent Artist object is not re-created for
>> each query, so the internal "list<Artist_AUX> _auxList" is not reseted
>> to null, and the extended properties are not refreshed.
>>
>> How can i force this list to be refreshed when a fresh Artist object is
>> fetched ? Or is there another way to do that ?
>>
>> Thanks.
>> Laurent Marchal.
>>
>>
>>
>>
>
>
>
>

Mime
View raw message