The key error here is "Duplicate entry 'admin' for key 2". It looks as if you are trying to save a user who already exists. Normally this happens because you do not have a field in your form for the user id (this should be a hidden field). As a result, when your request goes back to Hibernate it thinks you are persisting a new user rather than updating an existing one.
Mike. On 7/12/07, Mel Pison <[EMAIL PROTECTED]> wrote:
I am using appfuse 1.9x and webwork as the web framework Regarding my problem, I'm using the same object (User) from the example on appfuse. I cant update the information of the User object on the database on my application and throws some errors. Heres some part of those errors in tomcat after trigerring the save button to update the user profile on database. [Thinkscan] DEBUG [http-8080-Processor24] UserDaoHibernate.saveUser(49) | user's id: 2 [Thinkscan] WARN [http-8080-Processor24] JDBCExceptionReporter.logExceptions(71) | SQL Error: 1062, SQLState: 23000 [Thinkscan] ERROR [http-8080-Processor24] JDBCExceptionReporter.logExceptions(72) | Duplicate entry 'admin' for key 2 [Thinkscan] WARN [http-8080-Processor24] UserAction.save(154) | User 'admin' already exists! [Thinkscan] WARN [http-8080-Processor24] DefaultActionInvocation.executeResult(313) | No result defined for action com.voxsant.thinkscan.webapp.action.UserAction and result input I tried to test it for each tier and heres what ive got * * Dao test** [Thinkscan] INFO [main] UserDaoTest.loadContextLocations(136) | Loading context for: classpath*:/**/dao/applicationContext-*.xml,classpath*:META-INF/applicationContext-*.xml [Thinkscan] INFO [main] UserDaoTest.startNewTransaction(309) | Began transaction (1): transaction manager [ [EMAIL PROTECTED]; default rollback = true [Thinkscan] WARN [main] UserDaoHibernate.getUser(30) | uh oh, user '1000' not found... [Thinkscan] INFO [main] UserDaoTest.endTransaction(275) | Rolled back transaction after test execution [Thinkscan] INFO [main] UserDaoTest.startNewTransaction(309) | Began transaction (1): transaction manager [ [EMAIL PROTECTED]; default rollback = true [Thinkscan] INFO [main] UserDaoTest.endTransaction(275) | Rolled back transaction after test execution [Thinkscan] INFO [main] UserDaoTest.startNewTransaction(309) | Began transaction (1): transaction manager [ [EMAIL PROTECTED]; default rollback = true [Thinkscan] DEBUG [main] UserDaoHibernate.saveUser(49) | user's id: 1 [Thinkscan] INFO [main] UserDaoTest.endTransaction(275) | Rolled back transaction after test execution [Thinkscan] DEBUG [main] UserDaoHibernate.saveUser(49) | user's id: null [Thinkscan] WARN [main] JDBCExceptionReporter.logExceptions(71) | SQL Error: 1062, SQLState: 23000 [Thinkscan] ERROR [main] JDBCExceptionReporter.logExceptions(72) | Duplicate entry 'user' for key 2 [Thinkscan] DEBUG [main] UserDaoTest.testUpdateUser(60) | expected exception: could not insert: [com.voxsant..voxsant.thinkscan.model.User]; nested exception is org.hibernate.exception.ContraintViolationException: could not insert: [ com.voxsant.thinkscan.model.User] **Action test* -- *UserExistsException was thrown error on saving user /*** I printed it to console to test if an error occurred WARN [main] UserAction.save(154) | User 'user' already exists! Saving user DEBUG [main] UserDaoHibernate.saveUser(49) | user's id: 1 DEBUG [main] UserSecurityAdvice.afterReturning(118) | Removing 'user' from userCache added user DEBUG [main] UserManagerImpl.removeUser(67) | removing user: 2 * *Service test** [copy] Copying 2 files to C:\thinkscan\build\test\service\classes Testsuite: com.voxsant.thinkscan.service.UserManagerTest [Thinkscan] DEBUG [main] UserManagerImpl.removeUser(67) | removing user: 5 [Thinkscan] DEBUG [main] UserManagerTest.testUserExistsException(124) | expected exception: User 'admin' already exists! Tests run: 4, Failures: 0, Errors: 0, Time elapsed: 0.969 sec ------------- Standard Output --------------- [Thinkscan] DEBUG [main] UserManagerImpl.removeUser(67) | removing user: 5 [Thinkscan] DEBUG [main] UserManagerTest.testUserExistsException(124) | expected exception: User 'admin' already exists! * *It seems that my problems are more likely in saving(Dao) but I already compared my java classes to the original java files from the appfuse and they look the same. I still dont know the problem :D. I could add new records to user's table but i cant update it after inserting a record on my application Please suggest some solutions. Thanks! :D Michael Horwitz wrote: Which version of AppFuse and which web frontend are you using? Some more details on the exact nature of the problem would also be useful: when you say can't update, do you mean the data does not appear in the database or is an exception raised? Have you got unit tests for each tier and are they passing? Mike. On 7/12/07, **Mel Pison** <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> <[EMAIL PROTECTED]>> wrote: Hi All, Good Day everyone! I'm new here and I'm just starting in j2ee. I'm currently creating the same application from the tutorials(Person and User objects). I followed the steps from the tutorial and I already have a User object and I want to manipulate this object but I'm still encountering some problems. I just copied all the needed files for the User object from the myapp sample and I made some modifications on jsp files for viewing the user information. I could add a new record of user to my application but I cant update the user information including the new roles for a user. I already compared all my java files for users to the tutorials java files and it seems that there are no errors on that. I cant use the update functionality. Please suggest some solutions. Thanks! :D Regards, Mel Pison --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]><[EMAIL PROTECTED]> For additional commands, e-mail: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]><[EMAIL PROTECTED]>