3 Replies Latest reply on Nov 27, 2007 7:58 AM by alexandre russel

    data validation

    Jaime Martin Apprentice

      hi,
      in a form I want to validate that the code asigned in a field is one that already exists.
      For instance, I´ve a field for currencies. I have a table for them, and I want to check that the currency filled is already on the database to avoid foreign keys problems.
      I´ve found 2 solutions. The first is to override persist method and there by means of a query to check if that value is ok.
      The second is to add a try-catch in the persist, and in the catch check if there has been an Exception like this

      org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing:...

      Is there a better "seam-way" of validating this?
      thanks in advance!