Am saving some objects into a database
public boolean importPart(Part p) {
System.err.println("THIS FUNCTION DOESN'T ClOSE THE SESSION");
try {
tx = s.beginTransaction();
//s.saveOrUpdate(p);
s.save(p);
tx.commit();
System.out.println("Operation completed");
return true;
} catch (org.hibernate.exception.ConstraintViolationException e) {
System.out.println("Part exists in the database");
if (tx != null) {
tx.rollback();
}
return false;
} finally {
}
}
am still getting the exceptiontrace org.hibernate.exception.ConstraintViolationException I tried also
catch(Exception e){}
but still the trace is printed in the output
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at javaapplication4.Importer.importPart(Importer.java:58)
at javaapplication4.Importer.importFromFile(Importer.java:131)
at javaapplication4.MyProject.main(MyProject.java:31)
Caused by: java.sql.BatchUpdateException: ORA-00001: unique constraint (SASSYSTEM.PART_U01) violated
and when I try to catch
java.sql.BatchUpdateException
I get "this exception is never thrown in this try statement"
any ideas how can I get rid of this stackTrace ?