You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Hugi Thordarson <hu...@karlmenn.is> on 2011/10/19 13:46:46 UTC
Specifying what columns to fetch when using DataRows
Hi all.
I'm using DataRow fetching to optimize some queries. How do I specify what columns to fetch? Can I do something like this:
--------
SelectQuery q = new SelectQuery( Person.class );
q.setFetchingDataRows( true );
q.setDataRowKeyPaths( Arrays.asList( "name", "department.name", "address.city.country" ) );
--------
For those familar with EOF, I'd do this to achieve the same result:
--------
EOFetchSpecification fs = new EOFetchSpecification( "Person", null, null );
fs.setFetchesRawRows( true );
fs.setRawRowKeyPaths( Arrays.asList( "name", "department.name", "address.city.country" ) );
--------
Cheers,
- hugi
Re: Specifying what columns to fetch when using DataRows
Posted by John Huss <jo...@gmail.com>.
Read here <http://cayenne.apache.org/doc/data-rows.html>. "Data rows don't
have all the object-oriented features of DataObjects. *In particular, data
rows don't support relationships*."
John
On Wed, Oct 19, 2011 at 6:46 AM, Hugi Thordarson <hu...@karlmenn.is> wrote:
> Hi all.
>
> I'm using DataRow fetching to optimize some queries. How do I specify what
> columns to fetch? Can I do something like this:
>
> --------
> SelectQuery q = new SelectQuery( Person.class );
> q.setFetchingDataRows( true );
> q.setDataRowKeyPaths( Arrays.asList( "name", "department.name",
> "address.city.country" ) );
> --------
>
> For those familar with EOF, I'd do this to achieve the same result:
>
> --------
> EOFetchSpecification fs = new EOFetchSpecification( "Person", null, null );
> fs.setFetchesRawRows( true );
> fs.setRawRowKeyPaths( Arrays.asList( "name", "department.name",
> "address.city.country" ) );
> --------
>
> Cheers,
> - hugi
Re: Specifying what columns to fetch when using DataRows
Posted by Michael Gentry <mg...@masslight.net>.
Hi Hugi,
You probably want to use an SQLTemplate and specify the exact columns.
I don't recall seeing anything to support what you are asking for a
SelectQuery, although it sounds like a useful idea.
Thanks,
mrg
On Wed, Oct 19, 2011 at 7:46 AM, Hugi Thordarson <hu...@karlmenn.is> wrote:
> Hi all.
>
> I'm using DataRow fetching to optimize some queries. How do I specify what columns to fetch? Can I do something like this:
>
> --------
> SelectQuery q = new SelectQuery( Person.class );
> q.setFetchingDataRows( true );
> q.setDataRowKeyPaths( Arrays.asList( "name", "department.name", "address.city.country" ) );
> --------
>
> For those familar with EOF, I'd do this to achieve the same result:
>
> --------
> EOFetchSpecification fs = new EOFetchSpecification( "Person", null, null );
> fs.setFetchesRawRows( true );
> fs.setRawRowKeyPaths( Arrays.asList( "name", "department.name", "address.city.country" ) );
> --------
>
> Cheers,
> - hugi