cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: Unique persistent object and caching issue
Date Tue, 15 Jul 2008 12:31:01 GMT
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