Is registerNewObject required?

From: Dave Merrin (dmerri..pasystems.co.uk)
Date: Wed Dec 07 2005 - 10:10:28 EST

  • Next message: Andrus Adamchik: "Re: Is registerNewObject required?"

    Hi,

    I'm trying to use cayenne to perform some queries on an in-memory list. The
    list of objects hasn't been loaded from a database using cayenne, it has
    just been created from some arbitrary data. All this was working fine.

    Now I've discovered my data doesn't represent just one type of object, it
    represents many related objects. As an example I have a TrackMessage object
    which now needs to have a related UniqueID object. Both classes extend
    CayenneDataObject. Now when I call setToOneTarget passing in a created
    MessageID I get the following exception:

    java.lang.NullPointerException
            at
    org.objectstyle.cayenne.CayenneDataObject.getRelationshipNamed(CayenneDataOb
    ject.java:400)
            at
    org.objectstyle.cayenne.CayenneDataObject.setToOneTarget(CayenneDataObject.j
    ava:343)
            at
    ipa.printexpress.tracker.logfilter.TrackMessage.setInstanceID(TrackMessage.j
    ava:132)
            at
    ipa.printexpress.tracker.logfilter.TrackMessage.<init>(TrackMessage.java:73)
            at
    ipa.printexpress.tracker.logfilter.MessageRouter.run(MessageRouter.java:35)
            at
    ipa.printexpress.tracker.logfilter.ThreadPoolWorker.runIt(ThreadPoolWorker.j
    ava:101)

    I'm sure the last time I saw this I needed to register the objects using
    DataContext.registerNewObject. The only thing is I don't have a DataContext
    and don't particulary want one (because none of this is related to a
    database connection).

    Is there any way round this problem? If I do have to create a DataContext
    object then does it have to actually be connected to a database? Do I need
    to tell the DataContext about the relationship of the objects?

    Any help would be greatly appreciated. I'm still hoping I can pull off this
    alternative way of using cayenne.

    Cheers,

    Dave



    This archive was generated by hypermail 2.0.0 : Wed Dec 07 2005 - 10:12:26 EST