I am using Spring Data REST 2.1.4.RELEASE.
I created
Booking object- its REST repository (
CrudRepository extension) named BookingRepository - and the
BookingDetails projection (annotated using @Projection(name="details", types = Booking.class) ) to return some objects associated with it, such as Resource , Activity , Applicant , etc.
The client receives all orders with .../rest/bookings , and the JSON response includes links for related objects. If he adds ?projection=details , then related objects will be blown up and returned. And that's great.
Now I am adding this custom method to the repository:
List<Booking> findByApplicant(@Param("applicant") Person applicant);
When a client calls it with .../rest/bookings/search/findByApplicant?applicant=5 , there seems to be no way to request details projection. The following attempts are ignored:
To summarize, custom search methods ( findBy* ) never return a projection . If you do not annotate the repository using @RepositoryRestResource(excerptProjection = BookingDetails.class) , but this leads to some problems, the client should always use the same projection first. How can we allow the user to use forecasts also with findBy* methods?
java spring rest spring-data-rest projection
bluish
source share