14.1 Property Access
With Property Access you MUST have a setter and a getter.
With Property Access ONLY the getter and setter are intercepted. If you use the field in other methods then access to that field is not intercepted/managed (See the getFullName() method as an example).
14.2 Field Access
Field access in general is implemented via bytecode Enhancement (Also refered to as Weaving and Transformation).
...
Unlike property access field access does not require the getter or setter to even exist – they can be removed if you want.
Essentially with Field access you can write whatever code you like (within reason) and it will behave as expected (ORM interception occuring as and how you would expect).
14.2.2 Ebean – Field vs Property access
... With Ebean you get Field Access when you use Enhancement and you get Property Access when you use Subclassing.
> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/ZY75hnvMeVAJ.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to
> play-framewor...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.
--
Guillaume Bort
15.1 Why are these techniques needed?
All the Java ORM's that I am aware of need this to support “Lazy Loading” and that includes Ebean.
In addition to that Ebean (and some other ORMs) use these techniques to support “Dirty Checking” / “Optimistic Concurrency Checking”. That is, detecting when an entity bean has been modified (made dirty) and maintaining original values to support Optimistic Concurrency Checking.
I was wrong, Play already does bytecode enhancement of ebean classes (see PlayCommands.scala arund line 450). Now I just have to find out why the lazy loading doesn't work as expected.Timo
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/DmjFKJgJnkIJ.
Using getters access still work and solve the problem. But for me I
think it is better to fetch every needed data during the query, and to
avoid lazy loading during the template rendering.
We should probably update the documentation however.
> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/wPdpB6Hm_4QJ.
>
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to
> play-framewor...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.
--
Guillaume Bort
So to be clear, if you want to rely on magic and lazy loading it is
surely better to keep field privates and to use getter and setter to
access values.