Re: NullPointerException during object registration

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue Dec 16 2003 - 16:55:39 EST

  • Next message: Bill Fan: "RE: [Microsoft][SQLServer 2000 Driver for JDBC]ResultSet can not re-read row data for column 7."

    Jim,

    On Dec 16, 2003, at 2:56 PM, Jim Menard wrote:

    > There is indeed one relationship that is null, but it can't be
    > otherwise because, if I understand properly, I can't add that object
    > to this one yet in any case because this object is not yet part of the
    > context.
    >
    > Is there a Catch 22 here: I can't set the relationship because the
    > object does not yet have a context, but the relationship is manditory
    > (non-null) so it has to be set before I register the object.

    Looks like it has nothing to do with object relationships. I suspect
    that there is no mapping for a class that you are trying to register
    (and therefore no ObjEntity). I suggest using
    DataContext.createAndRegisternewObject(..) just like second code
    example in Chapter 6.3.1 shows, it is less error prone and produce an
    object of the class that is actually mapped in the model:

    http://objectstyle.org/cayenne/userguide/datactxt/statemanagement.html

    Hope this helps.... On Cayenne side of things I guess I need to add a
    sanity check for the case of unrecognized Java class, and throw an
    appropriate exception, instead of obscure NPE.

    Andrus



    This archive was generated by hypermail 2.0.0 : Tue Dec 16 2003 - 16:55:43 EST