lucas-issa / objectify-query

Automatically exported from code.google.com/p/objectify-query
0 stars 0 forks source link

Support the polymorphic queries introduced in Objectify 3.0. #13

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
In my mind there's two ways to go about this:

1) Create a class structure that mirrors the class structure of the entities to 
be queried.
-This could cause compile errors if there are hidden (i.e. overriden) fields.  
Not sure how Objectify handles that, or if worrying about it is even necessary 
(uncommon use case).
-This might make easier re-use of the existing code.

2) Create a flat class structure with each generated class generating methods 
for all properties in the ancestry chain.
-I think this is ideal.  Especially in the case where users want add features 
to the generated classes.  We could provide an annotation that allowed you to 
insert some special behavior that got inherited all the way down the tree (see 
below).  I think I'm stealing this idea from JAXB schema generated classes 
(studying that ahead of time may be beneficial). 

*****USER CLASSES******

@Entity
@QueryImplementation(MyBaseEntityQuery.class)
public class BaseEntity {
    ....
}

public class MyBaseEntityQuery extends BaseEntityQuery {

     // ad your own special query helper functions here.
    // notice we're extending a generated class.
}

@Subclass
public class SubEntity{
    ...
}

*****GENERATED CLASSES******

public class BaseEntityQuery{
    ... (generated content)
}

public class SubEntityQuery extends MyBaseEntityQuery{
   // The subclass inherits the custom helper functions
}

Original issue reported on code.google.com by james.ta...@gmail.com on 2 Sep 2011 at 11:57

GoogleCodeExporter commented 8 years ago
OOPS - should have read like this:
In my mind there's two ways to go about this:

1) Create a class structure that mirrors the class structure of the entities to 
be queried.
-This could cause compile errors if there are hidden (i.e. overriden) fields.  
Not sure how Objectify handles that, or if worrying about it is even necessary 
(uncommon use case).
-I think this is ideal.  Especially in the case where users want add features 
to the generated classes.  We could provide an annotation that allowed you to 
insert some special behavior that got inherited all the way down the tree (see 
below).  I think I'm stealing this idea from JAXB schema generated classes 
(studying that ahead of time may be beneficial). 

2) Create a flat class structure with each generated class generating methods 
for all properties in the ancestry chain.
-This might make easier re-use of the existing code.

Original comment by james.ta...@gmail.com on 2 Sep 2011 at 11:59