Hi experts
I have 2 columns defined as UNIQUE.
So when I insert a record which has the same UNIQUE-KEY,
I think I will catch a "duplicate key" exception.
Here is my problem:
I indeed see the exception, but it is thrown by somewhere inside Hibernate, but not the HibernateException I try to catch.
I need to catch it from HibernateException.
Did I miss something?
My program is really simple:
Connection conn = ConnectionFactory.getConnection();
Session session = _sessionFactory.openSession(conn);
Transaction tx = null;
try {
tx = session.beginTransaction();
// do something ....
session.save(data);
tx.commit();
} catch(HibernateException ex) {
// I thought I will catch the "duplicate key" exception here, but ...........
}
I use Hibernate 2.1.4, PostgreSQL 7.4.3 with its latest jdbc driver.
Thanks
|