Vikash
Vikash

Reputation: 31

SQL Error: 17059, SQLState: 99999:org.hibernate.util.JDBCExceptionReporter-[ERROR]: Fail to convert to internal representation

Getting Exception from below hibernate query while calling the API.

dao class method:

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 : String fetch_ChangeLog= "from ErmChangeLog p where p.instanceKey =:instanceKey";

exception :

    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!

Upvotes: 2

Views: 17174

Answers (2)

Erik M
Erik M

Reputation: 59

I agree with the answer of @Ucello; this will appear when there is a data type mismatch. But also when running the wrong project's version.

I used to have separated front-end and back-end projects. When I ran Grails (front-end), I didn't realize I was running MyApp v3.1 but having started the Java back-end of MyApp v3.0. So, between the 3.1 and 3.0 versions, there was a mismatch in the data types and throwing this error.

Not sure if this helps other users. It took me time to realize :)

Upvotes: 1

Ucello
Ucello

Reputation: 276

Looks like your parameters do not match the data types expected by the query. Can you try with Integer instead of Long?

Upvotes: 5

Related Questions