Matt: I changed to catch DataAccessException or even Exception, it makes no difference.
user.setId(null); endTransaction(); try { dao.saveUser(user); fail("saveUser didn't throw DataIntegrityViolationException"); } catch (DataAccessException e){ assertNotNull(e); log.debug("expected exception: " + e.getMessage()); } ----------------------- [junit] [cwr] ERROR [main] JDBCExceptionReporter.logExceptions(72) | [IBM][C LI Driver][DB2/NT] SQL0803N One or more values in the INSERT statement, UPDATE statement, or foreign key update caused by a DELETE statement are not valid beca use the primary key, unique constraint or unique index identified by "2" constra ins table "CWR.APP_USER" from having duplicate rows for those columns. SQLSTATE =23505 [junit] [cwr] ERROR [main] AbstractFlushingEventListener.performExecutions(301) | Could not synchronize database state with session [junit] org.hibernate.exception.ConstraintViolationException: could not insert: [com.transunion.bpma.cwr.model.User] Qin -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Matt Raible Sent: Wednesday, May 30, 2007 12:06 PM To: users@appfuse.dev.java.net Subject: Re: [appfuse-user] test failed It sounds like Spring is not properly mapping DB2Exception to DataIntegrityViolationException. What happens if you change it to catch DataAccessException - does it pass then? Matt On 5/30/07, Ding, Qin <[EMAIL PROTECTED]> wrote: > > > > > Matt: > > > > I am running appfuse 1.9.4 with JSF and DB2. I found an article you posted > regarding appfuse with DB2 issue and how to fix them. I came cross the same > error but not with the "testAddUserRole()". It is the "testUpdateUser()" > method throwing the following error. > > [junit] Caused by: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI > Driver][DB2/NT] SQL0803N One or mor > e values in the INSERT statement, UPDATE statement, or foreign key update > caused by a DELETE stateme > nt are not valid because the primary key, unique constraint or unique index > identified by "1" constr > ains table "ADMIN.USER_ROLE" from having duplicate rows for those columns. > SQLSTATE=23505 > > > > > If I comment out the following line from "testUpdateUser()", the test goes > well. How can I fix this problem? Thank you. > > > > user.setId(null); > > endTransaction(); > > try { > > dao.saveUser(user); > > //fail("saveUser didn't throw > DataIntegrityViolationException"); > > } catch (DataIntegrityViolationException e) { > > assertNotNull(e); > > log.debug("expected exception: " + e.getMessage()); > > } -- http://raibledesigns.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]