RE: Null pointer exceptions and database null

From: Gentry, Michael \(Contractor\) ("Gentry,)
Date: Fri Aug 04 2006 - 09:12:47 EDT

  • Next message: Øyvind Harboe: "Re: Null pointer exceptions and database null"

    Ah, now I feel your pain. :-)

    I have lots of cover code in my T4 application because of this OGNL "problem". There is no simple way, that I could find, to have OGNL handle it, either. They do have a NULL handler you can set, but it is per-class. Not too generic. I might have to think about EONull again, but it would probably be harder to implement in Java. Objective-C allows you to message any object with any message, including ones it doesn't understand, and handle it. This allowed EONull to always return an EONull when you requested an unknown property. In your example below, if "bar" was null, just returning a String wouldn't be enough because in Java, a String doesn't have a getName() method.

    What would probably be best, and I started to look into it but didn't get far, is to create a cayenne: prefix (instead of ognl:) for T4 which uses Cayenne's readNestedProperty() method, which can handle the NULL values.

    /dev/mrg

    PS. There isn't a writeNestedProperty() though ...

    -----Original Message-----
    From: oyvindharbo..mail.com [mailto:oyvindharboe@gmail.com] On Behalf Of Øyvind Harboe
    Sent: Friday, August 04, 2006 2:21 AM
    To: cayenne-use..ncubator.apache.org
    Subject: Re: Null pointer exceptions and database null

    There is no particular reason I don't want null handling work for
    relationships. Though possible, how to do this is clearly non-obvious.

    Consider an OGNL statement:

    foo.bar.name

    Here I want this entire expression to evaluate to an empty string.

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



    This archive was generated by hypermail 2.0.0 : Fri Aug 04 2006 - 09:13:18 EDT