Hi guys. I'm using WebWork and Hibernate3.2 and MySQL4.X I have a register form. When filling the form and press submit, I got the following exception : Duplicate key or integrity constraint violation, Yes, I know what you are thinking, I'm dublicating a unique key. No Sir, I'm not. After a couple of tries, it saved the form ! Trying again to register another user, I got the exception.
Duplicate key or integrity constraint violation, Yes, I know what you are thinking, I'm dublicating a unique key. No Sir, I'm not.
Unfortunately, you are. Exceptions like this are SQLExceptions which just report what the database error tells JDBC, Hibernate does not try to enforce any database constraints. If you can tell us a little more about what you are doing, perhaps someone can spot where you are going wrong.
The database schema for the database is generated by Hibernate
The relationship between User and CreditCard is one-to-one. The exception seems to origin from a duplicate value of email field of user_table. No, I'm not entering a duplicate value. user_table has only one row and I put logging statements to log each value I enter.
The first time I fill the form, I got an exception from WebWork. The second time, every thing is perfect. Trying to add a new user after that, I always got the duplicate value exception. I'm really tired, I have been trying to solve this for the last 48 hours.
I solve it ! Hibernate is not guilty, it is my stubidity :roll: To integerate WebWork with Spring, you have to declare action instances as singleton. Well, I was not doing so. So, every time the action executed, there is a User object and it will ask the facade to try to save it to the database again. Sorry Hibernate. And hearty thanks for you all.
And tomorrow is the circus! We can go to the circus! I love the circus! We can take this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!