ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reub...@sonic.net
Subject Cache w/ Hierarchical ResultMaps
Date Wed, 26 Oct 2005 17:46:20 GMT
Hello, I found that the cache doesn't behave exactly as I'd have expected;
I'm using an LRU cache. Is there a way that I can configure it to behave
as I'd like?

I have a hierarchical object tree, mapped using ResultMaps:

<select id="getA" ... resultMap="Map_A" cacheModel="Cache_A"> ...

<resultMap id="Map_A">
   <result property="B" column="a_id" select="B.getB">
...

I am caching A. It looks like all of the Bs that belong to A are also
cached as part of this, such that if I change a property of B directly
(without saving A -- the "saveA" operation causes the cache to flush) I
cannot access this new B information by calling "getA" again (since the
old B is stored in the cache).

I can get around this by adding all of the mutateB..Z statements to A's
cachemodel, but this is inelegant, since I'm now mixing namespaces, and
could lead to bugs creeping into the project, since developers may not
realize that there is a cache at A when they are adding the mutateN
statement. I would like instead for B..Z to have their own cachemodel, and
for A to get its Bs from B's cachemodel instead of from within its own.
That way, A's cachemodel can worry only about A mutators; B's can worry
about B mutators, etc etc.

Does this make sense, and is it possible to do this using current syntax?

Thanks
Reuben




Mime
View raw message