java.sql.SQLException: Invalid utf8 character string: 'ACED00'

使用JPA+Hibernate执行原生sql查询时报了异常,一开始以为是数据库编码的问题,尝试了几种方式都没有解决,静下来想了想,原来是查询的sql中有status in (?1),而传入的参数值是枚举元素,导致无法解析,把传入的参数值改成枚举元素的name()就解决了。根本原因和异常中的ACED00还么有搞清楚是什么。

Caused by: java.sql.SQLException: Invalid utf8 character string: 'ACED00'

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)

at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)

at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)

at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2825)

at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2156)

at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2323)

at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)

at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)

at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:82)

... 58 more

你可能感兴趣的:(Hibernate)