cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Kienenberger" <>
Subject Re: Error when join table spans datamaps
Date Thu, 18 May 2006 22:55:25 GMT
On 5/18/06, Andrus Adamchik <> wrote:
> But this means that Cayenne will be doing a cartesian
> product in memory, turning Cayenne in a database engine. I am really
> not comfortable with "this is a natural limitation" excuse I was
> about to make. Still not sure how else we can solve this. Short of
> horrible performance, maybe doing joins within Cayenne SQLAction code
> is not such bad an idea???

I completely understand that this is going to give horrible performance.
But horrible performance is better than no performance.

This is my first-pass at solving the problem at the application level
by replacing getWorkList() { return (List)readProperty("workList"); }
with the following.   Seems like there might be a better way to do
this without an SQLTemplate.   If I hit a second relationship like
this, I would probably pull the string together from the
ObjEntity/DbEntity fields -- actually I might see if I can fix this in
the template since all of that info is available there.

However, I'm not certain that this is sufficient.  This might not be
something I can fix from the application level, short of removing the
relationships in the datamap.

I'm hoping I can leave addToWorkList and removeFromWorkList alone.

I haven't looked at SQLAction so I'm not sure how that fits in yet.
I'll take a look when I get a chance.

    private List getWorkListTheHardWay()
        String sql = "select distinct(WORK_ID) as ID from

        // set parameters and run it...
        Map parameters = new HashMap();
        parameters.put("PRIMARY_KEY", getPrimaryKey());
        SQLTemplate rawSelect = new SQLTemplate(getClass(), sql, true);
        List distinctFKList = getDataContext().performQuery(rawSelect);

        List toManyList = new ArrayList(distinctFKList.size());
        Iterator foreignKeyIterator = distinctFKList.iterator();
        while (foreignKeyIterator.hasNext())
            DataRow dataRow = (DataRow);
            Object primaryKey = (Object) dataRow.get("ID");
            if (null == primaryKey)  continue;

com.gvea.core_work_mgmt.entity.cayenne.Work.class, primaryKey));

        return toManyList;

View raw message