RE: Is registerNewObject required?

From: Dave Merrin (dmerri..pasystems.co.uk)
Date: Mon Dec 12 2005 - 06:41:54 EST

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

    Hi Andrus,

    thanks for that. I've now changed things so I don't extend
    CayenneDataObject. That solves the problem where I have a java bean which
    contains another java bean. I'm still having trouble with my java bean
    containing a collection of java beans. I get the following exception:

    Caused by: java.beans.IntrospectionException: No property 'message' found in
    class java.util.ArrayList
            at
    org.objectstyle.cayenne.property.PropertyUtils.getPropertyDescriptor(Propert
    yUtils.java:230)
            at
    org.objectstyle.cayenne.property.PropertyUtils.getSimpleProperty(PropertyUti
    ls.java:178)
            at
    org.objectstyle.cayenne.property.PropertyUtils.getProperty(PropertyUtils.jav
    a:114)
            at
    org.objectstyle.cayenne.exp.parser.ASTObjPath.evaluateNode(ASTObjPath.java:8
    5)
            at
    org.objectstyle.cayenne.exp.parser.SimpleNode.evaluate(SimpleNode.java:243)
            at
    org.objectstyle.cayenne.exp.parser.SimpleNode.evaluateChild(SimpleNode.java:
    237)
            at
    org.objectstyle.cayenne.exp.parser.ASTEqual.evaluateNode(ASTEqual.java:95)
            at
    org.objectstyle.cayenne.exp.parser.SimpleNode.evaluate(SimpleNode.java:243)

    I can't see what I'm missing here?

    Dave

    > -----Original Message-----
    > From: Andrus Adamchik [mailto:andru..bjectstyle.org]
    > Sent: 07 December 2005 16:55
    > To: cayenne-use..bjectstyle.org
    > Subject: Re: Is registerNewObject required?
    >
    >
    > Dave,
    >
    > Relationships in Cayenne will only work for registered objects. So if
    > you application requires non-persistent objects, don't extend
    > CayenneDataObject at all - this doesn't buy you anything, and only
    > creates problems that you are seeing.
    >
    > Expression.evaluate() and Expression.filterObjects() will work with
    > any Java bean, DataObject or not. But the rest of Cayenne depends on
    > the fact that the objects are (a) mapped in the Modeler and (b)
    > registered with a DataContext.
    >
    > Andrus
    >
    > On Dec 7, 2005, at 6:10 PM, Dave Merrin wrote:
    > > 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 : Mon Dec 12 2005 - 06:44:03 EST