cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Øyvind Harboe" <>
Subject Represesntation of database NULL as something else than Java null pointer
Date Thu, 14 Dec 2006 08:11:06 GMT
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

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.

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

Øyvind Harboe

View raw message