cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ab@dataloy.com"...@dataloy.com>
Subject Re: ObjectSelect.columnQuery
Date Wed, 04 Oct 2017 11:59:44 GMT


On 2017-10-04 13:57, Nikita Timofeev <ntimofeev@objectstyle.com> wrote: 
> ObjectSelect.columnQuery can select individual columns, as it was
> designed just for that.
> However you can also use it to get full entities along with some
> arbitrary properties (aggregates, dependent objects, etc.).
> In your case you created property with type of "Cargo" and it returns
> you collection of Cargo objects.
> Just use correct type of required column (String, Integer, etc.).
> 
> However easiest (and also safe) way to use it is via static Properties
> generated in a superclass of your entity, i.e. something like this:
> 
> List<String> someStringProperties =
> ObjectSelect.columnQuery(Cargo.class,
> Cargo.SOME_STRING_PROPERTY).select(ctx);
> 
> 
> On Wed, Oct 4, 2017 at 12:45 PM, ab@dataloy.com <ab@dataloy.com> wrote:
> > Should ObjectSelect.columnQuery  execute a SQL query with just one column selected?
> >
> > I am using Cayenne 4.1 but running this code:
> >
> > Property<Cargo> property1 = Property.create("area", Cargo.class);
> >
> > List<Cargo> select = ObjectSelect.columnQuery(Cargo.class,property1).where(Expression.fromString("area>10")).select(ctx);
> >
> > the query executed select all the columns of cargo table.
> >
> > I need to specify which columns the queries must return because I have tables with
hundreds of columns that I do not need, returning all the columns every time is very time
consuming.
> >
> > Andrea
> 
> 
> 
> -- 
> Best regards,
> Nikita Timofeev

Perfect, I got it. Now it works I expected.

Many thanks

Mime
View raw message