ateubh
Janeiro 3, 2007, 12:58pm
#1
o seu arquivo facade deve estar assim
Session session = dao.HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
session.save(autoClean);
tx.commit();
dao.HibernateUtil.closeSession();
mude para isso
Session session = dao.HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
session.saveOrUpdate(autoClean);
tx.commit();
dao.HibernateUtil.closeSession();
ateubh
Janeiro 3, 2007, 12:59pm
#2
[quote=ateubh]o seu arquivo facade deve estar assim
Session session = dao.HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
session.save(...);
tx.commit();
dao.HibernateUtil.closeSession();
mude para isso
Session session = dao.HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
session.saveOrUpdate(...);
tx.commit();
dao.HibernateUtil.closeSession();
[/quote]
Caused by: java.sql.BatchUpdateException: Duplicate entry '89' for key 1
at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:648)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
... 71 more
Isso no ALTERAR
Esse campo é o do Codigo!!!
Alguem onde deve estar o erro
public void incluir(Cliente c) {
Session session = new HibernateSessionCreator().createSession();
try {
session.beginTransaction();
session.saveOrUpdate(c);
session.getTransaction().commit();
}catch(Exception ex) {
session.getTransaction().rollback();
//ex.printStackTrace();
throw new HibernateException(ex.getMessage());
}finally {
session.close();
}
}
já esta assim