2

When I started to use spring boot I was annotating my interface with @Repositoryall these days I was following the same, but today I happened to come across annotating with another way called @RepositoryRestResource. What is the difference between them, When is it used.

3 Answers 3

3

@RepositoryRestResource means you have REST endpoint to the repository. So user calls it directly via REST calls.

@Repository is a marker to a component which somehow stores data (CRUD operations). It is not necessary be accessible from external users directly.

So in case of @RepositoryRestResource you don't have any controller/service/dao layers but direct access.

Sign up to request clarification or add additional context in comments.

Comments

0

In addition to answer mentioned above, you can also customize your REST endpoints using @RepositoryRestResource.

1 Comment

Your answer will be much more usefull in case you'll add some links to information you mentioned.
0

The @Repository annotation enables exception translation so you can handle Springs DataAccessException instead of underlying persistence implementation exceptions (via PersistenceExceptionTranslationPostProcessor). @RepositoryRestResource is not a specialization of @Repository so you might want in include both, to expose REST endpoints and enable exception translation.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.