To make the requirement clear,
the relation should change to an existing B.
And there will be some queries on A which using B as the criteria.
For example, the JPAQL would be,
"select a from " + A.class.getName() + " as a where a.bKey = :bKey"

So I think the second solution won't fit.

For the first solution, I think the above query should change to,
"select a from " + A.class.getName() + " as a where
a.currentB_Key.contains(:currentB_Key)"
Since there will be a list of Current B pointing to a single real B
after some relation changes.

According to the GAE/J document, contains() can be only split into 30
sub-queries at most.
For a long running system, there can be more than 30 currentB pointing
to a single real B.

What should I do to get rid of this situation?

Thanks for your patient!

On 1月20日, 下午4時51分, John Patterson <jdpatter...@gmail.com> wrote:
> Actually, another option is just to overwrite B so the key stays the  
> same but the data in it changes.
>
> On 20 Jan 2010, at 15:31, Alan She wrote:
>
>
>
> > Thanks! This really a smart way for relations that often changes.
> > But I wonder if this is the only way?
>
> > What if the relation seldom change?
> > I believe the cost of the indirection will be shown on
> > the complexity of code and the runtime performance,
> > if using the "resolution" Entity everywhere.
>
> > On 1月20日, 下午3時37分, John Patterson <jdpatter...@gmail.com>  
> > wrote:
> >> If you are going to change the relation often you might want to  
> >> have a
> >> "resolution" Entity in the middle - lets say CurrentB.
>
> >> A->CurrentB->B
>
> >> instead of updating every A just update the single CurrentB
>
> >> On 20 Jan 2010, at 14:05, Alan She wrote:
>
> >>> Assume I have two class A and B,
> >>> which is unidirection unowned many to one relationship. (A * ----> 1
> >>> B)
> >>> I store the Key of class B inside class A.
> >>> The code looks like this, (I am using JPA)
>
> >>> @Entity
> >>> public class A {
>
> >>>   �...@enumerated
> >>>    private Key bKey;
> >>> }
>
> >>> @Entity
> >>> public class B {
> >>> }
>
> >>> Both A and B instance of the same user are under the same entity
> >>> group.
>
> >>> When I need to delete B, lets say 'Bx'
> >>> any A that associate with 'Bx' is going to change the association to
> >>> 'By'.
>
> >>> I can do this by query and iterate update with low level API.
> >>> However, there might be a huge amount of A,
> >>> This will exceed the request time limit.
>
> >>> What's the best solution to solve this problem?
> >>> 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-java@googlegroups.com
> >>> .
> >>> To unsubscribe from this group, send email to 
> >>> google-appengine-java+unsubscr...@googlegroups.com
> >>> .
> >>> For more options, visit this group 
> >>> athttp://groups.google.com/group/google-appengine-java?hl=en
> >>> .
> > --
> > 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-java@googlegroups.com
> > .
> > To unsubscribe from this group, send email to 
> > google-appengine-java+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group 
> > athttp://groups.google.com/group/google-appengine-java?hl=en
> > .
-- 
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.


Reply via email to