-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Could not synchronize database state with session??
PostPosted: Fri Oct 21, 2005 7:12 am 
Newbie

Joined: Thu Oct 20, 2005 9:10 am
Posts: 7
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


Top
 Profile  
 
 Post subject: order
PostPosted: Fri Oct 21, 2005 6:25 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
from
http://www.hibernate.org/hib_docs/v3/re ... rtyresults

Quote:
The order of the positional parameters are currently vital, as they must be in the same sequence as Hibernate expects them.


_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 22, 2005 12:53 am 
Newbie

Joined: Thu Oct 20, 2005 9:10 am
Posts: 7
Thank you very much, when I put the new column in the order, it works

Thank you once again


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 07, 2005 1:14 am 
Regular
Regular

Joined: Fri Feb 25, 2005 3:02 am
Posts: 71
[quote="jaincj"]Thank you very much, when I put the new column in the order, it works

Thank you once again[size=18][/size][/quote]


Hi, but how will you know in which order hibernate expects the parameters so that you can put them in the required order?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 07, 2005 1:21 am 
Newbie

Joined: Thu Oct 20, 2005 9:10 am
Posts: 7
The order what hibernate is expecting is the same order of property definition

For example we defined two property like

--------------------------------------------------------------------------------------------
<property name="name" column="NAME" type="string"/>
<property name="organizationUnit" column="FKS_ORG_UNIT" type="string"/>

Then we have to apply in the query the same order, that is first “name” then “organizationUnit”


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 07, 2005 1:53 am 
Regular
Regular

Joined: Fri Feb 25, 2005 3:02 am
Posts: 71
ok thanks you very much for the answer


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.