google-code-export / objectify-appengine

Automatically exported from code.google.com/p/objectify-appengine
MIT License
1 stars 0 forks source link

Implement "unactivated entities" as a surrogate for Key<?> #41

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Similar to Twig, allow relationship references to be defined as entity classes 
instead of Keys:

{{{
class SomeEntity {
   @Id long id;
   OtherEntity other;
}
}}}

The OtherEntity instance will contain only the Key information (id and parent) 
- there will be no separate fetch and thus the body of the entity will not be 
loaded from the database.

In order to populate this entity, a method will be added to Objectify:

Objectify.refresh(Object... entities)

Alternatively, the get() methods could be extended to take Object.

Beware, there are hazards to doing this - you now can have entity objects in 
your code which are uninitialized.

Automatic activation as per twig (or JDO) is not being considered at this time. 
 Too much magic with strong performance implications.

Original issue reported on code.google.com by lhori...@gmail.com on 15 Jun 2010 at 4:50

GoogleCodeExporter commented 9 years ago
and if the uninitialized entity is touched, something as LazyInitException 
could be raised.

Original comment by paulo.silveira on 19 Jul 2010 at 8:06

GoogleCodeExporter commented 9 years ago
Unfortunately it isn't possible for Objectify to detect uninitialized entity 
access without bytecode manipulation or some other post-processing of your 
entity classes.  The proxies would then present serialization problems and a 
whole host of other issues that drag you down the path of JDO.

It's not something we're likely to consider.

However, you can in your own entity code build your own uninitialized entity 
access detection.  Unfortunately it's laborious and invasive.

Original comment by lhori...@gmail.com on 19 Jul 2010 at 8:34

GoogleCodeExporter commented 9 years ago
Implemented in Objectify4

Original comment by lhori...@gmail.com on 16 Dec 2011 at 2:25