BankCode or BankId???
According to your comment bank code is the primary. According to the XML mapping BankId is your Id, bank code is just unique. Do you have other records in the database with bank code 4000??
Look into your table status and check the autoIncrement value. If something is being inserted that should update.
Another question. Why is the error code saying "could not insert: [com.mdd.web.pojo.Bank] " and your XML says:
<class catalog="mysql" name="com.mdd.web.persistance.bank.Bank" table="bank">
Seems like the xml you published does not correspond to the class that is generating the error when being inserted.
1. Yes, Bank Id is primary and bank code is unique.
2. The table mysql.bank is empty. No record is there.
3. I have given the wrong class name, it should be com.mdd.web.pojo.Bank in Bank.hbm.xml file
I am not getting any errors/exception and I can able to see the insert query into the console, but the record is not in the table.However strangely If I try to give the same bank code, then duplication error, but records in that bank table. How come this error? Please help on this.