Hi,
I accept suggestion about the management of INSERT into database.
I have a method in a sessionBean that simly does this operation
Entity manager em;
...
em.persist(NuovoRecord);
The problem is this, when the new record have a key equal to a stored object the
jboss shows an error and my application crash. I need to manage the duplicate case, in the sense that if the user is inserting an object that already exists (or that has a key already existent) i have to send back to user a message to advice him about it.
Using the
servlet and directly executing an sql code from it, i solved this problem using try catch(sqlException). in this case i can't, i try doing a flush before closing the method, and in this case i can catch the error and the application continue to works, but the jboss continues to show pages and pages of errors about duplicate keys.
What's the correct way for doing this operation?
Anyone can help me?
thans to all
Alessandro