Spring Data REST — Concept Check
Questions on Spring Data REST. Exports repository operations as hypermedia-driven REST endpoints automatically, following HATEOAS principles with HAL or HAL-FORMS media types.
Questions in this quiz
8 questions on Spring Data REST — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A developer wants to expose a Spring Data repository as REST endpoints. What is the minimal requirement to achieve this?
- AAdd @RestController annotation
- BImplement a custom controller
- CConfigure a base path in application.properties
- DExtend a Spring Data repository interface
2.What happens if you append ?projection=summary to a Spring Data REST endpoint URL?
- AIt returns a view with selected fields of the entity
- BIt returns the full entity without any changes
- CIt filters the results based on the summary field
- DIt sorts the results by the summary field
3.A client sends a GET request to /products/1?projection=summary. What will the response include?
- AThe product's name, price, and category name
- BOnly the product's category name
- COnly the name and price of the product
- DThe entire product entity
4.A developer uses @RepositoryRestResource with exported=false. What is the effect?
- AThe repository is exposed only for read operations
- BThe repository is exposed with default settings
- CThe repository is not exposed as REST endpoints
- DThe repository is exposed but with limited operations
5.A developer changes the base path using spring.data.rest.base-path. What is the impact?
- AThe change affects only GET operations
- BAll REST endpoints are exposed under the new base path
- COnly new endpoints use the new base path
- DIt has no effect on the existing endpoints
6.During a code review, a developer notices @HandleBeforeCreate in a handler class. What does this indicate?
- AA method will execute after an entity is deleted
- BA method will execute before an entity is deleted
- CA method will execute after an entity is created
- DA method will execute before a new entity is created
7.A developer believes that Spring Data REST requires explicit controllers for all operations. Why is this incorrect?
- AControllers are needed for read operations only
- BControllers are only needed for custom logic
- CExplicit controllers are required for all operations
- DSpring Data REST automatically exposes CRUD operations as REST endpoints
8.What is the purpose of @RepositoryEventHandler in Spring Data REST?
- ATo intercept lifecycle events for auditing or validation
- BTo handle HTTP requests directly
- CTo define custom REST endpoints
- DTo manage database transactions