r wrote:
Post exact message, not "something like that" :)
OK, here it is:
Hibernate: update item set name=?, description=? where id=?
1422 [main] ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
	at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:85)
	at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:70)
	at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:47)
	at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2431)
	at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2335)
	at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2635)
	at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:115)
	at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
	at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
	at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
	at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
	at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:365)
	at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
	at hibernate.BatchAddOrUpdate.main(BatchAddOrUpdate.java:61)
Hibernate ExceptionBatch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
Exception in thread "main" java.lang.RuntimeException: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
	at hibernate.BatchAddOrUpdate.main(BatchAddOrUpdate.java:64)
Caused by: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
	at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:85)
	at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:70)
	at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:47)
	at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2431)
	at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2335)
	at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2635)
	at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:115)
	at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
	at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
	at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
	at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
	at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:365)
	at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
	at hibernate.BatchAddOrUpdate.main(BatchAddOrUpdate.java:61)
Here is  the program code:package hibernate;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
public class BatchAddOrUpdate {
	public static void main(String[] args) {
		Configuration cfg = new Configuration();
		// cfg.addResource("hibernate/Hibernate.cfg.xml");
		cfg.addResource("hibernate/item.hbm.xml");
		cfg.setProperties(System.getProperties());
		// cfg.setProperty("connection.driver_class",
		// "oracle.jdbc.driver.OracleDriver");
		// cfg.setProperty("connection.url",
		// "jdbc:oracle:thin:@athlon3200:1521:orcl");
		// cfg.setProperty("connection.username", "SCOTT");
		// cfg.setProperty("connection.password", "tiger");
		cfg.setProperty("hibernate.dialect",
				"org.hibernate.dialect.Oracle9iDialect");
		// System.out.println("cfg.getProperties().getProperty('user.country') =
		// " + cfg.getProperties().getProperty("user.country"));
		// System.out.println("cfg.getProperties().getProperty('connection.driver_class')
		// = " + cfg.getProperties().getProperty("connection.driver_class"));
		// System.out.println("cfg.getProperties().getProperty('connection.url')
		// = " + cfg.getProperties().getProperty("connection.url"));
		// System.out.println("cfg.getProperties().getProperty('connection.username')
		// = " + cfg.getProperties().getProperty("connection.username"));
		// System.out.println("cfg.getProperties().getProperty('connection.password')
		// = " + cfg.getProperties().getProperty("connection.password"));
		System.out
				.println("cfg.getProperties().getProperty('hibernate.dialect') = "
						+ cfg.getProperties().getProperty("hibernate.dialect"));
		SessionFactory sessions = cfg.buildSessionFactory();
		Item item = new Item();
		item.setId(8L);
		item.setDescription("Test Item #8a");
		item.setName("XXXXX #8a");
		Session session = ConnectionFactory.getInstance().getSession();
		try {
			Transaction tx = session.beginTransaction();
			session.saveOrUpdate(item);
		//  session.save(item);
		//	session.update(item);
		//	item.setDescription("set after");
		//	item.setName("set after");
		//	session.flush();
			tx.commit();
		} catch (HibernateException e) {
			System.err.println("Hibernate Exception" + e.getMessage());
			throw new RuntimeException(e);
		}
		/*
		 * Regardless of whether the above processing resulted in an Exception
		 * or proceeded normally, we want to close the Hibernate session. When
		 * closing the session, we must allow for the possibility of a Hibernate
		 * Exception.
		 * 
		 */
		finally {
			if (session != null) {
				try {
					session.close();
				} catch (HibernateException e) {
					System.err.println("Hibernate Exception" + e.getMessage());
					throw new RuntimeException(e);
				}
			}
		}
	}
}