Hi,
I received a mail from our DBA saying that below query always reparsed by Oracle due to “bind mismatch” problem although we are using bind variables.
Code is -
There are 2 types of code which we used to insert data into tables.
Code1 with bind variables -
Code:
String hqlUpdate = "update " + boSource + " a set tibStatus = :loadStatusString where tibStatus = :intermediateStatusString and "+selectMaxOf +" from " + boSource
+ " where tibStatus = a.tibStatus " + sqlkeyCriteria + ")";
HashMap hParamMap = new HashMap();
hParamMap.put("loadStatusString", "LOAD");
hParamMap.put("intermediateStatusString", "INTR");
objectPS.executeQuery(hqlUpdate, hParamMap);
objectPS.flush();
Code2 without bind variables -
Code:
private void logErrorInDB(BOErrorLog objBOErrorLog, String userCode)
{
logger.logInfo("logErrorInDB", "Entering the method");
objBOErrorLog.setCreatedBy(userCode);
objBOErrorLog.setCreatedOn(new Date());
objBOErrorLog.setModifiedBy(userCode);
objBOErrorLog.setModifiedOn(new Date());
objectPS.saveOrUpdate(objBOErrorLog);
logger.logInfo("logErrorInDB", "Exiting the method");
}
generated SQL - Provided by DBA
Code:
insert into ERROR_LOG (OBJECT_CODE, OBJECT_KEY, PROCESS_CODE, ERROR_CODE, DESCRIPTION, CREATED_BY, CREATED_ON, MODIFIED_BY, MODIFIED_ON, id) values (:1, :2, :3, :4, :5, :6, :7, :8, :9, :10);
Please let me know why i am getting bind mismatch with bind variables itself? Or is there any other way to rewrite the above code to get rid of this problem.
Thanks in advance.