0 Replies Latest reply on Aug 3, 2005 9:56 PM by gberish

    Can I Catch an SQLException in a CMP Entity Bean?

    gberish

      Hi,

      I am trying to find out if there is anyway for my own code to catch an SQLException thrown by the conatiner generated store () code generated for a CMP Entity Bean. I know I can catch the Exception by by using a more messey BMP Entity Bean.

      I am testing my first EJB appliaction.

      Its a local client using JMS messages to a server MessageDrivenBean to create an EntityBean and persit its state in a MySQL data base.

      The MySql table to which my bean persists has one column with a UNIQUE INDEX, and it all works fine until I try to add a record having a duplicate value for that column.

      Them it gets wierd on me.

      THe container tries 11 times to INSERT the record. Each time it fails but still INSERTS a junk record -- all null or emtpy columns except the primary key that is auto-incremented. 11 junk records!

      My logger show that then the MDB onMessage () method concludes without Exception and the message is dumped to the dead letter queue.

      Only then I can see a jboss specific DuplicateRecordException on the server console, but can't find a way to catch it.

      Is there anyway or am I condemed to BMP?

      GLB