I've a problem with the entity manager of EJB3.0.
In fact, I've a business method in a session bean who adds simply several records into 5 entity beans. And the business logic requires that it be in one transaction, either success to add them all, or I rollback.
The trouble is the following : I've several concurrent client of this business session bean. They can call simultanously the business method to add records. And in many cases, some records of some entity can be duplicated. And I want just to bypass the creation if the record exists already.
But with the em.persist(), if the record exists, an EntityExistsException is thrown and the transaction is automatally rollbacked (however I want to continue, just discard the creation of the duplicated record, but I should continue to create other records).
I think it's a relatively common problem one can meet. But after searching on Google, I've not found a good answer.
How do you think about it? Maybe there's something wrong in my conception?
Thanks in advance for your help.