Ah... interesting. This is a bug. The cache in iBATIS is transactional. iBATIS also has a "feature" that only commits a transaction if a change was detected. These two features are conflicting. Since selects don't count as a "change", the transactional cache never flushes. If you call session.commit(true), you'll probably see calls to putObject.
Can you please file a JIRA ticket for this? Thanks much! 2009/9/7 Håkan Andersson <hakan.anders...@evertiq.com> > Hi > > Sorry for being unclear, I will try to explain a little better what I > have done. > > I have a fully working web application with the latest ibatis beta > 3.0.0.200 and what I did was to add <cache type="db.TestCache" /> to a > mapper, TestCache implements org.apache.ibatis.cache.Cache but at the > moment it only have logging statements, if I'm not horribly mistaken I > will see a "in putObject()" if hasKey() is false but I don't. > > My test class > public class TestCache implements Cache { > > static Logger log = Logger.getLogger(TestCache.class); > > private String id; > private ReadWriteLock readWriteLock = new ReentrantReadWriteLock(); > > /** > * @param id > */ > public TestCache(String id) { > super(); > this.id = id; > } > > @Override > public void clear() { > if (log.isDebugEnabled()) { > log.debug("in clear()"); > } > > } > > @Override > public String getId() { > if (log.isDebugEnabled()) { > log.debug("in getId()"); > } > > return this.id; > } > > @Override > public Object getObject(Object obj) { > if (log.isDebugEnabled()) { > log.debug("in getObject()"); > } > > return ""; > } > > @Override > public ReadWriteLock getReadWriteLock() { > if (log.isDebugEnabled()) { > log.debug("in getReadWriteLock()"); > } > > return this.readWriteLock; > } > > @Override > public int getSize() { > if (log.isDebugEnabled()) { > log.debug("in getSize()"); > } > > return 0; > } > > @Override > public boolean hasKey(Object obj) { > if (log.isDebugEnabled()) { > log.debug("in hasKey()"); > } > return false; > } > > @Override > public void putObject(Object arg0, Object arg1) { > if (log.isDebugEnabled()) { > log.debug("in putObject()"); > } > } > > @Override > public Object removeObject(Object arg0) { > if (log.isDebugEnabled()) { > log.debug("in removeObject()"); > } > > return null; > } > } > > > The logging shows > DEBUG java.sql.Connection - ooo Connection Opened > DEBUG db.TestCache - in getReadWriteLock() > DEBUG db.TestCache - in getReadWriteLock() > DEBUG db.TestCache - in hasKey() > DEBUG db.TestCache - in getReadWriteLock() > DEBUG java.sql.PreparedStatement - ==> Executing: (removed) > DEBUG java.sql.ResultSet - <== ResultSet Returned > DEBUG java.sql.ResultSet - <== Columns: (removed) > DEBUG java.sql.ResultSet - <== Row: (removed) > DEBUG java.sql.ResultSet - <== Row: (removed) > DEBUG db.TestCache - in getReadWriteLock() > DEBUG java.sql.Connection - xxx Connection Closed > > > > Best Regards > Håkan Andersson > > > On 06/09/09 09:21, Clinton Begin wrote: > > I'm not quite sure about your question... > > > > * What are you referring to when you say "the custom cache" -- I'm > > assuming that's something you've implemented. > > > > * How are you hooking it into your statements? > > > > * Can you provide a simple unit test to demonstrate the behavior (e.g. > > you could just use a simple hashmap implementation). > > > > Cheers, > > Clinton > > > > 2009/9/3 Håkan Andersson <hakan.anders...@evertiq.com > > <mailto:hakan.anders...@evertiq.com>> > > > > Hi > > > > I have been playing a little with the custom cache in ibatis 3.0 Beta > 3, > > but I can't see that the putObject is fired, is there any special > > condition that needs to be fulfilled before it will happen? > > hasKey, getObject and getReadWriteLock all get fired when it should > but > > not putObject. > > > > > > Best Regards > > Håkan Andersson > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org > > <mailto:user-java-unsubscr...@ibatis.apache.org> > > For additional commands, e-mail: user-java-h...@ibatis.apache.org > > <mailto:user-java-h...@ibatis.apache.org> > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org > For additional commands, e-mail: user-java-h...@ibatis.apache.org > >