views:

84

answers:

1

I am using Flex 4 with LCDS 3. I am having problems with properly handling exceptions.

I have a simple commit service like;

var commitToken:AsyncToken = _serviceName.serviceControl.commit(); // Commit the change.
commitToken.addResponder(new AsyncResponder(
function (event:ResultEvent, token:Object=null):void
    {
         Alert.show("DATA DELETED");
    },
function (event:FaultEvent, token:Object=null):void
    {
         Alert.show("Save failed: " + event.fault.faultString, "Error");
         _serviceName.serviceControl.revertChanges();
    }));

Now when I try to delete a row which has a child record I get the following error in my tomcat log;

    hdr(DSEndpoint) = my-rtmp
    hdr(DSId) = 9AFF219A-AB2A-3B60-D990-9E87A3D7CF71
java.lang.RuntimeException: Hibernate jdbc exception on operation=deleteItem error=Could not execute JDBC batch update : sqlError =  from SQLException: java.sql.BatchUpdateException: ORA-02292: integrity constraint (CATEGORY_FK) violated - child record found

followed by;

[LCDS]Serializing AMF/RTMP response
Version: 3
  (Command method=_error (0) trxId=10.0)
    (Typed Object #0 'flex.messaging.messages.ErrorMessage')
      rootCause = (Typed Object #1 'org.omg.CORBA.BAD_INV_ORDER')
        minor = 0
        localizedMessage = "The Servant has not been associated with an ORB instance"
        message = "The Servant has not been associated with an ORB instance"
        cause = null
        completed = (Typed Object #2 'org.omg.CORBA.CompletionStatus')
      destination = "CATEGORY"
      headers = (Object #3)
      correlationId = "D4B6573F-F8C2-0732-BD1C-6FD1C5979763"
      faultString = "Error occurred completing a transaction"
      messageId = "9AFF6D9A-3C1C-E99B-B00F-92E72069B64E"
      faultCode = "Server.Processing"
      timeToLive = 0.0
      extendedData = null
      faultDetail = null
      clientId = "C2F15FE1-2977-23AA-1ADD-6FD1C096A82F"
      timestamp = 1.281776280572E12
      body = null

In flex in my "event" in the fault function I can only get general data like "Error occurred completing a transaction", but I cannot access the error "ORA-02292:...".

Is there a way to access it, as I need to handle multiple exceptions that Oracle will catch such as duplicate ID.....

+1  A: 

Best way is to grab the exceptions before LCDS translates them into Fault objects.

If you are using some Spring / Java to do business logic before hitting Hibernate, you should look at the custom exception translators.

If you are using the Hibernate adapter directly, this might be a bit tricky!

Gregor Kiddie