Hi,
In my scenario, I have an AccountHead object which I mapped to a table.
I have the same page to create and modify the Account Head
I have a dropdown list in the page where I list all the account heads created.Selecting one accound head would display the details of that account head (I am using DWR for this)and the user can modify the details.This would issue an update to the DB.Also he can select an option called "create new" from the same dropdown and save that data ,which would actually create a new record.In this case the account id would be '0', and hibernate create and assign the new account head id(the data base field is an auto increament)
Now when I follow the the below sequence
1) Retrieve an existing record
2) Modify and save (update) the object
3) Select the "Create New" option to create new record
4) Save the date (insert)
I am getting an exception
"org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1"
Note : steps 1,2,3 executed successfully.
I have found out from the log that , hibernate issues first an insert statement and subsequently an update statement.
Please find the log trace
Code:
2008-09-18 03:06:28,529 [http-8080-2] DEBUG org.hibernate.pretty.Printer - com.scientia.dms.commons.vo.AccountHead{org_type=all, accountHead=test1111, accountHeadId=0, schedule=com.scientia.dms.commons.vo.AccountSchedule#-1, desc=test111}
2008-09-18 03:06:28,529 [http-8080-2] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2008-09-18 03:06:28,529 [http-8080-2] DEBUG org.hibernate.SQL - [b]insert into dms.dms_fin_account_master (SCHEDULE_ID, ACCOUNT_HEAD_NAME, ACCOUNT_HEAD_DESC, ORG_TYPE, ACCOUNT_HEAD_ID) values (?, ?, ?, ?, ?)[/b]2008-09-18 03:06:28,539 [http-8080-2] DEBUG org.hibernate.jdbc.AbstractBatcher - Executing batch size: 1
2008-09-18 03:06:28,539 [http-8080-2] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2008-09-18 03:06:28,539 [http-8080-2] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2008-09-18 03:06:28,539 [http-8080-2] DEBUG org.hibernate.SQL - [b]update dms.dms_fin_account_master set SCHEDULE_ID=?, ACCOUNT_HEAD_NAME=?, ACCOUNT_HEAD_DESC=?, ORG_TYPE=? where ACCOUNT_HEAD_ID=?[/b]2008-09-18 03:06:28,539 [http-8080-2] DEBUG org.hibernate.jdbc.AbstractBatcher - Executing batch size: 1
2008-09-18 03:06:28,549 [http-8080-2] ERROR org.hibernate.jdbc.AbstractBatcher - Exception executing batch:
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
Can anybody tell me why hibernate issues two DML statments , one insert and one update?
Thanks in Advance
Shaiju
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html