Hi All,
I am experiencing some strange behavior with the iBatis cache (iBatis
version 2.3.x)
It seems like iBatis is caching empty ResultSets/ResultMap, below is a
select statement for a user which does not exist in the database.
Notice the last line iBatis is caching something but its not a User
object which is what it would be for a select with an existing user as
seen in the second log extract.
Any thoughts anyone?
This is a problem for me in the following scenario.
select user to see if he/she exists
insert user because does not exist
.... later ... select the user which now exists
In the above scenario the third statements returns a null object because
it is returning the "null" object which was cached from the first statement!
To make this work I would have to flush the cache every time I insert
the new user which to me makes no sense at all.
Thanks,
Serge
Output for select of non existing user with a strange cache behavior.
09 Feb 2008 14:40:10,406 47078 [http-8080-2] DEBUG
java.sql.PreparedStatement - {pstm-100004} Executing
Statement: SELECT * FROM users WHERE username = ?
09 Feb 2008 14:40:10,406 47078 [http-8080-2] DEBUG
java.sql.PreparedStatement - {pstm-100004} Parameters: [usera]
09 Feb 2008 14:40:10,406 47078 [http-8080-2] DEBUG
java.sql.PreparedStatement - {pstm-100004} Types: [java.lang.String]
09 Feb 2008 14:40:10,406 47078 [http-8080-2] DEBUG java.sql.ResultSet -
{rset-100005} ResultSet
09 Feb 2008 14:40:10,406 47078 [http-8080-2] DEBUG
com.ibatis.sqlmap.engine.cache.CacheModel - Cache 'User.user-cache':
stored object '[EMAIL PROTECTED]'
Output for a select of an existing user
09 Feb 2008 15:02:49,859 245953 [http-8080-1] DEBUG
java.sql.PreparedStatement - {pstm-100009} Executing
Statement: SELECT * FROM users WHERE username = ?
09 Feb 2008 15:02:49,859 245953 [http-8080-1] DEBUG
java.sql.PreparedStatement - {pstm-100009} Parameters: [userc]
09 Feb 2008 15:02:49,859 245953 [http-8080-1] DEBUG
java.sql.PreparedStatement - {pstm-100009} Types: [java.lang.String]
09 Feb 2008 15:02:49,859 245953 [http-8080-1] DEBUG java.sql.ResultSet
- {rset-100010} ResultSet
09 Feb 2008 15:02:49,859 245953 [http-8080-1] DEBUG java.sql.ResultSet
- {rset-100010} Header: [id, username, password_hash,
pwd_reminder_email, active]
09 Feb 2008 15:02:49,859 245953 [http-8080-1] DEBUG java.sql.ResultSet
- {rset-100010} Result: [7, userc, w1vwW2KgIeg=, [EMAIL PROTECTED], true]
09 Feb 2008 15:02:49,859 245953 [http-8080-1] DEBUG
com.ibatis.sqlmap.engine.cache.CacheModel - Cache 'User.user-cache':
stored object '[EMAIL PROTECTED]'