Simpler JPA with Spring Data-JPA
Join the DZone community and get the full member experience.
Join For FreeHow to configure your Spring application with Simple CRUD configuration with Spring Data-JPA.
1. Add Spring Data-JPA to project configuration. In your Maven pom.xml file
2. Configure JPA Entity
3. Configure Typed Repository Interface
Spring Data JPA will create the beans for us.
4. Configure the application context
Note: this example uses Hibernate and HSQL
5. Inject the Repository
In our service class & tests we use the repository to execute our crud methods. Repository Methods: count(), exists(), delete(), deleteAll(), findOne(), findAll(), save().
Summary
The Spring Data project abstracts away basic data management concepts. In addition to support for traditional relational methodologies, Spring Data provides support for NoSQL Graph, Key-Value and Map-Reduce types. As we saw in the above example configuring CRUD style applications is fairly trivial and Spring provides a convenient configuration for the typical cookie cutter code.
From http://gordondickens.com/wordpress/2011/08/01/simpler-jpa-with-spring-data-jpa/
Opinions expressed by DZone contributors are their own.
Comments