1 Reply Latest reply on Feb 21, 2002 12:33 PM by Armin

    CMP field validation

    Marcus Brito Novice

      Hello, folks. I've got an Entity Bean using CMP. One of the entity's properties has a limited domain, that is, it should only get a couple of predetermined values. How can I do this using CMP?

      Can I write a body for the abstract setter testing if the supplied value is valid? Or the method body will never be called?

        • 1. Re: CMP field validation
          Armin Newbie

          One thing you could do is not to expose the CMP field in the remote/local interface. Instead, implement another getter/setter and expose those methods. For example:

          public abstract String getEmailAddr();
          public abstract void setEmailAddr(String addr);

          public String getEmailAddress()
          return getEmailAddr();

          public void setEmailAddress(String addr) throws SomeException

          if(!isValid(addr)) throw new SomeException();

          Expose the second two methods in the interface.