HI JD, thanks for the reply, but is there a way to to this without Twig? I mean, it's pretty basic what I'm trying to do, and probably google has provided a way to do it without needing an external library. Maybe I'm wrong, but I wouldn't like to depend on someones library! Thanks Fede
On Jan 15, 1:23 pm, jd <jdpatter...@gmail.com> wrote: > You mean you want to use OO in Java? Then you need Twig > > http://code.google.com/p/twig-persist/ > > It supports polymorphic relations and inheritance just like your > example with no configuration > > For example you could have: > > class D > { > Collection<C> cs; > > } > > which could contain A's or B's. > > To speed up querying and loading D's you can define them to be > embedded as components: > > class D > { > @Component(polymorphic=true) Collection<C> cs; > > } > > The polymorphic flag is needed to tell Twig to store the actual class > of the embedded component as an extra property which it needs a read- > time to create the instance. Usually this is not needed because Twig > can use the generic type of the Field to know that the Collection is > of C's. > > JD > > On Jan 15, 3:59 am, Federico Keen <federicok...@gmail.com> wrote: > > > Hi guys, I'm trying to use the datastore with a model like this: > > > Class A extends C > > { > > �...@persistent > > private String a1; > > > } > > > Class B extends C > > { > > �...@persistent > > private String b1; > > �...@persistent > > private D dAttribute; > > > } > > > Class D > > { > > �...@persistent > > private String d1; > > > } > > > Class C > > { > > �...@primarykey > > �...@persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) > > private Key id; > > > �...@persistent > > private double c1; > > �...@persistent > > private double c2; > > > } > > > How should I declare this in Java? > > How can I make queries? The following queries are failing and I don't > > can't find more help! > > > public List<A> get( String minC1, String maxC1 ) { > > PersistenceManager pm = WherePersistanceManagerFactory.get > > ().getPersistenceManager(); > > Query query = pm.newQuery(A.class); > > query.setFilter("c1 >= " + minC1 + " && c1 <= " + maxC1); > > return (List<A>) query.execute(); > > } > > > public List<B> get( String minC1, String maxC1 ) { > > PersistenceManager pm = WherePersistanceManagerFactory.get > > ().getPersistenceManager(); > > Query query = pm.newQuery(B.class); > > query.setFilter("c1 >= " + minC1 + " && c1 <= " + maxC1 + " > > && > > dAttribute.d1 = someConstant"); > > return (List<B>) query.execute(); > > } > > I can't understand how to store/retrieve classes that inherit from > > other classes or classes as attributes of other classes. I always get > > an error saying that the subclass hasn't got the superclass attribute > > or that the class that has a reference to the other class cannot find > > that attribute. > > Can anyone help me? > > Thanks!
-- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.