DuplicateKey exception while inserting record

Discussions

EJB programming & troubleshooting: DuplicateKey exception while inserting record

  1. DuplicateKey exception while inserting record (5 messages)

    Hi all,

    I am using Websphere Application server 3.02. I am getting a strange error while using entity bean.
    In my process, based on some business conditions i delete a record using the remove() method of entity bean.

    After deleting record if i try to insert a record using create() method of entity bean with same primary key i get DuplicateKey Exception.

    Any help on this would be appreciated.

    Sanjay.
  2. are you using CMP or BMP. If BMP (Bean Managed Persistence) check your database to C your DB record is getting deleted. There could be bug in you remove code?

    just in case?
  3. I have CMP in my entity bean.
  4. Have you ever solved this problem?
  5. Is the remove failing silently?
  6. I would recomend reviewing the primary key generation strategy in the first place.

    There is a nice thread in the subject here

    Cheers,
    Marco Garbelini