Represesntation of database NULL as something else than Java null pointer

From: Øyvind Harboe (oyvind.harbo..ylin.com)
Date: Thu Dec 14 2006 - 03:11:06 EST

  • Next message: Peter Schröder: "AW: objectFromDataRow with refresh"

    One thing that has caused us a lot of grief is that database null is
    represented as Java null pointer for e.g. strings, etc.

    99.99999% of all exceptions in our app are NPE's.

    Does Cayenne require that database null is represented as Java null pointer?

    Could I implement my own "NeverNullString" datatype where I'm thinking
    that .toString() returns the either what Cayenne java.lang.String
    returns today or e.g. "" for the case where it represents a database
    null?

    We would need to do the same for a couple of other datatypes, e.g. BigDecimal.

    java.lang.String is a final class, though BigDecimal is not...

    Additionally I would want to modify the equals method my
    NeverNullString object to not distinguish between database null or
    empty string so as not to cause unintended modifications to the
    database when used in combination w/Tapestry forms.

    http://cwiki.apache.org/CAY/mapping-jts-geometries.html

    This approach seems a lot cleaner and more powerful than trying to
    mess around with overriding read/writeProperty().

    -- 
    Øyvind Harboe
    http://www.zylin.com
    



    This archive was generated by hypermail 2.0.0 : Thu Dec 14 2006 - 03:11:54 EST