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, [email protected] <[email protected]> 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
