Hi,

I'm currently developing an application where we want to handle all the 
exceptions within the application. When calling a persist on an entity which 
violates a unique constraint in the entity, I'm unable to catch it with the 
following code.

try {
                        // Use the Entity Manager to persist the given Object
                        manager.persist(obj);
                
                        return;
                }
                catch (IllegalArgumentException e) {
                        throw new DataLayerException(0, "persist", "Illegal 
Argument", e.toString(), null, e);
                }
                catch (TransactionRequiredException e) {
                        //throw new DataLayerException(1, "persist", 
"Transaction required", e.toString(), null, e);
                        return;
                } 
                catch (Throwable e) {
                        throw new 
DataLayerException(DataLayerException.UNKNOWN_EXCEPTION, "persist", "Unknown", 
e.toString(), null, e);
                }finally {
                        System.err.print("finally");
                }

And it throws the following. I've trimmed the error down to the initial cause.

10:05:46,185 INFO  [STDOUT] Hibernate: select PROGRAM.nextval from dual
10:05:46,185 INFO  [STDOUT] finally
10:05:46,201 INFO  [STDOUT] Hibernate: insert into PROGRAM (PROGRAM_NAME, 
PROGRAM_PARENT, DESCRIPTION, USABLE, PERMITTING_PROGRAM_ID) values (?, ?, ?, ?, 
?)
10:05:46,232 WARN  [JDBCExceptionReporter] SQL Error: 1, SQLState: 23000
10:05:46,232 ERROR [JDBCExceptionReporter] ORA-00001: unique constraint 
(PUBLIC.IDX_PROGRAM_NAME) violated

10:05:46,232 WARN  [JDBCExceptionReporter] SQL Error: 1, SQLState: 23000
10:05:46,232 ERROR [JDBCExceptionReporter] ORA-00001: unique constraint 
(PUBLIC.IDX_PROGRAM_NAME) violated

Caused by: java.sql.BatchUpdateException: ORA-00001: unique constraint 
(PUBLIC.IDX_PROGRAM_NAME) violated

        at 
oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
        at 
oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10656)
        at 
org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:487)
        at 
org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
        at 
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:193)
        ... 80 more


Any help will be greatly appreciated.

Thanks, Grant

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3946683#3946683

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3946683


-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to