Issue
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!
Solution
Looks like your parameters do not match the data types expected by the query. Can you try with Integer instead of Long?
Answered By - Ucello