.SQLErrorCodeSQLExceptionTranslator - Unable to translate SQLException with Error code '0', will no

部署运行你感兴趣的模型镜像

iBatis resultMap报错 nullValue完美解决

url: http://blog.youkuaiyun.com/liguohuaty/article/details/4038437

 

错误信息:

SQLErrorCodesFactory - Database product name cached for DataSource [org.apache.commons.dbcp.BasicDataSource@19c5048]: name is 'MySQL'
SQLErrorCodesFactory - SQL error codes for 'MySQL' found
SQLErrorCodeSQLExceptionTranslator - Unable to translate SQLException with Error code '0', will now try the fallback translator
DataSourceUtils - Returning JDBC Connection to DataSource
Exception in thread "main" org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; 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.BulkBeanException; nested exception is com.ibatis.common.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.BulkBeanException
Caused by: com.ibatis.common.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.BulkBeanException
at 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.BulkBeanException
at 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>

 

您可能感兴趣的与本文相关的镜像

Llama Factory

Llama Factory

模型微调
LLama-Factory

LLaMA Factory 是一个简单易用且高效的大型语言模型(Large Language Model)训练与微调平台。通过 LLaMA Factory,可以在无需编写任何代码的前提下,在本地完成上百种预训练模型的微调

2025-09-18 15:29:33.615 [reactor-http-nio-5] DEBUG reactor.netty.http.server.HttpServerOperations - [a0e83397, L:/192.168.10.122:9000 - R:/192.168.10.221:51066] New http connection, requesting read 2025-09-18 15:29:33.615 [reactor-http-nio-5] DEBUG reactor.netty.transport.TransportConfig - [a0e83397, L:/192.168.10.122:9000 - R:/192.168.10.221:51066] Initialized pipeline DefaultChannelPipeline{(reactor.left.httpCodec = io.netty.handler.codec.http.HttpServerCodec), (reactor.left.httpTrafficHandler = reactor.netty.http.server.HttpTrafficHandler), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)} 2025-09-18 15:29:33.616 [reactor-http-nio-5] DEBUG reactor.netty.http.server.HttpServerOperations - [a0e83397, L:/192.168.10.122:9000 - R:/192.168.10.221:51066] Increasing pending responses, now 1 2025-09-18 15:29:33.616 [reactor-http-nio-5] DEBUG reactor.netty.http.server.HttpServer - [a0e83397-1, L:/192.168.10.122:9000 - R:/192.168.10.221:51066] Handler is being applied: org.springframework.http.server.reactive.ReactorHttpHandlerAdapter@250c00e8 2025-09-18 15:29:33.617 [reactor-http-nio-5] DEBUG o.s.web.server.adapter.HttpWebHandlerAdapter - [a0e83397-4] HTTP PUT "/master/shipper/update" 2025-09-18 15:29:33.617 [reactor-http-nio-5] DEBUG o.s.w.r.r.m.a.RequestMappingHandlerMapping - [a0e83397-4] Mapped to com.hvlink.controller.ShipperController#updateShipper(ShipperDTO) 2025-09-18 15:29:33.617 [reactor-http-nio-5] DEBUG o.s.w.r.r.m.a.RequestBodyMethodArgumentResolver - [a0e83397-4] Content-Type:application/json 2025-09-18 15:29:33.617 [reactor-http-nio-5] DEBUG o.s.w.r.r.m.a.RequestBodyMethodArgumentResolver - [a0e83397-4] 0..1 [com.hvlink.entity.dto.master.ShipperDTO] 2025-09-18 15:29:33.618 [reactor-http-nio-5] DEBUG reactor.netty.channel.FluxReceive - [a0e83397-1, L:/192.168.10.122:9000 - R:/192.168.10.221:51066] [terminated=false, cancelled=false, pending=0, error=null]: subscribing inbound receiver 2025-09-18 15:29:33.618 [reactor-http-nio-5] DEBUG o.s.http.codec.json.Jackson2JsonDecoder - [a0e83397-4] Decoded [ShipperDTO(id=29, companyCode=null, supplierCode=null, supplierName=0012000048 - 上海信耀电子有限公司, shipper (truncated)...] 2025-09-18 15:29:33.618 [reactor-http-nio-5] DEBUG o.s.jdbc.datasource.DataSourceTransactionManager - Creating new transaction with name [com.hvlink.service.impl.ShipperServiceImpl.updateShipper]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT 2025-09-18 15:29:33.618 [reactor-http-nio-5] DEBUG o.s.jdbc.datasource.DataSourceTransactionManager - Acquired Connection [ConnectionID:1 ClientConnectionId: 832daba7-ee0b-4bc1-9a5c-db187f8edc8d] for JDBC transaction 2025-09-18 15:29:33.618 [reactor-http-nio-5] DEBUG o.s.jdbc.datasource.DataSourceTransactionManager - Switching JDBC Connection [ConnectionID:1 ClientConnectionId: 832daba7-ee0b-4bc1-9a5c-db187f8edc8d] to manual commit 2025-09-18 15:29:33.628 [reactor-http-nio-5] DEBUG org.mybatis.spring.SqlSessionUtils - Creating a new SqlSession 2025-09-18 15:29:33.628 [reactor-http-nio-5] DEBUG org.mybatis.spring.SqlSessionUtils - Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6f745882] 2025-09-18 15:29:33.629 [reactor-http-nio-5] DEBUG o.m.spring.transaction.SpringManagedTransaction - JDBC Connection [ConnectionID:1 ClientConnectionId: 832daba7-ee0b-4bc1-9a5c-db187f8edc8d] will be managed by Spring 2025-09-18 15:29:33.629 [reactor-http-nio-5] DEBUG c.h.mapper.master.ShipperMapper.existsOtherDefault - ==> Preparing: SELECT CASE WHEN EXISTS ( SELECT 1 FROM tm_shipper WHERE is_default = '是' ) THEN 1 ELSE 0 END 2025-09-18 15:29:33.629 [reactor-http-nio-5] DEBUG c.h.mapper.master.ShipperMapper.existsOtherDefault - ==> Parameters: 2025-09-18 15:29:33.644 [reactor-http-nio-5] DEBUG c.h.mapper.master.ShipperMapper.existsOtherDefault - <== Total: 1 2025-09-18 15:29:33.644 [reactor-http-nio-5] DEBUG org.mybatis.spring.SqlSessionUtils - Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6f745882] 2025-09-18 15:29:33.644 [reactor-http-nio-5] DEBUG org.mybatis.spring.SqlSessionUtils - Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6f745882] from current transaction 2025-09-18 15:29:33.644 [reactor-http-nio-5] DEBUG c.hvlink.mapper.master.ShipperMapper.updateShipper - ==> Preparing: UPDATE tm_shipper SET company_code = ?, supplier_code = ?, shipper_name = ?, address = ?, contact_person = ?, contact_tel = ?, contact_mobile = ?, is_default = ? WHERE id = ? 2025-09-18 15:29:33.645 [reactor-http-nio-5] DEBUG c.hvlink.mapper.master.ShipperMapper.updateShipper - ==> Parameters: null, null, 发货方AC(String), null, 1(String), null, null, 否(String), 29(Integer) 2025-09-18 15:29:33.660 [reactor-http-nio-5] DEBUG org.mybatis.spring.SqlSessionUtils - Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6f745882] 2025-09-18 15:29:33.660 [reactor-http-nio-5] DEBUG o.s.j.support.SQLErrorCodeSQLExceptionTranslator - Unable to translate SQLException with Error code '515', will now try the fallback translator 2025-09-18 15:29:33.660 [reactor-http-nio-5] DEBUG o.s.jdbc.support.SQLStateSQLExceptionTranslator - Extracted SQL state class '23' from value '23000' 2025-09-18 15:29:33.661 [reactor-http-nio-5] DEBUG org.mybatis.spring.SqlSessionUtils - Transaction synchronization deregistering SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6f745882] 2025-09-18 15:29:33.661 [reactor-http-nio-5] DEBUG org.mybatis.spring.SqlSessionUtils - Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6f745882] 2025-09-18 15:29:33.661 [reactor-http-nio-5] DEBUG o.s.jdbc.datasource.DataSourceTransactionManager - Initiating transaction rollback 2025-09-18 15:29:33.661 [reactor-http-nio-5] DEBUG o.s.jdbc.datasource.DataSourceTransactionManager - Rolling back JDBC transaction on Connection [ConnectionID:1 ClientConnectionId: 832daba7-ee0b-4bc1-9a5c-db187f8edc8d] 2025-09-18 15:29:33.679 [reactor-http-nio-5] DEBUG o.s.jdbc.datasource.DataSourceTransactionManager - Releasing JDBC Connection [ConnectionID:1 ClientConnectionId: 832daba7-ee0b-4bc1-9a5c-db187f8edc8d] after transaction 2025-09-18 15:29:33.680 [reactor-http-nio-5] DEBUG o.s.w.r.r.m.annotation.ResponseBodyResultHandler - [a0e83397-4] Using 'application/json' given [application/json, text/plain, */*] and supported [application/json, application/*+json, application/x-ndjson, text/event-stream] 2025-09-18 15:29:33.680 [reactor-http-nio-5] DEBUG o.s.w.r.r.m.annotation.ResponseBodyResultHandler - [a0e83397-4] 0..1 [com.hvlink.common.Result<java.lang.String>] 2025-09-18 15:29:33.680 [reactor-http-nio-5] DEBUG o.s.http.codec.json.Jackson2JsonEncoder - [a0e83397-4] Encoding [Result(status=500, msg=<EOL><EOL>### Error updating database. Cause: com.microsoft.sqlserver.jdbc.SQLServer (truncated)...] 2025-09-18 15:29:33.681 [reactor-http-nio-5] DEBUG reactor.netty.http.server.HttpServerOperations - [a0e83397-1, L:/192.168.10.122:9000 - R:/192.168.10.221:51066] Detected non persistent http connection, preparing to close 2025-09-18 15:29:33.681 [reactor-http-nio-5] DEBUG reactor.netty.http.server.HttpServerOperations - [a0e83397-1, L:/192.168.10.122:9000 - R:/192.168.10.221:51066] Last HTTP packet was sent, terminating the channel 2025-09-18 15:29:33.681 [reactor-http-nio-5] DEBUG reactor.netty.channel.ChannelOperations - [a0e83397-1, L:/192.168.10.122:9000 - R:/192.168.10.221:51066] [HttpServer] Channel inbound receiver cancelled (operation cancelled). 2025-09-18 15:29:33.681 [reactor-http-nio-5] DEBUG o.s.web.server.adapter.HttpWebHandlerAdapter - [a0e83397-4] Completed 200 OK
最新发布
09-19
: Connection released: [id: 0][route: {}->http://192.168.12.59:6041][total kept alive: 1; route allocated: 1 of 20; total allocated: 1 of 200] 2025-08-29 09:54:39.783 DEBUG 21556 --- [ main] org.mybatis.spring.SqlSessionUtils : Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@68212585] 2025-08-29 09:54:39.925 DEBUG 21556 --- [ main] o.s.b.f.xml.XmlBeanDefinitionReader : Loaded 11 bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml] 2025-08-29 09:54:39.933 DEBUG 21556 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'DB2' 2025-08-29 09:54:39.965 DEBUG 21556 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'Derby' 2025-08-29 09:54:39.968 DEBUG 21556 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'H2' 2025-08-29 09:54:39.970 DEBUG 21556 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'HDB' 2025-08-29 09:54:39.977 DEBUG 21556 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'HSQL' 2025-08-29 09:54:39.979 DEBUG 21556 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'Informix' 2025-08-29 09:54:39.980 DEBUG 21556 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'MS-SQL' 2025-08-29 09:54:39.983 DEBUG 21556 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'MySQL' 2025-08-29 09:54:39.985 DEBUG 21556 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'Oracle' 2025-08-29 09:54:39.988 DEBUG 21556 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'PostgreSQL' 2025-08-29 09:54:39.991 DEBUG 21556 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'Sybase' 2025-08-29 09:54:39.994 DEBUG 21556 --- [ main] o.s.jdbc.support.SQLErrorCodesFactory : Looking up default SQLErrorCodes for DataSource [com.depower.datasource.config.DynamicDataSource@3596a9d5] 2025-08-29 09:54:39.994 DEBUG 21556 --- [ main] o.s.jdbc.datasource.DataSourceUtils : Fetching JDBC Connection from DataSource 2025-08-29 09:54:39.997 DEBUG 21556 --- [ main] o.s.jdbc.support.SQLErrorCodesFactory : SQL error codes for 'TDengine' not found 2025-08-29 09:54:39.998 DEBUG 21556 --- [ main] o.s.jdbc.support.SQLErrorCodesFactory : Caching SQL error codes for DataSource [com.depower.datasource.config.DynamicDataSource@3596a9d5]: database product name is 'TDengine' 2025-08-29 09:54:40.007 DEBUG 21556 --- [ main] s.j.s.SQLErrorCodeSQLExceptionTranslator : Unable to translate SQLException with Error code '537', will now try the fallback translator 2025-08-29 09:54:40.020 DEBUG 21556 --- [ main] c.d.datasource.aspect.DataSourceAspect : clean datasource
08-30
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值