1

I wanted to know if I can make a query to a class father and his son in the same query.

@Entity
public class Blog {
    @Getter
    @Setter
    @Id
    String id;

    @Getter
    @Setter
    int popularity;
}

@Entity
public class Post {
    @Id
    @Getter
    @Setter
    String id;

    @Getter
    @Setter
    String title;

    @Getter
    @Setter
    long published;

    @Getter
    @Setter
    String locale;

    @Getter
    @Setter
    @Load
    private Ref<Blog> parent; // or @Parent?

}

This would be possible? ->

Query list type Post > filter locale "Post" > order published "Post" > order popularity "Blog"

Thanks.

3 Answers 3

2

No, you cannot. This would be a join, and app engine does not support joins in queries. You either need to copy the data you want to filter on onto the Post entity, or else perform 2 separate queries and do the set intersection in memory.

0

If you make the Ref field in Post a @Parent field, you can do an ancestor() query on the Blog and get everything (ancestor() includes the parent entity). However, you will get literally everything in that entity group unless you filter by the type ie Post).

This kind of micro-optimization is almost certainly pointless. It won't save you any money and it is unlikely to save you any noticeable latency, especially if you @Cache the Blog.

-1

Of course you can! do this by adding the popularity field to Post. You'll have to update that value each day or week if the Blog's popularity changed.

This repetition of the information is typical and very common in noSql databases, don't think merise: think always: "the way to get all data ready for reading (in a minimal request count)", synchronizing data updates is very common in noSql dbs loke cassandra or datastore. Try reading some documentation on the subject

@adevine you cannot say No! if you don't know

1
  • I specifically state that the only way to do this is to copy the data you want to filter on onto the Post object. This is NOT a join and it is fundamentally different from what the question was asking.
    – adevine
    Jun 7, 2014 at 2:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.