0 Replies Latest reply on Oct 8, 2007 9:00 AM by pdhaigh

    Elegant handling of foreign key constraints

    pdhaigh

      Hi,

      Is there an elegant way of handling a delete that fails due to a foreign key constraint?

      @Transactional
       public String remove()
       {
       try
       {
       return super.remove();
       }
       catch (EntityExistsException ve)
       {
       log.warn("Caught entity exists exception");
       return "removed";
       }
      }


      Allows me to catch the EntityExistsException, but I cannot directly catch ConstraintViolationException. (which is still logged as an error by AbstractFlushingEventListener).

      cheers

      phil