1

I have an excerpt defined on a Repo like this:

@RepositoryRestResource(excerptProjection = ListAccountProjection.class)
public interface IAccountRepository extends IRepository<Account> {

When I exec GET /accounts it works like expected.

I have another Projection ShortAccountProjection.

When I exec GET /accounts?projection=short it is simply ignored. So the projection param will never override the exerpt projection from the repo?

When I remove the excerpt from the repo, the projection "sort" works as expected.

Ickbinet
  • 277
  • 3
  • 12

1 Answers1

2

If you define an excerpt projection, it is always applied when the collection resource is accessed (/accounts in your case), or the resources is added as _embedded within another resource.

Your ShortAccountProjection will apply only for item resources (e.g. GET /accounts/{id}?projection=short).

Eventually, take a look at Why is an excerpt projection not applied automatically for a Spring Data REST item resource?

Community
  • 1
  • 1
David Siro
  • 1,826
  • 14
  • 33
  • 1
    OK, this is how it works, but not why it works this way. The excerpt is a kind of preview. But when I explicitly request another projection, it should IMHO respect this. I cannot see why it should not... – Ickbinet Jan 03 '16 at 21:31
  • I agree with you, can't see a reason why it shouldn't work as you described. Maybe an idea for future release of SDR? – David Siro Jan 05 '16 at 10:32