diff --git a/readme.md b/readme.md
index c7e6d0561..ce591dee7 100644
--- a/readme.md
+++ b/readme.md
@@ -18,7 +18,8 @@ This README as well as the [reference documentation](http://static.springsource.
The main project [website](http://www.springsource.org/spring-data) contains links to basic project information such as source code, JavaDocs, Issue tracking, etc.
-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).
+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). You should also have a look at our new Spring Guide
+[Accessing Data with JPA](https://spring.io/guides/gs/accessing-data-jpa/) that leverages the simplified configuration provided by [Spring Boot](http://projects.spring.io/spring-boot/).
## Quick Start ##
@@ -29,40 +30,45 @@ Download the jar though Maven:
org.springframework.data
spring-data-jpa
- 1.4.0.RELEASE
+ 1.4.1.RELEASE
```
Also include your JPA persistence provider of choice (Hibernate, EclipseLink, OpenJpa). Setup basic Spring JPA configuration as well as Spring Data JPA repository support.
-```xml
-
-
-
-
-
-
-
-
-
+The simple Spring Data JPA configuration with Java-Config looks like this:
+```java
+@Configuration
+@EnableJpaRepositories("com.acme.repositories")
+class AppConfig {
-
-
-
+ @Bean
+ public DataSource dataSource() {
+ return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.HSQL).build();
+ }
-
+ @Bean
+ public JpaTransactionManager transactionManager(EntityManagerFactory emf) {
+ return new JpaTransactionManager(emf);
+ }
-
-
+ @Bean
+ public JpaVendorAdapter jpaVendorAdapter() {
+ HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();
+ jpaVendorAdapter.setDatabase(Database.H2);
+ jpaVendorAdapter.setGenerateDdl(true);
+ return jpaVendorAdapter;
+ }
+
+ @Bean
+ public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
+ LocalContainerEntityManagerFactoryBean lemfb = new LocalContainerEntityManagerFactoryBean();
+ lemfb.setDataSource(dataSource());
+ lemfb.setJpaVendorAdapter(jpaVendorAdapter());
+ lemfb.setPackagesToScan("com.acme");
+ return lemfb;
+ }
+}
```
Create an entity:
@@ -72,12 +78,14 @@ Create an entity:
public class User {
@Id
- @GeneratedValue(strategy = GenerationType.AUTO)
+ @GeneratedValue
private Integer id;
private String firstname;
private String lastname;
// Getters and setters
+ // (Firstname, Lastname)-constructor and noargs-constructor
+ // equals / hashcode
}
```
@@ -93,7 +101,7 @@ Write a test client
```java
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration("classpath:your-config-file.xml")
+@ContextConfiguration(classes = AppConfig.class)
public class UserRepositoryIntegrationTest {
@Autowired UserRepository repository;
@@ -101,10 +109,10 @@ public class UserRepositoryIntegrationTest {
@Test
public void sampleTestCase() {
User dave = new User("Dave", "Matthews");
- repository.save(user);
+ dave = repository.save(user);
User carter = new User("Carter", "Beauford");
- repository.save(carter);
+ carter = repository.save(carter);
List result = repository.findByLastname("Matthews");
assertThat(result.size(), is(1));