0 Replies Latest reply on Aug 18, 2005 6:39 PM by Mike Slyter

    Exception Handling

    Mike Slyter Newbie

      I have a unique case were a database trigger is used to provide data by raising an exception. The field is an identy column they just use the trigger to grab the auto generated number. My problem is I need to allow my EJB 3 to auto generate the id and the exception is raised and the process fails.

      How can I get at the exception to handle it if it is thrown in a Hibernate method call.

      Here is the exception:

      2005-08-18 16:13:27,625 DEBUG [org.hibernate.util.JDBCExceptionReporter] could not insert: [gov.utah.laborcommission.safety.entities.LcEntity] [insert into ENTITY (Data_Source_ID, Creation_Date, Entity_Name, Carrier_Flag, Email_Address, Employer_Flag, Organization_Flag, Person_Flag, Property_Flag, Self_Insured_Flag) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
      select @@identity]
      com.sybase.jdbc3.jdbc.SybSQLException: ZzZ2688411ZzZ
      


      The auto increment works fine, but the exception stops the insert.

      It appears that the exception is on the hibernate side. I put a try and catch block around the method that creates the instance of the entity bean using Exception and that didn't work.

      Any help would be appreciated.

      Mike