SQL错误:17059,SQL状态:99999:org.hibernate.util.JDBCExceptionReporter- [错误]:无法转换为内部表示形式

时间:2019-07-16 11:27:11

标签: java sql hibernate maven spring-mvc

在调用API时从休眠查询下面获取异常。

dao类方法:

public List<ErmChangeLog> fetchChangeLog(JsonInput jsonInput) throws SQLException {
    Session session = this.sessionFactory.openSession();    
    List<ErmChangeLog> objectList = null;
    Long instanceKey = 0L;
    try {
        instanceKey = jsonInput.getSystematic_Risk_ID();
        logger.debug("Connection creation process is completed.");
        Query query = session.createQuery(CommonConstants.fetch_ChangeLog);
        logger.info("query   : " + CommonConstants.fetch_ChangeLog);
        query.setParameter("instanceKey", instanceKey);
        logger.info("instanceKey : " + instanceKey);
        objectList = query.list();

    } catch (Exception e) {
        logger.debug("Failed to fetch Change Log");
        e.printStackTrace();
        throw e;
    }
    session.close();
    return objectList;

}

query:字符串fetch_ChangeLog =“来自ErmChangeLog p,其中p.instanceKey =:instanceKey”;

例外:

    at java.lang.Thread.run(Thread.java:745)
[2019-07-16 16:39:10,915]:org.hibernate.util.JDBCExceptionReporter-[WARN]: SQL Error: 17059, SQLState: 99999
[2019-07-16 16:39:10,915]:org.hibernate.util.JDBCExceptionReporter-[ERROR]: Fail to convert to internal representation
[2019-07-16 16:39:10,916]:org.hibernate.jdbc.ConnectionManager-[DEBUG]: transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!

1 个答案:

答案 0 :(得分:0)

看起来您的参数与查询期望的数据类型不匹配。您可以尝试使用Integer代替Long吗?