在一次发版后,之前一直有使用的一个sql查询转实体类报错实体类强转报错
但是更骚的是他这个报错还是不定性的。报错内容如下;
code: 500
error: "org.springframework.jdbc.UncategorizedSQLException:PreparedStatementCallback; uncategorized SQLException for SQL [xxx]; SQL state [null]; error code [0]; 转换查询结果到[xxx]出错:java.lang.ClassCastException@d1df98a; nested exception is java.sql.SQLException: 转换查询结果到[xxx]出错:java.lang.ClassCastException@d1df98a"
msg: "PreparedStatementCallback; uncategorized SQLException for SQL [xxx]; SQL state [null]; error code [0]; 转换查询结果到[xxx]出错:java.lang.ClassCastException@d1df98a; nested exception is java.sql.SQLException: 转换查询结果到[xxx]出错:java.lang.ClassCastException@d1df98a"
root: "java.sql.SQLException:转换查询结果到[xxx]出错:java.lang.ClassCastException@d1df98a"
stack: "- org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:89),\r\n- org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81),\r\n- org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81),\r\n- org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1442),\r\n- org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:632),\r\n- org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:668),\r\n- org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:699),\r\n- org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:711),\r\n- org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:762),\r\n- com.southgis.ibase.extend.service.SqlService.queryInner2(SqlService.java:412),\r\n- com.southgis.ibase.extend.service.SqlService.queryImpSql(SqlService.java:311),\r\n- com.southgis.ibase.extend.service.SqlService$$FastClassBySpringCGLIB$$f92a59e3.invoke(<generated>),\r\n- org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218),\r\n- org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:684),\r\n- com.southgis.ibase.extend.service.SqlService$$EnhancerBySpringCGLIB$$182676d5.queryImpSql(<generated>),\r\n- com.southgis.ibase.extend.service.SqlService.querySql(SqlService.java:264),\r\n- com.southgis.ibase.business.service.BusinessManagerService.getBusinessDefClass(BusinessManagerService.java:468),\r\n- com.southgis.ibase.business.service.BusinessManagerService.getBusinessDefByDiffType(BusinessManagerService.java:445),\r\n- com.southgis.ibase.business.service.BusinessManagerService.getBusinessDefTreeByCodeAndUserId(BusinessManagerService.java:177),\r\n- com.southgis.ibase.business.service.BusinessManagerService$$FastClassBySpringCGLIB$$c5d2b3de.invoke(<generated>),\r\n... 116 common frames omitted\r\n"
初步判断和线程有关,可是查询方法本身并没有启动线程。最终确认到是将该线程不安全类添加进了静态方法中导致并发时数据类型转换错误导致。