ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kai Mütz <kmu...@googlemail.com>
Subject NPE after updating to 2.3.1/2.3.2
Date Mon, 07 Jul 2008 16:53:57 GMT
Hi,

I have a simple sqlmap:

resultMap class="mypackage.Role" id="Role">
	<result property="role" column="role"/>
	<result property="description" column="description"/>
</resultMap>

<resultMap id="User" class="mypackage.User">
	<result property="username" column="name" jdbcType="VARCHAR" />
	<result property="password" column="password" jdbcType="VARCHAR" />
	<result property="email" column="email" jdbcType="VARCHAR" />
	<result property="enabled" column="enabled" jdbcType="BIT" />
	<result property="creationDate" column="creationDate" jdbcType="TIMESTAMP"
/>
	<result property="roles" column="name" select="user.selectRolesByName" />
</resultMap>

<select id="selectUserByName" resultMap="User">
	SELECT name, password, email, enabled, creationDate FROM User
	WHERE name = #VALUE#
</select>

<select id="selectRolesByName" resultMap="Role">
	SELECT auth.role, description FROM Authority auth
	INNER JOIN Role ON auth.role = Role.role
	WHERE auth.username = #VALUE#
</select>

With corresponding model objects User and Role. The roles property is of
type java.util.List. After upgrading from 2.3.0 to 2.3.1 or 2.3.2 I got the
following exception:

org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation;
uncategorized SQLException for SQL []; SQL state [null]; error code [0];
--- The error occurred in mypackage/UserSQLMap.xml.
--- The error occurred while applying a result map.
--- Check the user.User.
--- Check the result mapping for the 'roles' property.
--- Cause: java.lang.NullPointerException; nested exception is
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in mypackage/UserSQLMap.xml.
--- The error occurred while applying a result map.
--- Check the user.User.
--- Check the result mapping for the 'roles' property.
--- Cause: java.lang.NullPointerException
	at
org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQ
LStateSQLExceptionTranslator.java:121)
	at
org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translat
e(SQLErrorCodeSQLExceptionTranslator.java:322)
	at
org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemp
late.java:212)
	at
org.springframework.orm.ibatis.SqlMapClientTemplate.queryForObject(SqlMapCli
entTemplate.java:271)
	at de.mypackage.UserIBatisDAO.load(UserIBatisDAO.java:92)

[.....]

Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in mypackage/UserSQLMap.xml.
--- The error occurred while applying a result map.
--- Check the user.User.
--- Check the result mapping for the 'roles' property.
--- Cause: java.lang.NullPointerException
	at
com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithC
allback(MappedStatement.java:204)
	at
com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryForOb
ject(MappedStatement.java:120)
	at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapEx
ecutorDelegate.java:518)
	at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapEx
ecutorDelegate.java:493)
	at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSession
Impl.java:106)
	at
org.springframework.orm.ibatis.SqlMapClientTemplate$1.doInSqlMapClient(SqlMa
pClientTemplate.java:273)
	at
org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemp
late.java:209)
	... 27 more
Caused by: java.lang.NullPointerException
	at java.lang.Class.isAssignableFrom(Native Method)
	at
com.ibatis.sqlmap.engine.type.TypeHandlerFactory.getTypeHandler(TypeHandlerF
actory.java:143)
	at
com.ibatis.sqlmap.engine.type.TypeHandlerFactory.getTypeHandler(TypeHandlerF
actory.java:123)
	at
com.ibatis.sqlmap.engine.mapping.result.ResultMap.prepareBeanParameterObject
(ResultMap.java:591)
	at
com.ibatis.sqlmap.engine.mapping.result.ResultMap.getNestedSelectMappingValu
e(ResultMap.java:475)
	at
com.ibatis.sqlmap.engine.mapping.result.ResultMap.getResults(ResultMap.java:
341)
	at
com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.jav
a:384)
	at
com.ibatis.sqlmap.engine.execution.SqlExecutor.handleMultipleResults(SqlExec
utor.java:300)
	at
com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java
:189)
	at
com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteQuery(M
appedStatement.java:221)
	at
com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithC
allback(MappedStatement.java:189)
	... 33 more


The following snippet has been added to TypeHandlerFactory.getTypeHandler()
method

if (handler == null && Enum.class.isAssignableFrom(type)) { //Line 143
	handler = new EnumTypeHandler(type);
}

It seems that type is null.

Do I have to change anything in my sqlmap? Or what am I doing wrong?

Regards, Kai


Mime
View raw message