I am using Hibernate 5 and Spring 4. Executing the following SQL Query and getting error
Caused by: java.sql.SQLException: Column count doesn't match value count at row 1
SQLQuery query = getSessionFactory().getCurrentSession().createSQLQuery(" update irms_deleted_data SET reason=:reasonStr WHERE irms_id=:id ");
query.setString("reasonStr", "ABCD1234");
query.setInteger("id", irmsData.getId());
query.executeUpdate();
Any idea why I am getting this error?
I tried following (simple hibernate example)
create table irms_deleted_data (reason varchar2(10), irms_id number(11,0)); insert into IRMS_DELETED_DATA values ('xyz', 1);
Wrote a function:
private void updateirmsDeletedData() {
Transaction tx = null;
Session session = factory.openSession();
try {
tx = session.beginTransaction();
SQLQuery query = session.createSQLQuery("update irms_deleted_data SET reason=:reasonStr WHERE irms_id=:id");
query.setString("reasonStr", "ABCD1234");
query.setInteger("id", 1);
query.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
tx.commit();
session.close();
}
and that worked....
Also can you check if there is a trigger on irms_deleted_data which is doing something that is causing the issue...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.