From fe50153747788f22307319ea27c80fe6dea47158 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Thu, 21 Jul 2011 10:16:41 +0200 Subject: [PATCH] Polished readme.md. --- readme.md | 141 ++++++++++++++++++++++++++---------------------------- 1 file changed, 69 insertions(+), 72 deletions(-) diff --git a/readme.md b/readme.md index 0fe71025a..f527f1147 100644 --- a/readme.md +++ b/readme.md @@ -1,10 +1,8 @@ -Spring Data JPA -======================= +# Spring Data JPA # The primary goal of the [Spring Data](http://www.springsource.org/spring-data) project is to make it easier to build Spring-powered applications that use data access technologies. This module deals with enhanced support for JPA based data access layers. -Features --------- +## Features ## * Implementation of CRUD methods for JPA Entities * Dynamic query generation from query method names @@ -14,8 +12,7 @@ Features * Possibility to integrate custom repository code * Easy Spring integration with custom namespace -Getting Help ------------- +## Getting Help ## This README as well as the [reference documentation](http://static.springsource.org/spring-data/data-jpa/snapshot-site/reference/html) are the best places to start learning about Spring Data JPA. There are also [two sample applications](https://github.com/SpringSource/spring-data-jpa-examples) available to look at. @@ -24,98 +21,98 @@ The main project [website](http://www.springsource.org/spring-data) contains lin For more detailed questions, use the [forum](http://forum.springsource.org/forumdisplay.php?f=27). If you are new to Spring as well as to Spring Data, look for information about [Spring projects](http://www.springsource.org/projects). -# Quick Start +## Quick Start ## Download the jar though Maven: - - org.springframework.data - spring-data-jpa - 1.0.0.BUILD-SNAPSHOT - + + org.springframework.data + spring-data-jpa + 1.0.0.BUILD-SNAPSHOT + - - spring-maven-snapshot - - true - - Springframework Maven SNAPSHOT Repository - http://maven.springframework.org/snapshot - + + spring-maven-snapshot + + true + + Springframework Maven SNAPSHOT Repository + http://maven.springframework.org/snapshot + Also include your JPA persistence provider of choice (Hibernate, EclipseLink, OpenJpa). Setup basic Spring JPA configuration as well as Spring Data JPA repository support. - - + + - - - - - - + + + + + + - - - + + + - + - - + + Create an entity: - - @Entity - public class User { + @Entity + public class User { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Integer id; - private String firstname; - private String lastname; + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Integer id; + private String firstname; + private String lastname; - // Getters and setters - } + // Getters and setters + } -Create a repository interface in com.acme.repositories: +Create a repository interface in `com.acme.repositories`: - public interface UserRepository extends JpaRepository { - List findByLastname(String lastname); - } + public interface UserRepository extends CrudRepository { + List findByLastname(String lastname); + } Write a test client - @RunWith(SpringJUnit4TestRunner.class) - @ContextConfiguration("classpath:your-config-file.xml") - public class UserRepositoryIntegrationTest { + @RunWith(SpringJUnit4TestRunner.class) + @ContextConfiguration("classpath:your-config-file.xml") + public class UserRepositoryIntegrationTest { - @Autowrired UserRepository repository; + @Autowrired UserRepository repository; - @Test - public void sampleTestCase() { - User dave = new User("Dave", "Matthews"); - repository.save(user); + @Test + public void sampleTestCase() { + User dave = new User("Dave", "Matthews"); + repository.save(user); - User carter = new User("Carter", "Beauford"); - repository.save(carter); + User carter = new User("Carter", "Beauford"); + repository.save(carter); - List result = repository.findByLastname("Matthews"); - assertThat(result.size(), is(1)); - assertThat(result, hasItem(dave)); - } - } + List result = repository.findByLastname("Matthews"); + assertThat(result.size(), is(1)); + assertThat(result, hasItem(dave)); + } + } - -Contributing to Spring Data ---------------------------- +## Contributing to Spring Data ## Here are some ways for you to get involved in the community: