I've done some more testing and discovered I should have been using lower
case for the properties. I'm now having problems with the name bit:
Expression exp = ExpressionFactory.matchExp("class.name", "Item");
Exception in thread "main" org.objectstyle.cayenne.exp.ExpressionException:
[v.1.2M6 October 6 2005] Error evaluating expression 'class.name = "Item"'
Caused by: org.objectstyle.cayenne.CayenneRuntimeException: [v.1.2M6 October
6 2005] Invalid path: class.name
at
org.objectstyle.cayenne.CayenneDataObject.readNestedProperty(CayenneDataObje
ct.java:171)
Any ideas?
Dave
> -----Original Message-----
> From: Dave Merrin [mailto:dmerri..pasystems.co.uk]
> Sent: 10 January 2006 12:33
> To: cayenne-use..bjectstyle.org
> Subject: RE: Is registerNewObject required?
>
>
> Hi Andrus,
>
> going back on an old subject now. I'm trying to filter my objects
> using the
> class name. I've tried the following but it throws an exception:
>
> Expression exp = ExpressionFactory.matchExp("Class.Name", "Item");
>
> Exception in thread "main"
> org.objectstyle.cayenne.exp.ExpressionException:
> [v.1.2M6 October 6 2005] Error evaluating expression 'Class.Name = "Item"'
> Caused by: java.beans.IntrospectionException: No property 'Class' found in
> class ipa.printexpress.data.Item
>
> Is this because the property is in the base class rather than the
> class I'm
> dealing with?
>
> 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 : Tue Jan 10 2006 - 08:35:02 EST