Here is a comment from Andrea Bollini (4Science) on optional properties:
my idea is to have all the objects ready to hold as much information as possible. This mean that the parent object should be an attribute of our REST objects. We need to define a way to allow lazy loading in a similar way that the Hibernate framework does with the persistent entities.
We should use annotation to provide to our framework enough information to lazy load the relation when required. This could in turn rely on hibernate lazy-loading capabilities or trough direct invocation of dedicated retrieve methods.
Request should express interest for optional information specifying a "projection". Both the converter and the repository should be aware of the projection so to
- lazy load the required information (converter responsibility)
- optimize the retrieve of the information avoiding lazy load as much as possible
Projection should be defined as
- additional information to include
- information to hide
where the "base set" for each rest entity is defined. We could introduce an "optional" annotation to define which information are not part of the "base set".