db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <fisc...@seitenbau.net>
Subject Re: silent db hit for associated objects
Date Fri, 09 Sep 2005 07:59:46 GMT




Hi Thomas,

though I have no experience with the Cache, the code looks good to me.

   Thomas

Thomas Vandahl <thomas.vandahl@tewisoft.de> schrieb am 08.09.2005 16:31:16:

> Thomas Vandahl wrote:
> > Not without bigger changes in the AbstractBaseManager. I will have a
> > look at this. I guess the real fun starts if I want to cache the whole
> > collection of books at once (using MethodResultCache for example, not
to
> > speak of invalidation).
>
> Replying to myself is fun...
>
> Well, I finally came up with an attempt for a solution. It was less work
> than I expected, but I guess we are only halfway through. It passes the
> runtime test, however.
>
> It looks like this:
> ---8<---
> public Author getAuthor(Connection connection)
>      throws TorqueException
> {
>      if (aAuthor == null && (this.authorId != 0))
>      {
>          aAuthor =
> AuthorManager.getCachedInstance(SimpleKey.keyFor(this.authorId));
>          if (aAuthor == null)
>          {
>              aAuthor =
> AuthorPeer.retrieveByPK(SimpleKey.keyFor(this.authorId), connection);
>              AuthorManager.putInstance(aAuthor);
>          }
>      }
>      return aAuthor;
> }
> ---8<---
>
> While I was at it I corrected a few problems PMD complained about, but
> there is still room for improvement... :-)
>
> Any comments are welcome.
>
> Bye, Thomas.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-dev-help@db.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message