Olá pessoal,
Estou usando o HIBERNATE 3 + TOMCAT 5.5 e quando vou tentar excluir um registro ele me retorna a seguinte exception:
Ps.: segue meus arquivos de configuração
===============================================
Exception in thread “main” org.hibernate.StaleStateException: Unexpected row count: 0 expected: 1
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:27)
at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2291)
at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2440)
at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:73)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:144)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at br.com.shc.database.dao.generic2.teste.TesteGenerericDAO.main(TesteGenerericDAO.java:111)
public class TesteGenerericDAO
{
@SuppressWarnings(“unchecked”)
public static void main(String[] args)
{
SessionFactory sessionFactory = SessionManager.createSessionFactory();
Session session = sessionFactory.openSession();
GenericSHCDAO genericSHCDAO = new GenericSHCDAO(Pessoa.class, session);
Transaction transaction = session.beginTransaction();
Pessoa pessoa2 = new Pessoa();
pessoa2.setId(new Integer(2).intValue());
genericSHCDAO.delete(pessoa2);
transaction.commit();
session.close();
}
}
Abraços,