Ask questions and see you at December, 7th, 8.PM. CET: https://vimeo.com/event/154379
Also checkout recent episode:
Please keep the questions Jakarta EE-stic. Means: as short and as concise as only possible. Feel free to ask several, shorter questions. Upcoming airhacks.tv events are also going to be announced at meetup.com/airhacks
How would you go about fulfilling dynamic entity projection requests from a REST client? Imagine a purchase order entity which has a lot of fields. Sometimes the client needs to read all and sometimes only a few but exactly which isn't known until runtime and is provided as query params. Also - there are associated entities (like order items). Sometimes the client wants to see them, sometimes not. Creating specific projection DTO's is therefore not an option. Need something similar to OData expand.
Using JSON-B adapters and serializers feels like a glorified DTO approach and the main pain point is there would need to be one for every class. JSON-P is good but it introduces coupling to a specific format (can't support XML then). At one point I implemented a simple object cloner running as the last step in the REST resource "GET" calls copying an entity instance to another instance of the same class but only picking and choosing the fields requested by the client and the rest was set to null (default JSONB skips nulls so this was kind of a hack). That seemed a little heavy handed though so I ended up writing a custom Message Body Writer and injecting @context UriInfo into it so that I can extract the list of fields & expand options requested by the client from the query params and perform the projection dynamically using reflection and some JPA metadata. That's probably not the best way to go about it - do you have any suggestions?