Reputation: 499
I have had a look at the following question
What are the advantages of using Spring Data REST over Spring Data JPA?
It doesn't quite cater to my needs. My DB is on MYSQL, I chose Spring-Data-JPA implementation. What are all the added advantages that REST can give me which I wont find in simple Spring-Data-JPA? For example if tomorrow, I decide to implement a cache b/w my business and Database module, in which case would I have to write lesser code? Which would be easily configurable? Which would be more flexible and how?
Also, if I am using both REST and JPA in a new application, what design principles do I break?
I am looking forward to the answers from an architecture perspective. Thanks in advance.
Upvotes: 24
Views: 17422
Reputation: 69
look for hibernate framework for easily manage Java application to interact with the database https://www.javatpoint.com/hibernate-tutorial
Upvotes: 0
Reputation: 12184
Basically I think your question is not completely to the point. I think you have not completely found your way through the spring project jungle - so I try to give a little orientation here.
Spring-data-jpa is the spring way to access data using JPA. You could use spring-data-rest on top of spring-data-jpa to create a REST-API layer with no code on top of your repositories and entities.
And what spring-data-rest can do for you is just amazing. It is the fastest way to create a REST API on top of your JPA layer. And it is also highly customizable. But I think it has it's limits. The most significant weakness is the tight coupling between entities and API. Usually you would like to have a little decoupling between these layers. But it is a great piece of software. If you need to be fast and want to write the minimal amount of code go for spring data rest.
A spring alternative to spring-data-rest is using spring MVC directly to create a REST API on your own. Spring-data-jpa would still be used to implement the data access layer. Spring MVC is very powerful and is used by spring-data-rest under the hood. This gives you full control of the REST layer.
I also want to mention spring HATEOAS - it is just a module on top of spring mvc and it gives you the tools to create a hypermedia driven REST API - so you can go for a maturity level 3 of the Richardson Maturity Model - it is also used by spring-data-rest internally.
Upvotes: 73