Sorry, let me write it down with keys just to make sure we are on the same
page:
Article {
HashSet<Key> reviews; // Keys of reviews
HashSet<String> tags;
int status; // derived from all Reviews' statuses.
}
Review {
Key article;
Key reviewer;
int status;
}
Reviewer {
String email;
}
Now, do you suggest that I make Article embedded in Review? One article may
have many reviews, that would mean the same article is embedded in all of
them? Will that work fine? I just saw a lot of redundancy here, but if thats
the best way, thats the best way!
Thanks!
On Thu, Aug 27, 2009 at 1:03 PM, Sam Walker <[email protected]> wrote:
> Yes, it is a key. I just wanted to make it obvious which Keys are involved.
> I read the Embedded class as well, its not what I want here I think.
>
> How would you model this scenario then? Both models I discussed in my
> original post have issues.
>
>
> On Thu, Aug 27, 2009 at 11:22 AM, Jason (Google) <[email protected]>wrote:
>
>> JDO supports syntax like article.status but App Engine's datastore doesn't
>> support joins so you'll have to make article an embedded object in order to
>> use the query as you have it below:
>>
>> http://code.google.com/appengine/docs/java/datastore/dataclasses.html#Embedded_Classes
>>
>> Also, how have you defined reviewerParam? Is it a Key object or are you
>> actually passing in the Reviewer object? The latter won't work, but I'll
>> follow up about the former (querying on a Key).
>>
>> - Jason
>>
>>
>> On Sun, Aug 23, 2009 at 11:18 PM, Sam Walker <[email protected]>wrote:
>>
>>> Also, I get this error: *Can only filter by properties of a sub-object
>>> if the sub-object is embedded.* when I tried to access article while
>>> setting a fitler: query.setFilter("reviewer == reviewerParam &&
>>> article.status = articleStatusParam");
>>>
>>> What am I missing?
>>>
>>>
>>> On Sat, Aug 22, 2009 at 6:02 PM, Sam Walker <[email protected]>wrote:
>>>
>>>> In the second model, how will I find all Articles being reviewed by A
>>>> and B?
>>>>
>>>> The only way I can think of is adding another derived field in Article:
>>>>
>>>> Article {
>>>> HashSet<Review> reviews;
>>>> HashSet<Reviewer> reviewers; // keys of Reviewers to help the query
>>>> "find all articles reviewed by A and B"
>>>> HashSet<String> tags;
>>>> int status; // derived from all Reviews' statuses.
>>>> }
>>>>
>>>> Review {
>>>> Article article;
>>>> Reviewer reviewer;
>>>> int status;
>>>> }
>>>>
>>>> Now I should be able to do "reviewers.contains(A.key) and
>>>> reviewers.contains(B.key)". Is that the best way?
>>>>
>>>>
>>>> On Sat, Aug 22, 2009 at 2:02 PM, Sam Walker <[email protected]>wrote:
>>>>
>>>>> Oh sweet, I didn't know that.
>>>>>
>>>>> That's awesome! Thanks for the quick reply.
>>>>>
>>>>>
>>>>> On Sat, Aug 22, 2009 at 1:51 PM, datanucleus <[email protected]
>>>>> > wrote:
>>>>>
>>>>>>
>>>>>> > I dont think I can do sth like (I can't access article.tags,
>>>>>> article.status
>>>>>> > as far as I know, correct?):
>>>>>>
>>>>>> Of course you can. JDO spec defines JDOQL, using Java syntax.
>>>>>>
>>>>>> > query.setFilter("reviewer == reviewerParam && status == statusParam
>>>>>> &&
>>>>>> > article.tags == tagParam && article.status = articleStatusParam");
>>>>>>
>>>>>> What is "tagParam" ? an element of the hashSet?
>>>>>> You can't do "Collection == element" in Java so you can't in JDOQL.
>>>>>> You could do "article.tags.contains(tagParam)"
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>>
>>>
>>
>> >>
>>
>
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---