RE: Scalar Types

From: Cris Daniluk (cris.danilu..laraview.com)
Date: Wed Feb 02 2005 - 09:57:51 EST

  • Next message: Reinaldo Coelho Sartorelli: "INSERT without specifying an parameter."

    >I tend to want to map properties that are nullable as objects
    >(ie. Boolean), and those that are not nullable as scalars
    >(ie. boolean).

    Doing so will make it difficult and annoying to change between nullable and
    not nullable if your data rules ever change. If you're worried about
    immediate null-enforcement, I find it better to override the setter with a
    constraint:

    public void setNonnullableField(Integer value) {
      if (value == null) throw new NullPointerException();
      writeProperty(NONNULLABLEFIELD_PROPERTY, value);
    }

    This gives your application immediate feedback, rather than waiting until
    commit. It creates a bit of dependence on the data structure in your domain
    object, but by using the field property, you ensure that the code stops
    compiling if you forget to update it after a field name change.

    Cris



    This archive was generated by hypermail 2.0.0 : Wed Feb 02 2005 - 09:57:21 EST