Hi all,
I am using hibernate for persisting the data, Instead of hibernate query I written my own query by using
<sql-insert> and <sql-update> in the <hibernate-mapping> file
and it was working fine.
After adding a new filed in the database table, I just modified the sql-insert and sql-update query but it started giving error !!
So I reverted back all changes in my db, and for testing purpose just interchanged my two columns in the update query then also its giving error.
My Hbm file ---*************************************************************
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.capco.ortos.orap.model.Issue" table="A1_Issue">
<id name="id" column="Id" type="long">
<generator class="sequence">
<param name="sequence">A_SEQ_ISSUES</param>
</generator>
</id>
<property name="name" column="NAME" type="string"/>
<property name="organizationUnit" column="FKS_ORG_UNIT" type="string"/>
<property name="location" column="FKS_LOCATION" type="string"/>
<property name="product" column="FKS_PRODUCT" type="string"/>
<property name="process" column="FKS_PROCESS" type="string"/>
<property name="riskCategory" column="FKS_RISK_CATEGORY" type="string"/>
<property name="event" column="FKS_EVENT" type="string"/>
<property name="assessor" column="FK_ASSESSOR" type="string"/>
<property name="assessorDelegate" column="FK_ASSESSOR_DELEGATE" type="string"/>
<property name="approver" column="FK_APPROVER" type="string"/>
<property name="approverDelegate" column="FK_APPROVER_DELEGATE" type="string"/>
<property name="currency" column="FKQ_CURRENCY" type="string"/>
<property name="type" column="FK_TYPE" type="string"/>
<property name="status" column="FK_STATUS" type="string"/>
<property name="issueGroup" column="FK_ISSUE_GROUP" type="string"/>
<property name="description" column="DESCRIPTION" type="string"/>
<property name="captureDate" column="CAPTURE_DATE"/>
<property name="targetCompletionDate" column="TARGET_COMPLETION_DATE"/>
<property name="targetReviewDate" column="TARGET_REVIEW_DATE" />
<property name="cost" column="COST" type="string"/>
<property name="estimatedCost" column="ESTIMATED_COST" type="string"/>
<property name="reductionOfCost" column="REDUCTION_OF_COST" type="string"/>
<property name="sourceApplication" column="SOURCE_APPLICATION" type="string"/>
<property name="sourceId" column="SOURCE_ID" type="string"/>
<property name="sourceValue" column="SOURCE_VALUE" type="string"/>
<property name="sourceDate" column="SOURCE_DATE" type="string"/>
<property name="originalScore" column="ORIGINAL_SCORE" type="string"/>
<property name="targetScore" column="TARGET_SCORE" type="string"/>
<property name="actualScore" column="ACTUAL_SCORE" type="string"/>
<property name="commentGeneral" column="COMMENT_GENERAL" type="string"/>
<property name="commentApprover" column="COMMENT_APPROVER" type="string"/>
<property name="trafficLights" column="TRAFFIC_LIGHTS" type="string"/>
<property name="isRiskReviewed" column="IS_RISK_REVIEWED" type="string"/>
<property name="isRiskAccepted" column="IS_RISK_ACCEPTED" type="string"/>
<property name="riskAcceptanceReason" column="RISK_ACCEPTANCE_REASON" type="string"/>
<property name="insuranceCoverage" column="INSURANCE_COVERAGE" type="string"/>
<property name="lastChangeUser" column="LAST_CHANGE_USER" type="string"/>
<property name="workFlowId" column="FKS_WORKFLOW_ID" type="long"/>
<sql-insert>
insert into A1_Issue (NAME, FKS_ORG_UNIT, FKS_LOCATION, FKS_PRODUCT, FKS_PROCESS, FKS_RISK_CATEGORY, FKS_EVENT, FK_ASSESSOR, FK_ASSESSOR_DELEGATE, FK_APPROVER, FK_APPROVER_DELEGATE, FKQ_CURRENCY, FK_TYPE, FK_STATUS, FK_ISSUE_GROUP,
DESCRIPTION, CAPTURE_DATE, TARGET_COMPLETION_DATE, TARGET_REVIEW_DATE, COST, ESTIMATED_COST, REDUCTION_OF_COST,
SOURCE_APPLICATION, SOURCE_ID, SOURCE_VALUE, SOURCE_DATE, ORIGINAL_SCORE, TARGET_SCORE, ACTUAL_SCORE, COMMENT_GENERAL,
COMMENT_APPROVER, TRAFFIC_LIGHTS, IS_RISK_REVIEWED, IS_RISK_ACCEPTED, RISK_ACCEPTANCE_REASON, INSURANCE_COVERAGE,
LAST_CHANGE_USER, FKS_WORKFLOW_ID, Id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, to_date(?,'YYYY.MM.DD'), to_date(?,'YYYY.MM.DD'), to_date(?,'YYYY.MM.DD'), ?, ?, ?, ?, ?, ?, to_date(?,'MM-DD-YYYY'), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
</sql-insert>
<sql-update>
update A1_Issue set NAME=?, FKS_ORG_UNIT=?, FKS_LOCATION=?, FKS_PRODUCT=?,
FKS_PROCESS=?, FKS_RISK_CATEGORY=?, FKS_EVENT=?, FK_ASSESSOR=?,
FK_ASSESSOR_DELEGATE=?, FK_APPROVER=?, FK_APPROVER_DELEGATE=?, FKQ_CURRENCY=?,
FK_TYPE=?, FK_STATUS=?, FK_ISSUE_GROUP=?, DESCRIPTION=?,
CAPTURE_DATE=to_date(?,'YYYY.MM.DD'), TARGET_COMPLETION_DATE=to_date(?,'YYYY.MM.DD'), TARGET_REVIEW_DATE=to_date(?,'YYYY.MM.DD'), COST=?, ESTIMATED_COST=?, REDUCTION_OF_COST=?, SOURCE_APPLICATION=?, SOURCE_ID=?, SOURCE_VALUE=?, SOURCE_DATE=to_date(?,'YYYY.MM.DD'), ORIGINAL_SCORE=?, TARGET_SCORE=?, ACTUAL_SCORE=?, COMMENT_GENERAL=?, COMMENT_APPROVER=?, TRAFFIC_LIGHTS=?, IS_RISK_REVIEWED=?, IS_RISK_ACCEPTED=?, RISK_ACCEPTANCE_REASON=?, INSURANCE_COVERAGE=?, LAST_CHANGE_USER=?, FKS_WORKFLOW_ID=? where Id=?
</sql-update>
</class>
</hibernate-mapping>
*****************************************************
DAO - Code
Session session = HibernateSession.currentSession();
session.update(issue);
session.flush();
***************************************************
The above code is working fine…but if I interchange the column in <sql-update>
For example “NAME” and “FKS_ORG_UNIT” it will give error like
*****************************************************
12:13:44,633 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
*************************************************************
So what is the problem?...should I give in the same order?....so how can I add a new field and update the query?
Pleas help me
|