Re: Is registerNewObject() required?

From: Michał Morzywołek (nirwan8..mail.com)
Date: Mon Sep 01 2008 - 03:50:00 EDT

  • Next message: Tarik: "Rolling back changes in ROP does seem to work"

    Hello Chris,

    i'm not a serious Cayenne developer so i might be wrong but as far as I know
    objects have to be registered with cayenne before any changes/reading of
    relationships. It can be done by registerNewObject() (for already existing
    objects) or createNewObject() (object is registered during creation). Like
    i've said - im out of the game for some time so i might be wrong :)

    *Announcement*Fresh Msc looking for a job - got any free spot ;-)?

    Goodluck,
    Michał Morzywołek

    2008/9/1 Chris Murphy <chris@strandz.org>

    >
    > I have a relationship between two entities whereby a Worker references
    > another Worker. The name of the relationship is 'actualBelongsToGroup'. When
    > I try to set one on the other using this relationship, Cayenne baulks:
    >
    > Caused by: java.lang.NullPointerException
    > at
    > org.apache.cayenne.CayenneDataObject.setToOneTarget(CayenneDataObject.java:297)
    > at
    > org.strandz.data.wombatrescue.objects.cayenne.auto._Worker.setActualBelongsToGroup(_Worker.java:229)
    > at
    > org.strandz.data.wombatrescue.objects.cayenne.Worker.setBelongsToGroup(Worker.java:139)
    >
    > The problem occurs because getDataContext() on the <being set> worker is
    > returning null.
    >
    > Do I have to dataContext.registerNewObject( <being set worker>) on the
    > <being set worker> before calling setActualBelongsToGroup( <another worker>)
    > on it?
    > What is the philosophy here? I thought I would be able to put together a
    > graph of objects, without regard to persistence issues, then later register
    > them, then commit?
    >
    > thanks - Chris
    >
    > --
    > Seaweed Software Pty Ltd,
    > http://www.strandz.org
    >
    >



    This archive was generated by hypermail 2.0.0 : Mon Sep 01 2008 - 03:50:38 EDT