长春治疗北京泌尿系统最好的医院哪好

iBatis resultMap报错 nullValue完美解决 - ibatis-returning-string - ITkeyowrd
iBatis resultMap报错 nullValue完美解决
错误信息:SQLErrorCodesFactory - Database product name cached for DataSource [mons.dbcp.BasicDataSource@19c5048]: name is 'MySQL'SQLErrorCodesFactory - SQL error codes for 'MySQL' foundSQLErrorCodeSQLExceptionTranslator - Unable to translate SQLException with Error code '0', will now try the fallback translatorDataSourceUtils - Returning JDBC Connection to DataSourceException in thread &main& org.springframework.jdbc.UncategorizedSQLException: SqlMapC uncategorized SQLException for SQL []; SQL state [null]; error code [0];--- The error occurred in net/jbbs/dao/ibatis/map/user.xml. --- The error occurred while applying a result map. --- Check the user.userResult. --- The error happened while setting a property on the result object. --- Cause: net.sf.cglib.beans.BulkBeanE nested exception is mon.jdbc.exception.NestedSQLException:--- The error occurred in net/jbbs/dao/ibatis/map/user.xml. --- The error occurred while applying a result map. --- Check the user.userResult. --- The error happened while setting a property on the result object. --- Cause: net.sf.cglib.beans.BulkBeanExceptionCaused by: mon.jdbc.exception.NestedSQLException:--- The error occurred in net/jbbs/dao/ibatis/map/user.xml. --- The error occurred while applying a result map. --- Check the user.userResult. --- The error happened while setting a property on the result object. --- Cause: net.sf.cglib.beans.BulkBeanExceptionat com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:188)at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:104)at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:566)at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:541)at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106)at org.springframework.orm.ibatis.SqlMapClientTemplate$1.doInSqlMapClient(SqlMapClientTemplate.java:243)at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:193)at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForObject(SqlMapClientTemplate.java:241)at net.jbbs.dao.ibatis.UserDAOImpl.findByEmail(UserDAOImpl.java:54)at net.jbbs.test.UserTest.findByEmail(UserTest.java:42)at net.jbbs.test.UserTest.main(UserTest.java:34)Caused by: net.sf.cglib.beans.BulkBeanExceptionat net.jbbs.domain.User$$BulkBeanByCGLIB$$88b6b34d.setPropertyValues(&generated&)at com.ibatis.sqlmap.engine.accessplan.EnhancedPropertyAccessPlan.setProperties(EnhancedPropertyAccessPlan.java:33)at com.ibatis.sqlmap.engine.exchange.JavaBeanDataExchange.setData(JavaBeanDataExchange.java:112)at com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.setResultObjectValues(BasicResultMap.java:373)at com.ibatis.sqlmap.engine.mapping.statement.RowHandlerCallback.handleResultObject(RowHandlerCallback.java:64)at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.java:382)at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleMultipleResults(SqlExecutor.java:301)at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:190)at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:205)at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)... 10 more这个错误指出resultMap里有问题。说错误发生在设置某一个属性的时候,但是没有具体说明是一个怎么样的错误&NULL错误&。由于对于iBatis了解还不是很深,所以一时不知如何事好。只有在resultMap里面作文章,把里面的&result&注释掉一些,哈哈,程序居然正常跑起来了。看来我快要找到错误了,接着继续排除其它的&result&,终于让我找到出错的一行&result&了:&result column=&ORDER_NUM& property=&orderNum& jdbcType=&long& /&&!--接下来得弄清楚是一个什么样的错误,怎么去修复它。查找数据库表,发现&orderNum&这一列是nullable,并且没有为它设置默认值。所以表里面orderNum这一列有许多都为NULL。我大概明白了,肯定是iBatis试图把从数据库读出来的NULL 值写入对象属性的时候出现异常。采取的补救措施就是:&result column=&ORDER_NUM& property=&orderNum& jdbcType=&long&nullValue=&0&/&对从数据库读出来的NULL值采用一个相应可转换为orderNum类型的值来替换附: &resultMap id=&pageStaticItemMap& class=&PageStaticItem&&&result column=&ITEMID& property=&itemId& jdbcType=&long&/&&result column=&ITEMNAME& property=&itemName& jdbcType=&String&/&&result column=&SERVERID& property=&serverId& jdbcType=&long&/&&result column=&SOURCE& property=&source& jdbcType=&String&/&&result column=&TARGET_PATH& property=&targetPath& jdbcType=&String&/&&result column=&TARGET_FILE& property=&targetFile& jdbcType=&String&/&&result column=&LOCAL_PATH& property=&localPath& jdbcType=&String&/&&result column=&FTP_PATH& property=&ftpPath& jdbcType=&String&/&&result column=&ITEMTYPE& property=&itemType& jdbcType=&String&/&&result column=&EXT1& property=&ext1& jdbcType=&String&/&&result column=&EXT2& property=&ext2& jdbcType=&String&/&&result column=&EXT3& property=&ext3& jdbcType=&String&/&&result column=&EXT4& property=&ext4& jdbcType=&String&/&&result column=&ORDER_NUM& property=&orderNum& jdbcType=&long& /&&!--这一行加一个nullValue=&0&就OK了--&&result column=&ITEM_TYPE& property=&item_Type& jdbcType=&String&/&&result column=&SERVER_PROPERTIES& property=&serverProperties& jdbcType=&String&/&&result column=&GET_SQL& property=&getSql& jdbcType=&String&/&&/resultMap&
错误信息:SQLErrorCodesFactory - Database product name cached for DataSource [mons.dbcp.BasicDataSource@19c5048]: name is 'MySQL'SQLErrorCodesFactory - SQL error co
相关阅读排行
相关内容推荐
请激活账号
为了能正常使用评论、编辑功能及以后陆续为用户提供的其他产品,请激活账号。
您的注册邮箱:
如果您没有收到激活邮件,请注意检查垃圾箱。java mybatie问题,再传map参数里面是list的时候,总是报传进去的参数为空
mybatise& xml配置
&select id="querybusisumucorplist"& resultType="BseBusiSum1" parameterType="Map"&
&&&&&&&&&&& SELECT ORGNO&& &
&&&&&&&&&&& FROM&& bsatraninfo
&&&&&&&&&&& WHERE& ORGNO in
&&&&&&&&&&& &foreach collection="orglist" item="id" index="index" open="(" separator="," close=")"&
&&&&&&&&&&&&&&& #{id}
&&&&&&&&&&& &/foreach&
&&& &/select&
&&&&&& orglist.add("22222");
&&&&&&& params.put("orglist", orglist);
&&&&&&& (params);
&&&&&&& bsebusisumucorplist = bseService.querybusisumucorplist(params);
报错### Error querying count.& Cause: org.apache.ibatis.type.TypeException: Error setting null for parameter #1 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型
### Cause: org.apache.ibatis.type.TypeException: Error setting null for parameter #1 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型
你把Map换成map试试?
parameterType="map“
其实你可以直接传list,也很方便
在mybatis里的configuration里面加上这段试试呢
&settings&
&setting name="jdbcTypeForNull" value="NULL" /&
&/settings&
http://my.oschina.net/u/2312022/blog/647341
或许你可以试试去掉“&parameterType="Map"” , 如果没理解错,是调用传递对象里面的get方法鏌ョ湅: 1439|鍥炲?: 7

我要回帖

更多关于 一般前列腺治多久才好 的文章

 

随机推荐