asolfre / objectify-appengine

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

@OnSave is processed in the wrong order? #224

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have a class [C], which extends a base class [B]. Both have @OnSave() and 
both are processed when the entity is saved.

I don't know if there is a given order at all or if this is by chance or 
anybody has reflected about this before, but I would have expected the order to 
be:

1. Base class [B]
2. Class [C]

In my case, the order is vice versa.

Why do I expect this particular order? Because [C] inherits from and often 
@Override(s) [B]. I would have expected in objectify as well that I can set a 
value in [B].@OnSave and then "override" it in [C].@OnSave.

Am I right? Any thoughts?

Original issue reported on code.google.com by oliver.h...@gmail.com on 30 Oct 2014 at 6:58

GoogleCodeExporter commented 9 years ago
Hmmmm. It was deliberately decided that @OnLoad does superclass-first and 
@OnSave does subclass-first. The general thinking was that this is somewhat 
like start/stop methods. But maybe that thinking is wrong.

I just checked and JPA does superclass-first, so that's a good data point. I 
will reverse the order for @OnSave.

Original comment by lhori...@gmail.com on 18 Nov 2014 at 6:00

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 0e07671a08f4.

Original comment by lhori...@gmail.com on 18 Nov 2014 at 6:05

GoogleCodeExporter commented 9 years ago
It will be great to clearly state in documentation the ordering for  @OnLoad  
and @OnSave.

Thanks

Original comment by hus...@gmail.com on 27 Nov 2014 at 1:33

GoogleCodeExporter commented 9 years ago
The documentation does clearly state it. And as of v5.1.2, it's even accurate :)

Original comment by lhori...@gmail.com on 27 Nov 2014 at 7:08