Re: Is registerNewObject required?

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Mon Dec 12 2005 - 11:52:52 EST

  • Next message: Marcin Skladaniec: "3t server enchancements"

    > Do you know of any others which are good and might be worth looking
    > at?

    There is plenty of things out there that specifically deal with in-
    memory filtering...

    OGNL:

    http://www.ognl.org/

    Commons JXPath. I haven't tried it for anything advanced

    http://jakarta.apache.org/commons/jxpath/

    JDK 5 has built in XPath capabilities, though I don't know if they
    are applicable to non-XML objects:

    http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/xpath/package-
    summary.html

    > I would enter a Jira issue but I know you're not looking at adding
    > any more functionality to this version.

    This is true. But if nobody cares, it won't get in 1.3 either ;-)

    Andrus

    On Dec 12, 2005, at 6:11 PM, Dave Merrin wrote:

    > Hi Andrus,
    >
    > it's a shame this doesn't exist. I would enter a Jira issue but I know
    > you're not looking at adding any more functionality to this
    > version. By the
    > time you're onto the next version I think my project will be done and
    > dusted.
    >
    > I've had a quick look at the apache commons collection for
    > filtering a list.
    > Do you know of any others which are good and might be worth looking
    > at?
    >
    > Cheers,
    >
    > Dave
    >
    >> -----Original Message-----
    >> From: Andrus Adamchik [mailto:andru..bjectstyle.org]
    >> Sent: 12 December 2005 12:06
    >> To: cayenne-use..bjectstyle.org
    >> Subject: Re: Is registerNewObject required?
    >>
    >>
    >> Dave,
    >>
    >> You are not missing anything. Collections won't work with in-memory
    >> Expression API. This is a known limitation... we need to document it
    >> better I guess.
    >>
    >> The original reason behind this limitation was to preserve
    >> simplicity, so there wasn't a goal of building a full in-memory DB or
    >> XPath-like system. Now I tend to think we need to implement in-memory
    >> collection support for completeness. You may enter a feature request
    >> for that in Jira if this is important to you... Also you may try
    >> numerous XPath implementations that are more appropriate for advanced
    >> in-memory filtering.
    >>
    >> Andrus
    >>
    >>
    >> On Dec 12, 2005, at 2:41 PM, Dave Merrin wrote:
    >>
    >>> 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 - 11:52:55 EST