Is there a way to do a Ref get with @Load in a query if you only have an ID for a property?

17 views
Skip to first unread message

Tony Park

unread,
May 1, 2024, 11:19:21 PMMay 1
to objectify-appengine
Is there a way to do a Ref get with @Load in a query if you only have an ID for a property?

Normally a Ref would look like this:

@Entity
class Car {
    @Id Long id;
    @Load Ref<Person> driver; 
}

But what if you had this:

@Entity
class Car {
    @Id Long id;
    Long driverId; // You know this is a Person entity
}

Storing Keys as a property in an entity is useful when using Ref with @Load but Keys are at least 4x larger than a simple long ID. 

A long is 8 bytes but a key (depending on the entity name) is 16 bytes + 8 bytes for long id + string length of entity name (e.g. 8 bytes) = 32 bytes. 

If there is a way to @Load entities without storing keys, it would save a bit of space.

Jeff Schnitzer

unread,
May 4, 2024, 1:29:55 AMMay 4
to objectify...@googlegroups.com
Ooof, that's a tough one. I'm afraid there isn't. It would require pretty significant work ofy's internals. That @Load stuff is the most complicated part, especially because Objectify preserves the facade of async behavior (that's no longer async because the google libraries no longer support async).

Jeff

--
You received this message because you are subscribed to the Google Groups "objectify-appengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to objectify-appen...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/objectify-appengine/4ac55f59-0292-4ff4-9dc2-4424129060ddn%40googlegroups.com.

Tony Park

unread,
May 12, 2024, 6:01:27 PMMay 12
to objectify-appengine
I see, I figured it may be a bit involved. Thanks.
Reply all
Reply to author
Forward
0 new messages