Re: Group function support

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Jun 10 2009 - 11:24:33 EDT

  • Next message: Andrus Adamchik: "Re: Problems with Expression.match()"

    Great! Let me try to guess about the nature of this error. EJBQL is
    resolved to SQLTemplate in the backend as an intermediate step. So I
    suspect the root of the generated SQLTemplate is set to Java class
    instead of entity name.

    Andrus

    On Jun 10, 2009, at 5:52 PM, Dave Lamy wrote:
    > Thanks for the FYI Andrus.
    >
    > I'll just punt to a named query for the time being. Thanks for
    > logging in
    > the JIRA. My concern would be that it would probably be a low-
    > priority
    > issue (since I'm apparently the only person who has come across
    > this).. to
    > that end, I'd be more than happy to look into the solution impl, but
    > would
    > definitely like to have someone to lean on as I dig into the call
    > stack.. if
    > you or anyone else could point me at some code on the SelectQuery
    > side that
    > does the entity-by-name lookup correctly, and a general point at the
    > area of
    > EJBQL that needs work, I can get my hands dirty and help.
    >
    > Thanks again for the great product and support--
    > Dave
    >
    > On Wed, Jun 10, 2009 at 7:37 AM, Andrus Adamchik <andru..bjectstyle.org
    > >wrote:
    >
    >> From what I can tell, nobody ever looked at this scenario (EJBQL with
    >> generic entities) yet, so I am not surprised it is broken. Let me
    >> log a Jira
    >> to investigate the issue. Sorry, this also means you'll have to use
    >> SQLTemplate.
    >>
    >> Andrus
    >>
    >>
    >>
    >> On Jun 10, 2009, at 12:14 AM, Dave Lamy wrote:
    >>
    >> Hey guys-- I'm trying to get group functions operational in my
    >>> Cayenne-backed system. As far as I can tell, the only support for
    >>> group
    >>> functions (min, max, count, etc) outside of rolling my own SQL is
    >>> EJBQL..
    >>> is
    >>> that true or am I missing something?
    >>>
    >>> Assuming this is the case: I'm having issues with my EJBQL
    >>> working when I
    >>> reference a generic Cayenne class. IE, my "Artist" data class
    >>> doesn't
    >>> have
    >>> a strong class implementation.. it just uses a standard base
    >>> class. This
    >>> feature has been great and is absolutely essential to our software.
    >>> However, in my test case I have a simple Artist class with no
    >>> concrete
    >>> impl:
    >>>
    >>> <obj-entity name="Artist" lock-type="optimistic"
    >>> dbEntityName="ARTIST"
    >>> superClassName="com.routeto1.data.DynamicDataObject">
    >>> <obj-attribute name="address" type="java.lang.String"
    >>> db-attribute-path="ADDRESS"/>
    >>> <obj-attribute name="name" type="java.lang.String"
    >>> db-attribute-path="NAME"/>
    >>> <obj-attribute name="type" type="java.lang.String"
    >>> db-attribute-path="TYPE"/>
    >>> </obj-entity>
    >>>
    >>> when I try to execute a simple EJBQL group test query:
    >>>
    >>> select count(a), a.name from Artist a group by a.name
    >>>
    >>> I get the following exception:
    >>>
    >>> org.apache.cayenne.CayenneRuntimeException: [v.3.0M5 Nov 29 2008
    >>> 21:12:47]
    >>> Can't perform lookup. There is more than one ObjEntity mapped to
    >>> com.routeto1.data.impl.DynamicDataObject
    >>> at
    >>>
    >>> org
    >>> .apache
    >>> .cayenne.map.EntityResolver._lookupObjEntity(EntityResolver.java:
    >>> 847)
    >>> at
    >>>
    >>> org
    >>> .apache
    >>> .cayenne.map.EntityResolver.lookupObjEntity(EntityResolver.java:701)
    >>> at
    >>>
    >>> org
    >>> .apache
    >>> .cayenne.query.BaseQueryMetadata.resolve(BaseQueryMetadata.java:99)
    >>> at
    >>>
    >>> org
    >>> .apache
    >>> .cayenne
    >>> .query.SQLTemplateMetadata.resolve(SQLTemplateMetadata.java:47)
    >>> at
    >>> org.apache.cayenne.query.SQLTemplate.getMetaData(SQLTemplate.java:
    >>> 157)
    >>> at
    >>>
    >>> org
    >>> .apache
    >>> .cayenne
    >>> .access.jdbc.SQLTemplateAction.<init>(SQLTemplateAction.java:77)
    >>> at
    >>>
    >>> org
    >>> .apache
    >>> .cayenne.dba.JdbcActionBuilder.sqlAction(JdbcActionBuilder.java:90)
    >>> at
    >>>
    >>> org
    >>> .apache
    >>> .cayenne.access.jdbc.EJBQLAction.performAction(EJBQLAction.java:100)
    >>> at
    >>>
    >>> org
    >>> .apache
    >>> .cayenne
    >>> .access.DataNodeQueryAction.runQuery(DataNodeQueryAction.java:57)
    >>> at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:
    >>> 236)
    >>> at
    >>>
    >>> org
    >>> .apache
    >>> .cayenne
    >>> .access.DataDomainQueryAction.runQuery(DataDomainQueryAction.java:
    >>> 423)
    >>> at
    >>>
    >>> org.apache.cayenne.access.DataDomainQueryAction.access
    >>> $000(DataDomainQueryAction.java:67)
    >>> ....
    >>>
    >>> which seems to read like the EJBQL impl doesn't support the
    >>> generic base
    >>> class concept. Am I right on this? I don't care about EJBQL,
    >>> just want
    >>> to
    >>> get group functions working without having to resort to rolling a
    >>> bunch of
    >>> dynamic SQL :-). Perhaps an upgrade to M6 is in order? Thanks in
    >>> advance
    >>> for any help you can provide!
    >>>
    >>> --Dave Lamy
    >>>
    >>
    >>



    This archive was generated by hypermail 2.0.0 : Wed Jun 10 2009 - 11:25:08 EDT