views:

11

answers:

1

Hi,

In the python app engine docs, I see something called dbReferenceProperty. I can't understand what it is, or how it's used. I'm using the java interface to app engine, so I'm not sure if there's an equivalent.

I'm interested in it because it sounds like some sort of pseudo-join, where we can point a property of a class to some other object's value - something like if we had:

class User {
    private String mPhotoUrl;
    private String mPhone;
    private String mState;
    private String mCountry;
    .. etc ..
}

class UserLite {
    @ReferenceProperty User.mPhotoUrl;
    private String mPhotoUrl;
}

then if we had to update a User object's mPhotoUrl value, the change would somehow propagate out to all UserLite instances referencing it, rather than having to update every UserLite object instance manually,

Thanks

+2  A: 

A db.ReferenceProperty simply holds the key of another datastore entity, which is automatically fetched from the datastore when the property is used.

There's some additional magic where the entity that is referenced has access to a query for entities of type Foo that reference it in the special attribute foo_set.

The Java datastore API instead has owned relationships, which serve the same purpose.

Wooble
Ah ok gotcha makes sense, thanks!