Search code examples
projectionspring-data-rest

Spring data rest: projection


is there any way to "inline" (not embed) an entity into a projection without manually copying the getters and keeping em manually in sync?

Example:

Entity
 f1
 f2
 f3

Projection
 @Inline(Entity.class)

becomes:

Projection
 getF1()
 getF2()
 getF3()

The only way I see is to implement the Projection in the Entity but this does not match very well with my usage of Lombok and it no longer works if the Projection has additional fields which the enitiy has not (It would require an additional interface).

Any ideas?


Solution

  • Not really sure what you are trying to achieve by this - projections are there for providing different view on data - so they will in many cases not totally match your entity structure. If you are worried about the code duplication you can have a common interface that both your entity and the projection extend/implement.