API for Proejction Queries

12 views
Skip to first unread message

Emanuele Ziglioli

unread,
Oct 10, 2012, 7:11:49 PM10/10/12
to siena-...@googlegroups.com
Hi everyone,

I'm thinking about starting to use GAE's projection queries, where you can query only certain fields and not the whole entity. Thinking about how to do it in Siena, what do you think about something like:

<V>V Model.all(Class<T> clazz).get( String field ); // it returns one field only
<T>T Model.all(Class<T> clazz).get( String fields... ); // it queries and fills the model with a subset of fields

Alternatively we could look at implementing polymorphic classes that way, where only the fields of a certain queried, not the whole entitiy. So there would be a static definition of a subset of an entity, as a new class, but with some annotations to say that that class is polymorfic to another, larger entity.

Pascal Voitot Dev

unread,
Oct 11, 2012, 2:59:14 AM10/11/12
to siena-...@googlegroups.com
projection is done on Query, isn't it?
why not adding filter on query directly?

<V>V Model.all(Class<T> clazz).projection( String field ).get();

do you have an example of your polymorphic class, I'm not sure to understand well.

Pascal

--
You received this message because you are subscribed to the Google Groups "Siena" group.
To view this discussion on the web visit https://groups.google.com/d/msg/siena-discuss/-/NIUlhRdkbLsJ.
To post to this group, send email to siena-...@googlegroups.com.
To unsubscribe from this group, send email to siena-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/siena-discuss?hl=en.

Emanuele Ziglioli

unread,
Oct 11, 2012, 4:42:44 PM10/11/12
to siena-...@googlegroups.com


On Thursday, 11 October 2012 19:59:37 UTC+13, Pascal wrote:
projection is done on Query, isn't it?
why not adding filter on query directly?

<V>V Model.all(Class<T> clazz).projection( String field ).get();

that's a good idea
 

do you have an example of your polymorphic class, I'm not sure to understand well.

let me think..., a class Animal contains (name, species, breed, owner)
A class Dog could extend Animal in a polymorphic way, so it could add or remove fields.
The point is storing all Animals in one big Animal table without necessarily adding all fields for all sub-entities to the parent entity.
I suppose this is not the same as the case of projection queries but it would be perhaps an alternative way to implement polymorphism.

Pascal Voitot Dev

unread,
Oct 11, 2012, 5:39:23 PM10/11/12
to siena-...@googlegroups.com
On Thu, Oct 11, 2012 at 10:42 PM, Emanuele Ziglioli <the...@emanueleziglioli.it> wrote:


On Thursday, 11 October 2012 19:59:37 UTC+13, Pascal wrote:
projection is done on Query, isn't it?
why not adding filter on query directly?

<V>V Model.all(Class<T> clazz).projection( String field ).get();

that's a good idea
 

do you have an example of your polymorphic class, I'm not sure to understand well.

let me think..., a class Animal contains (name, species, breed, owner)
A class Dog could extend Animal in a polymorphic way, so it could add or remove fields.
The point is storing all Animals in one big Animal table without necessarily adding all fields for all sub-entities to the parent entity.
I suppose this is not the same as the case of projection queries but it would be perhaps an alternative way to implement polymorphism.
 

I see! This is something interesting and a feature NoSQL can provide and Sql can't ;)
I think it would be cool yes to have this and actually I wanted to propose it at the beginning but was limited by GAE... but you're not anymore ;)
 

Pascal

On Thu, Oct 11, 2012 at 1:11 AM, Emanuele Ziglioli <the...@emanueleziglioli.it> wrote:
Hi everyone,

I'm thinking about starting to use GAE's projection queries, where you can query only certain fields and not the whole entity. Thinking about how to do it in Siena, what do you think about something like:

<V>V Model.all(Class<T> clazz).get( String field ); // it returns one field only
<T>T Model.all(Class<T> clazz).get( String fields... ); // it queries and fills the model with a subset of fields

Alternatively we could look at implementing polymorphic classes that way, where only the fields of a certain queried, not the whole entitiy. So there would be a static definition of a subset of an entity, as a new class, but with some annotations to say that that class is polymorfic to another, larger entity.

--
You received this message because you are subscribed to the Google Groups "Siena" group.
To view this discussion on the web visit https://groups.google.com/d/msg/siena-discuss/-/NIUlhRdkbLsJ.
To post to this group, send email to siena-...@googlegroups.com.
To unsubscribe from this group, send email to siena-discus...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/siena-discuss?hl=en.

--
You received this message because you are subscribed to the Google Groups "Siena" group.
To view this discussion on the web visit https://groups.google.com/d/msg/siena-discuss/-/RLA0VAEHjHEJ.
Reply all
Reply to author
Forward
0 new messages