ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From -dk- <dmitriy.kargapo...@gmail.com>
Subject null pointer exception when setting @Options(useCache = false)
Date Fri, 04 Dec 2009 04:33:28 GMT

Hi All.
I'm using iBatis 3 beta 5 for Java 6 with ojdbc6.jar (Oracle 11g).

I got working simple mapper like this:

public interface RateMapper {
       @Select("select rate from rate_table where rate_id = #{id}")
       double getRate(int id);
}

Then I tried to disable cache for this statement:

public interface RateMapper {
       @Options(useCache = false)
       @Select("select rate from rate_table where rate_id = #{id}")
       double getRate(int id);
}

and got NullPointerException...

digging through the code I found it thrown because following statement
returns null:
KeyGenerator keyGenerator = mappedStatement.getKeyGenerator();

in the
org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize()
method.

Intuitively adding to the Options "useGeneratedKeys = true" I was able to
get it working again:
...
 @Options(useCache = false, useGeneratedKeys = true)
...

How does option "useGeneratedKeys" relate to "useCache" in case of select
statement?
Does it actually relate or it just a side-effect making buggy code
fortunately working?

Thanks.



-- 
View this message in context: http://old.nabble.com/null-pointer-exception-when-setting-%40Options%28useCache-%3D-false%29-tp26635759p26635759.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Mime
View raw message