diff --git a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/auditing/AuditableUser.java b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/auditing/AuditableUser.java similarity index 92% rename from jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/auditing/AuditableUser.java rename to jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/auditing/AuditableUser.java index 4884c91d..d5461356 100644 --- a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/auditing/AuditableUser.java +++ b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/auditing/AuditableUser.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.example.repository.auditing; +package example.springdata.jpa.auditing; import javax.persistence.Entity; diff --git a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/auditing/AuditableUserRepository.java b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/auditing/AuditableUserRepository.java similarity index 86% rename from jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/auditing/AuditableUserRepository.java rename to jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/auditing/AuditableUserRepository.java index c3984527..1c4e3220 100644 --- a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/auditing/AuditableUserRepository.java +++ b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/auditing/AuditableUserRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.example.repository.auditing; +package example.springdata.jpa.auditing; import org.springframework.data.repository.CrudRepository; diff --git a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/auditing/AuditingConfiguration.java b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/auditing/AuditingConfiguration.java similarity index 93% rename from jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/auditing/AuditingConfiguration.java rename to jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/auditing/AuditingConfiguration.java index 0fd712ab..485db0a0 100644 --- a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/auditing/AuditingConfiguration.java +++ b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/auditing/AuditingConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.example.repository.auditing; +package example.springdata.jpa.auditing; import javax.sql.DataSource; @@ -39,7 +39,7 @@ class AuditingConfiguration { /** * We need to configure a {@link LocalContainerEntityManagerFactoryBean} manually here as Spring does not * automatically add the {@code orm.xml} if a {@code persistence.xml} is located right beside it. This is - * necessary to get the {@link org.springframework.data.jpa.example.repository.basics.BasicFactorySetup} sample + * necessary to get the {@link example.springdata.jpa.basics.BasicFactorySetup} sample * working. However, in a {code persistence.xml}-less codebase you can rely on Spring Boot on setting the correct * defaults. * diff --git a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/auditing/AuditorAwareImpl.java b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/auditing/AuditorAwareImpl.java similarity index 92% rename from jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/auditing/AuditorAwareImpl.java rename to jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/auditing/AuditorAwareImpl.java index 2ee7fd6b..e5f67522 100644 --- a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/auditing/AuditorAwareImpl.java +++ b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/auditing/AuditorAwareImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.example.repository.auditing; +package example.springdata.jpa.auditing; import org.springframework.data.domain.AuditorAware; diff --git a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/auditing/package-info.java b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/auditing/package-info.java similarity index 53% rename from jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/auditing/package-info.java rename to jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/auditing/package-info.java index b0467812..685a8ac2 100644 --- a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/auditing/package-info.java +++ b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/auditing/package-info.java @@ -1,4 +1,4 @@ /** * Package showing auditing support with Spring Data repositories. */ -package org.springframework.data.jpa.example.repository.auditing; \ No newline at end of file +package example.springdata.jpa.auditing; \ No newline at end of file diff --git a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/caching/CachingConfiguration.java b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/caching/CachingConfiguration.java similarity index 96% rename from jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/caching/CachingConfiguration.java rename to jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/caching/CachingConfiguration.java index 98806c27..7992c7cc 100644 --- a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/caching/CachingConfiguration.java +++ b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/caching/CachingConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.example.repository.caching; +package example.springdata.jpa.caching; import java.util.Arrays; diff --git a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/caching/CachingUserRepository.java b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/caching/CachingUserRepository.java similarity index 94% rename from jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/caching/CachingUserRepository.java rename to jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/caching/CachingUserRepository.java index ed82aa23..35e252b9 100644 --- a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/caching/CachingUserRepository.java +++ b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/caching/CachingUserRepository.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.example.repository.caching; +package example.springdata.jpa.caching; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; diff --git a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/simple/User.java b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/caching/User.java similarity index 94% rename from jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/simple/User.java rename to jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/caching/User.java index ef7955e1..75482a1a 100644 --- a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/simple/User.java +++ b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/caching/User.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.example.repository.simple; +package example.springdata.jpa.caching; import javax.persistence.Column; import javax.persistence.Entity; diff --git a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/caching/package-info.java b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/caching/package-info.java similarity index 61% rename from jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/caching/package-info.java rename to jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/caching/package-info.java index a5ea9748..e6b0e7a8 100644 --- a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/caching/package-info.java +++ b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/caching/package-info.java @@ -1,5 +1,5 @@ /** * Sample for the integration of the Spring caching abstraction with Spring Data repositories. */ -package org.springframework.data.jpa.example.repository.caching; +package example.springdata.jpa.caching; diff --git a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/custom/CustomRepositoryConfig.java b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/custom/CustomRepositoryConfig.java similarity index 94% rename from jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/custom/CustomRepositoryConfig.java rename to jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/custom/CustomRepositoryConfig.java index 63796393..38e90bdb 100644 --- a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/custom/CustomRepositoryConfig.java +++ b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/custom/CustomRepositoryConfig.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.example.repository.custom; +package example.springdata.jpa.custom; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.Configuration; diff --git a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/custom/User.java b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/custom/User.java similarity index 94% rename from jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/custom/User.java rename to jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/custom/User.java index 7ef5f61b..6f6fd3f2 100644 --- a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/custom/User.java +++ b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/custom/User.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.example.repository.custom; +package example.springdata.jpa.custom; import javax.persistence.Column; import javax.persistence.Entity; diff --git a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/custom/UserRepository.java b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/custom/UserRepository.java similarity index 96% rename from jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/custom/UserRepository.java rename to jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/custom/UserRepository.java index e6e0d7ae..7f39e6aa 100644 --- a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/custom/UserRepository.java +++ b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/custom/UserRepository.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.example.repository.custom; +package example.springdata.jpa.custom; import java.util.List; diff --git a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/custom/UserRepositoryCustom.java b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/custom/UserRepositoryCustom.java similarity index 93% rename from jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/custom/UserRepositoryCustom.java rename to jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/custom/UserRepositoryCustom.java index 6ff76e7b..0d09a53b 100644 --- a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/custom/UserRepositoryCustom.java +++ b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/custom/UserRepositoryCustom.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.example.repository.custom; +package example.springdata.jpa.custom; import java.util.List; diff --git a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/custom/UserRepositoryImpl.java b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/custom/UserRepositoryImpl.java similarity index 93% rename from jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/custom/UserRepositoryImpl.java rename to jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/custom/UserRepositoryImpl.java index dd75b817..4655fa5d 100644 --- a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/custom/UserRepositoryImpl.java +++ b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/custom/UserRepositoryImpl.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.example.repository.custom; +package example.springdata.jpa.custom; import java.util.List; @@ -62,7 +62,7 @@ class UserRepositoryImpl implements UserRepositoryCustom { /* * (non-Javadoc) - * @see org.springframework.data.jpa.example.repository.UserRepositoryCustom#myCustomBatchOperation() + * @see example.springdata.jpa.UserRepositoryCustom#myCustomBatchOperation() */ public List myCustomBatchOperation() { diff --git a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/custom/UserRepositoryImplJdbc.java b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/custom/UserRepositoryImplJdbc.java similarity index 94% rename from jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/custom/UserRepositoryImplJdbc.java rename to jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/custom/UserRepositoryImplJdbc.java index 750d09f7..381f1f31 100644 --- a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/custom/UserRepositoryImplJdbc.java +++ b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/custom/UserRepositoryImplJdbc.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.example.repository.custom; +package example.springdata.jpa.custom; import java.sql.ResultSet; import java.sql.SQLException; @@ -61,7 +61,7 @@ class UserRepositoryImplJdbc extends JdbcDaoSupport implements UserRepositoryCus /* * (non-Javadoc) - * @see org.springframework.data.jpa.example.repository.UserRepositoryCustom#myCustomBatchOperation() + * @see example.springdata.jpa.UserRepositoryCustom#myCustomBatchOperation() */ public List myCustomBatchOperation() { return getJdbcTemplate().query(COMPLICATED_SQL, new UserRowMapper()); diff --git a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/custom/package-info.java b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/custom/package-info.java similarity index 71% rename from jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/custom/package-info.java rename to jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/custom/package-info.java index 2218bc34..9a2f7d5e 100644 --- a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/custom/package-info.java +++ b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/custom/package-info.java @@ -1,5 +1,5 @@ /** * Package showing a repository interface to use basic query method execution functionality as well as customized repository functionality. */ -package org.springframework.data.jpa.example.repository.custom; +package example.springdata.jpa.custom; diff --git a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/simple/SimpleConfiguration.java b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/simple/SimpleConfiguration.java similarity index 93% rename from jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/simple/SimpleConfiguration.java rename to jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/simple/SimpleConfiguration.java index 531bb664..67dbb341 100644 --- a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/simple/SimpleConfiguration.java +++ b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/simple/SimpleConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.example.repository.simple; +package example.springdata.jpa.simple; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.Configuration; diff --git a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/simple/SimpleUserRepository.java b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/simple/SimpleUserRepository.java similarity index 97% rename from jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/simple/SimpleUserRepository.java rename to jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/simple/SimpleUserRepository.java index a01dbff3..952286eb 100644 --- a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/simple/SimpleUserRepository.java +++ b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/simple/SimpleUserRepository.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.example.repository.simple; +package example.springdata.jpa.simple; import java.util.List; diff --git a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/caching/User.java b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/simple/User.java similarity index 94% rename from jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/caching/User.java rename to jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/simple/User.java index da23c5fd..5cd395f6 100644 --- a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/caching/User.java +++ b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/simple/User.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.example.repository.caching; +package example.springdata.jpa.simple; import javax.persistence.Column; import javax.persistence.Entity; diff --git a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/simple/package-info.java b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/simple/package-info.java similarity index 63% rename from jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/simple/package-info.java rename to jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/simple/package-info.java index 338e0e5a..a1c3e319 100644 --- a/jpa/spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/simple/package-info.java +++ b/jpa/spring-data-jpa-example/src/main/java/example/springdata/jpa/simple/package-info.java @@ -1,5 +1,5 @@ /** * Package showing a simple repository interface to use basic query method execution functionality. */ -package org.springframework.data.jpa.example.repository.simple; +package example.springdata.jpa.simple; diff --git a/jpa/spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/auditing/AuditableUserSample.java b/jpa/spring-data-jpa-example/src/test/java/example/springdata/jpa/auditing/AuditableUserSample.java similarity index 87% rename from jpa/spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/auditing/AuditableUserSample.java rename to jpa/spring-data-jpa-example/src/test/java/example/springdata/jpa/auditing/AuditableUserSample.java index bec34f10..c9eea143 100644 --- a/jpa/spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/auditing/AuditableUserSample.java +++ b/jpa/spring-data-jpa-example/src/test/java/example/springdata/jpa/auditing/AuditableUserSample.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.example.repository.auditing; +package example.springdata.jpa.auditing; import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; @@ -27,6 +27,11 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.util.ReflectionTestUtils; import org.springframework.transaction.annotation.Transactional; +import example.springdata.jpa.auditing.AuditableUser; +import example.springdata.jpa.auditing.AuditableUserRepository; +import example.springdata.jpa.auditing.AuditingConfiguration; +import example.springdata.jpa.auditing.AuditorAwareImpl; + /** * @author Oliver Gierke * @author Thomas Darimont diff --git a/jpa/spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/basics/BasicFactorySetup.java b/jpa/spring-data-jpa-example/src/test/java/example/springdata/jpa/basics/BasicFactorySetup.java similarity index 90% rename from jpa/spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/basics/BasicFactorySetup.java rename to jpa/spring-data-jpa-example/src/test/java/example/springdata/jpa/basics/BasicFactorySetup.java index fab9f93a..d1f8269b 100644 --- a/jpa/spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/basics/BasicFactorySetup.java +++ b/jpa/spring-data-jpa-example/src/test/java/example/springdata/jpa/basics/BasicFactorySetup.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.example.repository.basics; +package example.springdata.jpa.basics; import static org.junit.Assert.*; @@ -24,10 +24,11 @@ import javax.persistence.Persistence; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.springframework.data.jpa.example.repository.simple.SimpleUserRepository; -import org.springframework.data.jpa.example.repository.simple.User; import org.springframework.data.jpa.repository.support.JpaRepositoryFactory; +import example.springdata.jpa.simple.SimpleUserRepository; +import example.springdata.jpa.simple.User; + /** * Test case showing how to use the basic {@link GenericDaoFactory} * diff --git a/jpa/spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/basics/BasicSample.java b/jpa/spring-data-jpa-example/src/test/java/example/springdata/jpa/basics/BasicSample.java similarity index 93% rename from jpa/spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/basics/BasicSample.java rename to jpa/spring-data-jpa-example/src/test/java/example/springdata/jpa/basics/BasicSample.java index 74d7454f..dc7d62de 100644 --- a/jpa/spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/basics/BasicSample.java +++ b/jpa/spring-data-jpa-example/src/test/java/example/springdata/jpa/basics/BasicSample.java @@ -17,7 +17,7 @@ ess or implied. * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.example.repository.basics; +package example.springdata.jpa.basics; import static org.junit.Assert.*; @@ -28,10 +28,11 @@ import javax.persistence.Persistence; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.springframework.data.jpa.example.repository.simple.User; import org.springframework.data.jpa.repository.support.SimpleJpaRepository; import org.springframework.data.repository.CrudRepository; +import example.springdata.jpa.simple.User; + /** * This unit tests shows plain usage of {@link SimpleJpaRepository}. * diff --git a/jpa/spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/basics/package-info.java b/jpa/spring-data-jpa-example/src/test/java/example/springdata/jpa/basics/package-info.java similarity index 91% rename from jpa/spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/basics/package-info.java rename to jpa/spring-data-jpa-example/src/test/java/example/springdata/jpa/basics/package-info.java index e3b82d7c..44b9b873 100644 --- a/jpa/spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/basics/package-info.java +++ b/jpa/spring-data-jpa-example/src/test/java/example/springdata/jpa/basics/package-info.java @@ -17,4 +17,4 @@ * * @author Thomas Darimont */ -package org.springframework.data.jpa.example.repository.basics; \ No newline at end of file +package example.springdata.jpa.basics; \ No newline at end of file diff --git a/jpa/spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/caching/CachingRepositoryTests.java b/jpa/spring-data-jpa-example/src/test/java/example/springdata/jpa/caching/CachingRepositoryTests.java similarity index 90% rename from jpa/spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/caching/CachingRepositoryTests.java rename to jpa/spring-data-jpa-example/src/test/java/example/springdata/jpa/caching/CachingRepositoryTests.java index 8684f8ac..26250013 100644 --- a/jpa/spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/caching/CachingRepositoryTests.java +++ b/jpa/spring-data-jpa-example/src/test/java/example/springdata/jpa/caching/CachingRepositoryTests.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.example.repository.caching; +package example.springdata.jpa.caching; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; @@ -29,6 +29,10 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.transaction.annotation.Transactional; +import example.springdata.jpa.caching.CachingConfiguration; +import example.springdata.jpa.caching.CachingUserRepository; +import example.springdata.jpa.caching.User; + /** * Integration test to show how to use {@link Cacheable} with a Spring Data repository. * diff --git a/jpa/spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/custom/UserRepositoryCustomizationTests.java b/jpa/spring-data-jpa-example/src/test/java/example/springdata/jpa/custom/UserRepositoryCustomizationTests.java similarity index 95% rename from jpa/spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/custom/UserRepositoryCustomizationTests.java rename to jpa/spring-data-jpa-example/src/test/java/example/springdata/jpa/custom/UserRepositoryCustomizationTests.java index a5c2abe4..301ad288 100644 --- a/jpa/spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/custom/UserRepositoryCustomizationTests.java +++ b/jpa/spring-data-jpa-example/src/test/java/example/springdata/jpa/custom/UserRepositoryCustomizationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.example.repository.custom; +package example.springdata.jpa.custom; import static org.junit.Assert.*; diff --git a/jpa/spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/simple/SimpleUserRepositoryTests.java b/jpa/spring-data-jpa-example/src/test/java/example/springdata/jpa/simple/SimpleUserRepositoryTests.java similarity index 91% rename from jpa/spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/simple/SimpleUserRepositoryTests.java rename to jpa/spring-data-jpa-example/src/test/java/example/springdata/jpa/simple/SimpleUserRepositoryTests.java index e9e7f3de..c012b209 100644 --- a/jpa/spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/simple/SimpleUserRepositoryTests.java +++ b/jpa/spring-data-jpa-example/src/test/java/example/springdata/jpa/simple/SimpleUserRepositoryTests.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.example.repository.simple; +package example.springdata.jpa.simple; import static org.junit.Assert.*; @@ -27,6 +27,10 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.transaction.annotation.Transactional; +import example.springdata.jpa.simple.SimpleConfiguration; +import example.springdata.jpa.simple.SimpleUserRepository; +import example.springdata.jpa.simple.User; + /** * Intergration test showing the basic usage of {@link SimpleUserRepository}. * diff --git a/jpa/spring-data-jpa-example/src/test/resources/META-INF/persistence.xml b/jpa/spring-data-jpa-example/src/test/resources/META-INF/persistence.xml index 7f39b498..f8381193 100644 --- a/jpa/spring-data-jpa-example/src/test/resources/META-INF/persistence.xml +++ b/jpa/spring-data-jpa-example/src/test/resources/META-INF/persistence.xml @@ -2,7 +2,7 @@ - org.springframework.data.jpa.example.repository.simple.User + example.springdata.jpa.simple.User diff --git a/jpa/spring-data-jpa-interceptors/src/main/java/org/spring/data/jpa/sample/interceptors/ApplicationConfiguration.java b/jpa/spring-data-jpa-interceptors/src/main/java/example/springdata/jpa/interceptors/ApplicationConfiguration.java similarity index 97% rename from jpa/spring-data-jpa-interceptors/src/main/java/org/spring/data/jpa/sample/interceptors/ApplicationConfiguration.java rename to jpa/spring-data-jpa-interceptors/src/main/java/example/springdata/jpa/interceptors/ApplicationConfiguration.java index 3f456d1d..82f9082b 100644 --- a/jpa/spring-data-jpa-interceptors/src/main/java/org/spring/data/jpa/sample/interceptors/ApplicationConfiguration.java +++ b/jpa/spring-data-jpa-interceptors/src/main/java/example/springdata/jpa/interceptors/ApplicationConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.spring.data.jpa.sample.interceptors; +package example.springdata.jpa.interceptors; import org.springframework.aop.Advisor; import org.springframework.aop.aspectj.AspectJExpressionPointcut; diff --git a/jpa/spring-data-jpa-interceptors/src/main/java/org/spring/data/jpa/sample/interceptors/Customer.java b/jpa/spring-data-jpa-interceptors/src/main/java/example/springdata/jpa/interceptors/Customer.java similarity index 85% rename from jpa/spring-data-jpa-interceptors/src/main/java/org/spring/data/jpa/sample/interceptors/Customer.java rename to jpa/spring-data-jpa-interceptors/src/main/java/example/springdata/jpa/interceptors/Customer.java index ac026355..149ba92b 100644 --- a/jpa/spring-data-jpa-interceptors/src/main/java/org/spring/data/jpa/sample/interceptors/Customer.java +++ b/jpa/spring-data-jpa-interceptors/src/main/java/example/springdata/jpa/interceptors/Customer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 the original author or authors. + * Copyright 2012-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.spring.data.jpa.sample.interceptors; +package example.springdata.jpa.interceptors; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -22,9 +22,7 @@ import javax.persistence.Id; @Entity public class Customer { - @Id - @GeneratedValue - Long id; + @Id @GeneratedValue Long id; String firstname; String lastname; diff --git a/jpa/spring-data-jpa-interceptors/src/main/java/org/spring/data/jpa/sample/interceptors/CustomerRepository.java b/jpa/spring-data-jpa-interceptors/src/main/java/example/springdata/jpa/interceptors/CustomerRepository.java similarity index 87% rename from jpa/spring-data-jpa-interceptors/src/main/java/org/spring/data/jpa/sample/interceptors/CustomerRepository.java rename to jpa/spring-data-jpa-interceptors/src/main/java/example/springdata/jpa/interceptors/CustomerRepository.java index 1a2a788a..35fecd2b 100644 --- a/jpa/spring-data-jpa-interceptors/src/main/java/org/spring/data/jpa/sample/interceptors/CustomerRepository.java +++ b/jpa/spring-data-jpa-interceptors/src/main/java/example/springdata/jpa/interceptors/CustomerRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 the original author or authors. + * Copyright 2012-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.spring.data.jpa.sample.interceptors; +package example.springdata.jpa.interceptors; import org.springframework.data.repository.CrudRepository; diff --git a/jpa/spring-data-jpa-interceptors/src/test/java/org/spring/data/jpa/sample/interceptors/InterceptorIntegrationTest.java b/jpa/spring-data-jpa-interceptors/src/test/java/example/springdata/jpa/interceptors/InterceptorIntegrationTest.java similarity index 88% rename from jpa/spring-data-jpa-interceptors/src/test/java/org/spring/data/jpa/sample/interceptors/InterceptorIntegrationTest.java rename to jpa/spring-data-jpa-interceptors/src/test/java/example/springdata/jpa/interceptors/InterceptorIntegrationTest.java index 6bfb2372..b3ee6a01 100644 --- a/jpa/spring-data-jpa-interceptors/src/test/java/org/spring/data/jpa/sample/interceptors/InterceptorIntegrationTest.java +++ b/jpa/spring-data-jpa-interceptors/src/test/java/example/springdata/jpa/interceptors/InterceptorIntegrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 the original author or authors. + * Copyright 2012-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.spring.data.jpa.sample.interceptors; +package example.springdata.jpa.interceptors; import org.junit.Test; import org.junit.runner.RunWith; @@ -25,8 +25,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @ContextConfiguration(classes = ApplicationConfiguration.class) public class InterceptorIntegrationTest { - @Autowired - CustomerRepository repository; + @Autowired CustomerRepository repository; @Test public void foo() { diff --git a/jpa/spring-data-jpa-java8-auditing/src/main/java/org/springframework/data/jpa/examples/java8/AbstractEntity.java b/jpa/spring-data-jpa-java8-auditing/src/main/java/example/springdata/jpa/java8/AbstractEntity.java similarity index 92% rename from jpa/spring-data-jpa-java8-auditing/src/main/java/org/springframework/data/jpa/examples/java8/AbstractEntity.java rename to jpa/spring-data-jpa-java8-auditing/src/main/java/example/springdata/jpa/java8/AbstractEntity.java index 33a1b0ac..d625f98f 100644 --- a/jpa/spring-data-jpa-java8-auditing/src/main/java/org/springframework/data/jpa/examples/java8/AbstractEntity.java +++ b/jpa/spring-data-jpa-java8-auditing/src/main/java/example/springdata/jpa/java8/AbstractEntity.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.examples.java8; +package example.springdata.jpa.java8; import java.time.ZonedDateTime; diff --git a/jpa/spring-data-jpa-java8-auditing/src/main/java/org/springframework/data/jpa/examples/java8/Customer.java b/jpa/spring-data-jpa-java8-auditing/src/main/java/example/springdata/jpa/java8/Customer.java similarity index 89% rename from jpa/spring-data-jpa-java8-auditing/src/main/java/org/springframework/data/jpa/examples/java8/Customer.java rename to jpa/spring-data-jpa-java8-auditing/src/main/java/example/springdata/jpa/java8/Customer.java index 132c9449..72b38c92 100644 --- a/jpa/spring-data-jpa-java8-auditing/src/main/java/org/springframework/data/jpa/examples/java8/Customer.java +++ b/jpa/spring-data-jpa-java8-auditing/src/main/java/example/springdata/jpa/java8/Customer.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.examples.java8; +package example.springdata.jpa.java8; import javax.persistence.Entity; diff --git a/jpa/spring-data-jpa-java8-auditing/src/main/java/org/springframework/data/jpa/examples/java8/CustomerRepository.java b/jpa/spring-data-jpa-java8-auditing/src/main/java/example/springdata/jpa/java8/CustomerRepository.java similarity index 87% rename from jpa/spring-data-jpa-java8-auditing/src/main/java/org/springframework/data/jpa/examples/java8/CustomerRepository.java rename to jpa/spring-data-jpa-java8-auditing/src/main/java/example/springdata/jpa/java8/CustomerRepository.java index cf0207a9..5ca47de4 100644 --- a/jpa/spring-data-jpa-java8-auditing/src/main/java/org/springframework/data/jpa/examples/java8/CustomerRepository.java +++ b/jpa/spring-data-jpa-java8-auditing/src/main/java/example/springdata/jpa/java8/CustomerRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.examples.java8; +package example.springdata.jpa.java8; import org.springframework.data.repository.CrudRepository; diff --git a/jpa/spring-data-jpa-java8-auditing/src/test/java/org/springframework/data/jpa/examples/java8/Java8AuditingIntegrationTests.java b/jpa/spring-data-jpa-java8-auditing/src/test/java/example/springdata/jpa/java8/Java8AuditingIntegrationTests.java similarity index 93% rename from jpa/spring-data-jpa-java8-auditing/src/test/java/org/springframework/data/jpa/examples/java8/Java8AuditingIntegrationTests.java rename to jpa/spring-data-jpa-java8-auditing/src/test/java/example/springdata/jpa/java8/Java8AuditingIntegrationTests.java index 9a808343..959e5f06 100644 --- a/jpa/spring-data-jpa-java8-auditing/src/test/java/org/springframework/data/jpa/examples/java8/Java8AuditingIntegrationTests.java +++ b/jpa/spring-data-jpa-java8-auditing/src/test/java/example/springdata/jpa/java8/Java8AuditingIntegrationTests.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.examples.java8; +package example.springdata.jpa.java8; import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; @@ -28,6 +28,9 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import example.springdata.jpa.java8.Customer; +import example.springdata.jpa.java8.CustomerRepository; + /** * Integration test to show the usage of Java 8 date time APIs with Spring Data JPA auditing. * diff --git a/jpa/spring-data-jpa-showcase/README.txt b/jpa/spring-data-jpa-showcase/README.txt index 1db5a3ec..bf4b5fd4 100644 --- a/jpa/spring-data-jpa-showcase/README.txt +++ b/jpa/spring-data-jpa-showcase/README.txt @@ -1,4 +1,4 @@ Spring Data JPA showcase ------------------------ -This is the sample app to demo Spring Data JPA features at conferences. The two main packages to take a look at are org.springframework.data.jpa.showcase.before and org.springframework.data.jpa.showcase.after. The first one shows a typical data access implementation with JPA 2. The second one shows what's left if you use Spring Data JPA. \ No newline at end of file +This is the sample app to demo Spring Data JPA features at conferences. The two main packages to take a look at are example.springdata.jpa.showcase.before and example.springdata.jpa.showcase.after. The first one shows a typical data access implementation with JPA 2. The second one shows what's left if you use Spring Data JPA. \ No newline at end of file diff --git a/jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/after/AccountRepository.java b/jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/after/AccountRepository.java new file mode 100644 index 00000000..f25a7b4d --- /dev/null +++ b/jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/after/AccountRepository.java @@ -0,0 +1,39 @@ +/* + * Copyright 2011-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package example.springdata.jpa.showcase.after; + +import java.util.List; + +import org.springframework.data.repository.CrudRepository; + +import example.springdata.jpa.showcase.core.Account; +import example.springdata.jpa.showcase.core.Customer; + +/** + * Repository to manage {@link Account} instances. + * + * @author Oliver Gierke + */ +public interface AccountRepository extends CrudRepository { + + /** + * Returns all accounts belonging to the given {@link Customer}. + * + * @param customer + * @return + */ + List findByCustomer(Customer customer); +} diff --git a/jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/after/CustomerRepository.java b/jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/after/CustomerRepository.java new file mode 100644 index 00000000..580dbf5c --- /dev/null +++ b/jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/after/CustomerRepository.java @@ -0,0 +1,40 @@ +/* + * Copyright 2011-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package example.springdata.jpa.showcase.after; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.repository.CrudRepository; + +import example.springdata.jpa.showcase.core.Customer; + +/** + * Repository to manage {@link Customer} instances. + * + * @author Oliver Gierke + */ +public interface CustomerRepository extends CrudRepository, JpaSpecificationExecutor { + + /** + * Returns a page of {@link Customer}s with the given lastname. + * + * @param lastname + * @param pageable + * @return + */ + Page findByLastname(String lastname, Pageable pageable); +} diff --git a/jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/before/AccountService.java b/jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/before/AccountService.java new file mode 100644 index 00000000..abfad2c8 --- /dev/null +++ b/jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/before/AccountService.java @@ -0,0 +1,45 @@ +/* + * Copyright 2011-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package example.springdata.jpa.showcase.before; + +import java.util.List; + +import example.springdata.jpa.showcase.core.Account; +import example.springdata.jpa.showcase.core.Customer; + +/** + * Service interface for {@link Account}s. + * + * @author Oliver Gierke + */ +public interface AccountService { + + /** + * Saves the given {@link Account}. + * + * @param account + * @return + */ + Account save(Account account); + + /** + * Returns all {@link Account}s of the given {@link Customer}. + * + * @param customer + * @return + */ + List findByCustomer(Customer customer); +} diff --git a/jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/before/AccountServiceImpl.java b/jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/before/AccountServiceImpl.java new file mode 100644 index 00000000..1c6e0f6f --- /dev/null +++ b/jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/before/AccountServiceImpl.java @@ -0,0 +1,69 @@ +/* + * Copyright 2011-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package example.springdata.jpa.showcase.before; + +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.TypedQuery; + +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + +import example.springdata.jpa.showcase.core.Account; +import example.springdata.jpa.showcase.core.Customer; + +/** + * Plain JPA implementation of {@link AccountService}. + * + * @author Oliver Gierke + */ +@Repository +@Transactional(readOnly = true) +class AccountServiceImpl implements AccountService { + + @PersistenceContext private EntityManager em; + + /* + * (non-Javadoc) + * @see example.springdata.jpa.showcase.before.AccountService#save(example.springdata.jpa.showcase.core.Account) + */ + @Override + @Transactional + public Account save(Account account) { + + if (account.getId() == null) { + em.persist(account); + return account; + } else { + return em.merge(account); + } + } + + /* + * (non-Javadoc) + * @see example.springdata.jpa.showcase.before.AccountService#findByCustomer(example.springdata.jpa.showcase.core.Customer) + */ + @Override + public List findByCustomer(Customer customer) { + + TypedQuery query = em.createQuery("select a from Account a where a.customer = ?1", Account.class); + query.setParameter(1, customer); + + return query.getResultList(); + } +} diff --git a/jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/before/CustomerService.java b/jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/before/CustomerService.java similarity index 58% rename from jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/before/CustomerService.java rename to jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/before/CustomerService.java index 96413871..163e1c52 100644 --- a/jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/before/CustomerService.java +++ b/jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/before/CustomerService.java @@ -1,8 +1,23 @@ -package org.springframework.data.jpa.showcase.before; +/* + * Copyright 2011-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package example.springdata.jpa.showcase.before; import java.util.List; -import org.springframework.data.jpa.showcase.core.Customer; +import example.springdata.jpa.showcase.core.Customer; /** * Service interface for {@link Customer}s. diff --git a/jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/before/CustomerServiceImpl.java b/jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/before/CustomerServiceImpl.java similarity index 57% rename from jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/before/CustomerServiceImpl.java rename to jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/before/CustomerServiceImpl.java index 074e767d..e2f09e32 100644 --- a/jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/before/CustomerServiceImpl.java +++ b/jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/before/CustomerServiceImpl.java @@ -1,4 +1,19 @@ -package org.springframework.data.jpa.showcase.before; +/* + * Copyright 2011-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package example.springdata.jpa.showcase.before; import java.util.List; @@ -6,10 +21,11 @@ import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence.TypedQuery; -import org.springframework.data.jpa.showcase.core.Customer; import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.Transactional; +import example.springdata.jpa.showcase.core.Customer; + /** * Plain JPA implementation of {@link CustomerService}. * @@ -19,12 +35,11 @@ import org.springframework.transaction.annotation.Transactional; @Transactional(readOnly = true) public class CustomerServiceImpl implements CustomerService { - @PersistenceContext - private EntityManager em; + @PersistenceContext private EntityManager em; /* * (non-Javadoc) - * @see org.springframework.data.jpa.showcase.before.CustomerService#findById(java.lang.Long) + * @see example.springdata.jpa.showcase.before.CustomerService#findById(java.lang.Long) */ @Override public Customer findById(Long id) { @@ -33,7 +48,7 @@ public class CustomerServiceImpl implements CustomerService { /* * (non-Javadoc) - * @see org.springframework.data.jpa.showcase.before.CustomerService#findAll() + * @see example.springdata.jpa.showcase.before.CustomerService#findAll() */ @Override public List findAll() { @@ -42,7 +57,7 @@ public class CustomerServiceImpl implements CustomerService { /* * (non-Javadoc) - * @see org.springframework.data.jpa.showcase.before.CustomerService#findAll(int, int) + * @see example.springdata.jpa.showcase.before.CustomerService#findAll(int, int) */ @Override public List findAll(int page, int pageSize) { @@ -57,7 +72,7 @@ public class CustomerServiceImpl implements CustomerService { /* * (non-Javadoc) - * @see org.springframework.data.jpa.showcase.before.CustomerService#save(org.springframework.data.jpa.showcase.core.Customer) + * @see example.springdata.jpa.showcase.before.CustomerService#save(example.springdata.jpa.showcase.core.Customer) */ @Override @Transactional @@ -74,7 +89,7 @@ public class CustomerServiceImpl implements CustomerService { /* * (non-Javadoc) - * @see org.springframework.data.jpa.showcase.before.CustomerService#findByLastname(java.lang.String, int, int) + * @see example.springdata.jpa.showcase.before.CustomerService#findByLastname(java.lang.String, int, int) */ @Override public List findByLastname(String lastname, int page, int pageSize) { diff --git a/jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/core/Account.java b/jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/core/Account.java new file mode 100644 index 00000000..08a05e1a --- /dev/null +++ b/jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/core/Account.java @@ -0,0 +1,51 @@ +/* + * Copyright 2011-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package example.springdata.jpa.showcase.core; + +import java.util.Date; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +/** + * @author Oliver Gierke + */ +@Entity +public class Account { + + @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; + + @ManyToOne private Customer customer; + + @Temporal(TemporalType.DATE) private Date expiryDate; + + public Long getId() { + return id; + } + + public Customer getCustomer() { + return customer; + } + + public Date getExpiryDate() { + return expiryDate; + } +} diff --git a/jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/core/Customer.java b/jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/core/Customer.java new file mode 100644 index 00000000..1c6088fd --- /dev/null +++ b/jpa/spring-data-jpa-showcase/src/main/java/example/springdata/jpa/showcase/core/Customer.java @@ -0,0 +1,45 @@ +/* + * Copyright 2011-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package example.springdata.jpa.showcase.core; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +/** + * @author Oliver Gierke + */ +@Entity +public class Customer { + + @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; + + private String firstname; + private String lastname; + + public Long getId() { + return id; + } + + public String getFirstname() { + return firstname; + } + + public String getLastname() { + return lastname; + } +} diff --git a/jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/after/AccountRepository.java b/jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/after/AccountRepository.java deleted file mode 100644 index 3d40aa72..00000000 --- a/jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/after/AccountRepository.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.springframework.data.jpa.showcase.after; - -import java.util.List; - -import org.springframework.data.jpa.showcase.core.Account; -import org.springframework.data.jpa.showcase.core.Customer; -import org.springframework.data.repository.CrudRepository; - -/** - * Repository to manage {@link Account} instances. - * - * @author Oliver Gierke - */ -public interface AccountRepository extends CrudRepository { - - /** - * Returns all accounts belonging to the given {@link Customer}. - * - * @param customer - * @return - */ - List findByCustomer(Customer customer); -} diff --git a/jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/after/CustomerRepository.java b/jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/after/CustomerRepository.java deleted file mode 100644 index 9bd4e718..00000000 --- a/jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/after/CustomerRepository.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.springframework.data.jpa.showcase.after; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; -import org.springframework.data.jpa.showcase.core.Customer; -import org.springframework.data.repository.CrudRepository; - -/** - * Repository to manage {@link Customer} instances. - * - * @author Oliver Gierke - */ -public interface CustomerRepository extends CrudRepository, JpaSpecificationExecutor { - - /** - * Returns a page of {@link Customer}s with the given lastname. - * - * @param lastname - * @param pageable - * @return - */ - Page findByLastname(String lastname, Pageable pageable); -} diff --git a/jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/before/AccountService.java b/jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/before/AccountService.java deleted file mode 100644 index a5c4a09f..00000000 --- a/jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/before/AccountService.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.springframework.data.jpa.showcase.before; - -import java.util.List; - -import org.springframework.data.jpa.showcase.core.Account; -import org.springframework.data.jpa.showcase.core.Customer; - -/** - * Service interface for {@link Account}s. - * - * @author Oliver Gierke - */ -public interface AccountService { - - /** - * Saves the given {@link Account}. - * - * @param account - * @return - */ - Account save(Account account); - - /** - * Returns all {@link Account}s of the given {@link Customer}. - * - * @param customer - * @return - */ - List findByCustomer(Customer customer); -} diff --git a/jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/before/AccountServiceImpl.java b/jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/before/AccountServiceImpl.java deleted file mode 100644 index 728acbcc..00000000 --- a/jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/before/AccountServiceImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.springframework.data.jpa.showcase.before; - -import java.util.List; - -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.persistence.TypedQuery; - -import org.springframework.data.jpa.showcase.core.Account; -import org.springframework.data.jpa.showcase.core.Customer; -import org.springframework.stereotype.Repository; -import org.springframework.transaction.annotation.Transactional; - -/** - * Plain JPA implementation of {@link AccountService}. - * - * @author Oliver Gierke - */ -@Repository -@Transactional(readOnly = true) -class AccountServiceImpl implements AccountService { - - @PersistenceContext - private EntityManager em; - - /* - * (non-Javadoc) - * @see org.springframework.data.jpa.showcase.before.AccountService#save(org.springframework.data.jpa.showcase.core.Account) - */ - @Override - @Transactional - public Account save(Account account) { - - if (account.getId() == null) { - em.persist(account); - return account; - } else { - return em.merge(account); - } - } - - /* - * (non-Javadoc) - * @see org.springframework.data.jpa.showcase.before.AccountService#findByCustomer(org.springframework.data.jpa.showcase.core.Customer) - */ - @Override - public List findByCustomer(Customer customer) { - - TypedQuery query = em.createQuery("select a from Account a where a.customer = ?1", Account.class); - query.setParameter(1, customer); - - return query.getResultList(); - } -} diff --git a/jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/core/Account.java b/jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/core/Account.java deleted file mode 100644 index 097dc356..00000000 --- a/jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/core/Account.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.springframework.data.jpa.showcase.core; - -import java.util.Date; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.ManyToOne; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; - -/** - * @author Oliver Gierke - */ -@Entity -public class Account { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - @ManyToOne - private Customer customer; - - @Temporal(TemporalType.DATE) - private Date expiryDate; - - public Long getId() { - return id; - } - - public Customer getCustomer() { - return customer; - } - - public Date getExpiryDate() { - return expiryDate; - } -} diff --git a/jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/core/Customer.java b/jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/core/Customer.java deleted file mode 100644 index 77da23c5..00000000 --- a/jpa/spring-data-jpa-showcase/src/main/java/org/springframework/data/jpa/showcase/core/Customer.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.springframework.data.jpa.showcase.core; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; - -/** - * @author Oliver Gierke - */ -@Entity -public class Customer { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - private String firstname; - private String lastname; - - public Long getId() { - return id; - } - - public String getFirstname() { - return firstname; - } - - public String getLastname() { - return lastname; - } -} diff --git a/jpa/spring-data-jpa-showcase/src/snippets/java/example/springdata/jpa/showcase/snippets/AccountPredicates.java b/jpa/spring-data-jpa-showcase/src/snippets/java/example/springdata/jpa/showcase/snippets/AccountPredicates.java new file mode 100644 index 00000000..57c9e932 --- /dev/null +++ b/jpa/spring-data-jpa-showcase/src/snippets/java/example/springdata/jpa/showcase/snippets/AccountPredicates.java @@ -0,0 +1,41 @@ +/* + * Copyright 2011-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package example.springdata.jpa.showcase.snippets; + +import org.joda.time.LocalDate; + +import com.mysema.query.types.expr.BooleanExpression; + +import example.springdata.jpa.showcase.core.Account; +import example.springdata.jpa.showcase.core.QAccount; + +/** + * Predicates for {@link Account}s. + * + * @author Oliver Gierke + */ +public class AccountPredicates { + + private static QAccount account = QAccount.account; + + public static BooleanExpression isExpired() { + return expiresBefore(new LocalDate()); + } + + public static BooleanExpression expiresBefore(LocalDate date) { + return account.expiryDate.before(date.toDateTimeAtStartOfDay().toDate()); + } +} diff --git a/jpa/spring-data-jpa-showcase/src/snippets/java/example/springdata/jpa/showcase/snippets/AccountRepository.java b/jpa/spring-data-jpa-showcase/src/snippets/java/example/springdata/jpa/showcase/snippets/AccountRepository.java new file mode 100644 index 00000000..ec904773 --- /dev/null +++ b/jpa/spring-data-jpa-showcase/src/snippets/java/example/springdata/jpa/showcase/snippets/AccountRepository.java @@ -0,0 +1,43 @@ +/* + * Copyright 2011-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package example.springdata.jpa.showcase.snippets; + +import java.util.List; + +import org.springframework.data.querydsl.QueryDslPredicateExecutor; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.NoRepositoryBean; + +import example.springdata.jpa.showcase.core.Account; +import example.springdata.jpa.showcase.core.Customer; + +/** + * Repository to manage {@link Account} instances. + * + * @author Oliver Gierke + */ +@NoRepositoryBean +public interface AccountRepository extends CrudRepository, AccountRepositoryCustom, + QueryDslPredicateExecutor { + + /** + * Returns all accounts belonging to the given {@link Customer}. + * + * @param customer + * @return + */ + List findByCustomer(Customer customer); +} diff --git a/jpa/spring-data-jpa-showcase/src/snippets/java/example/springdata/jpa/showcase/snippets/AccountRepositoryCustom.java b/jpa/spring-data-jpa-showcase/src/snippets/java/example/springdata/jpa/showcase/snippets/AccountRepositoryCustom.java new file mode 100644 index 00000000..90593a17 --- /dev/null +++ b/jpa/spring-data-jpa-showcase/src/snippets/java/example/springdata/jpa/showcase/snippets/AccountRepositoryCustom.java @@ -0,0 +1,26 @@ +/* + * Copyright 2011-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package example.springdata.jpa.showcase.snippets; + +import org.joda.time.LocalDate; + +/** + * @author Oliver Gierke + */ +interface AccountRepositoryCustom { + + void removedExpiredAccounts(LocalDate reference); +} diff --git a/jpa/spring-data-jpa-showcase/src/snippets/java/example/springdata/jpa/showcase/snippets/AccountRepositoryImpl.java b/jpa/spring-data-jpa-showcase/src/snippets/java/example/springdata/jpa/showcase/snippets/AccountRepositoryImpl.java new file mode 100644 index 00000000..d70632fb --- /dev/null +++ b/jpa/spring-data-jpa-showcase/src/snippets/java/example/springdata/jpa/showcase/snippets/AccountRepositoryImpl.java @@ -0,0 +1,61 @@ +/* + * Copyright 2011-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package example.springdata.jpa.showcase.snippets; + +import java.util.Date; + +import javax.persistence.EntityManager; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; + +import org.joda.time.LocalDate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import example.springdata.jpa.showcase.core.Account; + +/** + * @author Oliver Gierke + */ +@Repository +class AccountRepositoryImpl implements AccountRepositoryCustom { + + private final EntityManager em; + + @Autowired + public AccountRepositoryImpl(EntityManager em) { + this.em = em; + } + + /* + * (non-Javadoc) + * @see example.springdata.jpa.showcase.snippets.AccountRepositoryCustom#removedExpiredAccounts(org.joda.time.LocalDate) + */ + @Override + public void removedExpiredAccounts(LocalDate reference) { + + CriteriaBuilder cb = em.getCriteriaBuilder(); + CriteriaQuery query = cb.createQuery(Account.class); + Root account = query.from(Account.class); + + query.where(cb.lessThan(account.get("expiryDate").as(Date.class), reference.toDateTimeAtStartOfDay().toDate())); + + for (Account each : em.createQuery(query).getResultList()) { + em.remove(each); + } + } +} diff --git a/jpa/spring-data-jpa-showcase/src/snippets/java/example/springdata/jpa/showcase/snippets/AccountRepositoryJdbcImpl.java b/jpa/spring-data-jpa-showcase/src/snippets/java/example/springdata/jpa/showcase/snippets/AccountRepositoryJdbcImpl.java new file mode 100644 index 00000000..1227f8da --- /dev/null +++ b/jpa/spring-data-jpa-showcase/src/snippets/java/example/springdata/jpa/showcase/snippets/AccountRepositoryJdbcImpl.java @@ -0,0 +1,42 @@ +/* + * Copyright 2011-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package example.springdata.jpa.showcase.snippets; + +import org.joda.time.LocalDate; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Repository; + +/** + * @author Oliver Gierke + */ +@Repository +class AccountRepositoryJdbcImpl implements AccountRepositoryCustom { + + private JdbcTemplate template; + + public void setTemplate(JdbcTemplate template) { + this.template = template; + } + + /* + * (non-Javadoc) + * @see example.springdata.jpa.showcase.snippets.AccountRepositoryCustom#removedExpiredAccounts(org.joda.time.LocalDate) + */ + @Override + public void removedExpiredAccounts(LocalDate reference) { + template.update("DELETE Account AS a WHERE a.expiryDate < ?", reference.toDateTimeAtStartOfDay().toDate()); + } +} diff --git a/jpa/spring-data-jpa-showcase/src/snippets/java/org/springframework/data/jpa/showcase/snippets/CustomerSpecifications.java b/jpa/spring-data-jpa-showcase/src/snippets/java/example/springdata/jpa/showcase/snippets/CustomerSpecifications.java similarity index 61% rename from jpa/spring-data-jpa-showcase/src/snippets/java/org/springframework/data/jpa/showcase/snippets/CustomerSpecifications.java rename to jpa/spring-data-jpa-showcase/src/snippets/java/example/springdata/jpa/showcase/snippets/CustomerSpecifications.java index 34e0c461..78d7be46 100644 --- a/jpa/spring-data-jpa-showcase/src/snippets/java/org/springframework/data/jpa/showcase/snippets/CustomerSpecifications.java +++ b/jpa/spring-data-jpa-showcase/src/snippets/java/example/springdata/jpa/showcase/snippets/CustomerSpecifications.java @@ -1,4 +1,19 @@ -package org.springframework.data.jpa.showcase.snippets; +/* + * Copyright 2011-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package example.springdata.jpa.showcase.snippets; import java.util.Date; @@ -10,8 +25,9 @@ import javax.persistence.criteria.Root; import org.joda.time.LocalDate; import org.springframework.data.jpa.domain.Specification; -import org.springframework.data.jpa.showcase.core.Account; -import org.springframework.data.jpa.showcase.core.Customer; + +import example.springdata.jpa.showcase.core.Account; +import example.springdata.jpa.showcase.core.Customer; /** * Collection of {@link Specification} implementations. diff --git a/jpa/spring-data-jpa-showcase/src/snippets/java/org/springframework/data/jpa/showcase/snippets/AccountPredicates.java b/jpa/spring-data-jpa-showcase/src/snippets/java/org/springframework/data/jpa/showcase/snippets/AccountPredicates.java deleted file mode 100644 index 828a0f22..00000000 --- a/jpa/spring-data-jpa-showcase/src/snippets/java/org/springframework/data/jpa/showcase/snippets/AccountPredicates.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.springframework.data.jpa.showcase.snippets; - -import org.joda.time.LocalDate; -import org.springframework.data.jpa.showcase.core.Account; -import org.springframework.data.jpa.showcase.core.QAccount; - -import com.mysema.query.types.expr.BooleanExpression; - -/** - * Predicates for {@link Account}s. - * - * @author Oliver Gierke - */ -public class AccountPredicates { - - private static QAccount $ = QAccount.account; - - public static BooleanExpression isExpired() { - return expiresBefore(new LocalDate()); - } - - public static BooleanExpression expiresBefore(LocalDate date) { - return $.expiryDate.before(date.toDateTimeAtStartOfDay().toDate()); - } -} diff --git a/jpa/spring-data-jpa-showcase/src/snippets/java/org/springframework/data/jpa/showcase/snippets/AccountRepository.java b/jpa/spring-data-jpa-showcase/src/snippets/java/org/springframework/data/jpa/showcase/snippets/AccountRepository.java deleted file mode 100644 index 85520f76..00000000 --- a/jpa/spring-data-jpa-showcase/src/snippets/java/org/springframework/data/jpa/showcase/snippets/AccountRepository.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.springframework.data.jpa.showcase.snippets; - -import java.util.List; - -import org.springframework.data.jpa.showcase.core.Account; -import org.springframework.data.jpa.showcase.core.Customer; -import org.springframework.data.querydsl.QueryDslPredicateExecutor; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.NoRepositoryBean; - -/** - * Repository to manage {@link Account} instances. - * - * @author Oliver Gierke - */ -@NoRepositoryBean -public interface AccountRepository extends CrudRepository, AccountRepositoryCustom, - QueryDslPredicateExecutor { - - /** - * Returns all accounts belonging to the given {@link Customer}. - * - * @param customer - * @return - */ - List findByCustomer(Customer customer); -} diff --git a/jpa/spring-data-jpa-showcase/src/snippets/java/org/springframework/data/jpa/showcase/snippets/AccountRepositoryCustom.java b/jpa/spring-data-jpa-showcase/src/snippets/java/org/springframework/data/jpa/showcase/snippets/AccountRepositoryCustom.java deleted file mode 100644 index dcae0a5f..00000000 --- a/jpa/spring-data-jpa-showcase/src/snippets/java/org/springframework/data/jpa/showcase/snippets/AccountRepositoryCustom.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.springframework.data.jpa.showcase.snippets; - -import org.joda.time.LocalDate; - -/** - * @author Oliver Gierke - */ -interface AccountRepositoryCustom { - - void removedExpiredAccounts(LocalDate reference); -} diff --git a/jpa/spring-data-jpa-showcase/src/snippets/java/org/springframework/data/jpa/showcase/snippets/AccountRepositoryImpl.java b/jpa/spring-data-jpa-showcase/src/snippets/java/org/springframework/data/jpa/showcase/snippets/AccountRepositoryImpl.java deleted file mode 100644 index 9dce0b0f..00000000 --- a/jpa/spring-data-jpa-showcase/src/snippets/java/org/springframework/data/jpa/showcase/snippets/AccountRepositoryImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.springframework.data.jpa.showcase.snippets; - -import java.util.Date; - -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; - -import org.joda.time.LocalDate; -import org.springframework.data.jpa.showcase.core.Account; -import org.springframework.stereotype.Repository; - -/** - * @author Oliver Gierke - */ -@Repository -class AccountRepositoryImpl implements AccountRepositoryCustom { - - @PersistenceContext private EntityManager em; - - /* - * (non-Javadoc) - * @see org.springframework.data.jpa.showcase.snippets.AccountRepositoryCustom#removedExpiredAccounts(org.joda.time.LocalDate) - */ - @Override - public void removedExpiredAccounts(LocalDate reference) { - - CriteriaBuilder cb = em.getCriteriaBuilder(); - CriteriaQuery query = cb.createQuery(Account.class); - Root account = query.from(Account.class); - - query.where(cb.lessThan(account.get("expiryDate").as(Date.class), reference.toDateTimeAtStartOfDay().toDate())); - - for (Account each : em.createQuery(query).getResultList()) { - em.remove(each); - } - } -} diff --git a/jpa/spring-data-jpa-showcase/src/snippets/java/org/springframework/data/jpa/showcase/snippets/AccountRepositoryJdbcImpl.java b/jpa/spring-data-jpa-showcase/src/snippets/java/org/springframework/data/jpa/showcase/snippets/AccountRepositoryJdbcImpl.java deleted file mode 100644 index bb6448f8..00000000 --- a/jpa/spring-data-jpa-showcase/src/snippets/java/org/springframework/data/jpa/showcase/snippets/AccountRepositoryJdbcImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.springframework.data.jpa.showcase.snippets; - -import org.joda.time.LocalDate; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.stereotype.Repository; - -/** - * @author Oliver Gierke - */ -@Repository -class AccountRepositoryJdbcImpl implements AccountRepositoryCustom { - - private JdbcTemplate template; - - public void setTemplate(JdbcTemplate template) { - this.template = template; - } - - /* - * (non-Javadoc) - * @see org.springframework.data.jpa.showcase.snippets.AccountRepositoryCustom#removedExpiredAccounts(org.joda.time.LocalDate) - */ - @Override - public void removedExpiredAccounts(LocalDate reference) { - template.update("DELETE Account AS a WHERE a.expiryDate < ?", reference.toDateTimeAtStartOfDay().toDate()); - } -} diff --git a/jpa/spring-data-jpa-showcase/src/snippets/resources/jdbc.xml b/jpa/spring-data-jpa-showcase/src/snippets/resources/jdbc.xml index 41a3a29b..1a00def0 100644 --- a/jpa/spring-data-jpa-showcase/src/snippets/resources/jdbc.xml +++ b/jpa/spring-data-jpa-showcase/src/snippets/resources/jdbc.xml @@ -1,4 +1,4 @@ - + diff --git a/jpa/spring-data-jpa-showcase/src/test-snippets/java/example/springdata/jpa/showcase/snippets/test/AccountRepositoryIntegrationTest.java b/jpa/spring-data-jpa-showcase/src/test-snippets/java/example/springdata/jpa/showcase/snippets/test/AccountRepositoryIntegrationTest.java new file mode 100644 index 00000000..f2e03a57 --- /dev/null +++ b/jpa/spring-data-jpa-showcase/src/test-snippets/java/example/springdata/jpa/showcase/snippets/test/AccountRepositoryIntegrationTest.java @@ -0,0 +1,50 @@ +/* + * Copyright 2011-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package example.springdata.jpa.showcase.snippets.test; + +import static example.springdata.jpa.showcase.snippets.AccountPredicates.*; +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.*; + +import org.joda.time.LocalDate; + +import example.springdata.jpa.showcase.core.Account; +import example.springdata.jpa.showcase.snippets.AccountRepository; + +/** + * @author Oliver Gierke + */ +public abstract class AccountRepositoryIntegrationTest { + + private AccountRepository accountRepository; + + public void removesExpiredAccountsCorrectly() throws Exception { + + accountRepository.removedExpiredAccounts(new LocalDate(2011, 1, 1)); + assertThat(accountRepository.count(), is(1L)); + } + + public void findsExpiredAccounts() { + + Account expired = accountRepository.findOne(1L); + Account valid = accountRepository.findOne(2L); + + Iterable findAll = accountRepository.findAll(expiresBefore(new LocalDate(2011, 3, 1))); + + assertThat(findAll, hasItem(expired)); + assertThat(findAll, not(hasItem(valid))); + } +} diff --git a/jpa/spring-data-jpa-showcase/src/test-snippets/java/example/springdata/jpa/showcase/snippets/test/CustomerRepositoryIntegrationTest.java b/jpa/spring-data-jpa-showcase/src/test-snippets/java/example/springdata/jpa/showcase/snippets/test/CustomerRepositoryIntegrationTest.java new file mode 100644 index 00000000..14674a5b --- /dev/null +++ b/jpa/spring-data-jpa-showcase/src/test-snippets/java/example/springdata/jpa/showcase/snippets/test/CustomerRepositoryIntegrationTest.java @@ -0,0 +1,50 @@ +/* + * Copyright 2011-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package example.springdata.jpa.showcase.snippets.test; + +import static example.springdata.jpa.showcase.snippets.CustomerSpecifications.*; +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.*; +import static org.springframework.data.jpa.domain.Specifications.*; + +import java.util.List; + +import org.joda.time.LocalDate; +import org.springframework.data.jpa.domain.Specification; + +import example.springdata.jpa.showcase.after.CustomerRepository; +import example.springdata.jpa.showcase.core.Customer; + +/** + * Snippets to show the usage of {@link Specification}s. + * + * @author Oliver Gierke + */ +public class CustomerRepositoryIntegrationTest { + + private CustomerRepository repository; + + public void findsCustomersBySpecification() throws Exception { + + Customer dave = repository.findOne(1L); + + LocalDate expiryLimit = new LocalDate(2011, 3, 1); + List result = repository.findAll(where(accountExpiresBefore(expiryLimit))); + + assertThat(result.size(), is(1)); + assertThat(result, hasItems(dave)); + } +} diff --git a/jpa/spring-data-jpa-showcase/src/test-snippets/java/org/springframework/data/jpa/showcase/snippets/test/AccountRepositoryIntegrationTest.java b/jpa/spring-data-jpa-showcase/src/test-snippets/java/org/springframework/data/jpa/showcase/snippets/test/AccountRepositoryIntegrationTest.java deleted file mode 100644 index 752cf626..00000000 --- a/jpa/spring-data-jpa-showcase/src/test-snippets/java/org/springframework/data/jpa/showcase/snippets/test/AccountRepositoryIntegrationTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.springframework.data.jpa.showcase.snippets.test; - -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.*; -import static org.springframework.data.jpa.showcase.snippets.AccountPredicates.*; - -import org.joda.time.LocalDate; -import org.springframework.data.jpa.showcase.core.Account; -import org.springframework.data.jpa.showcase.snippets.AccountRepository; - -/** - * @author Oliver Gierke - */ -public abstract class AccountRepositoryIntegrationTest { - - private AccountRepository accountRepository; - - public void removesExpiredAccountsCorrectly() throws Exception { - - accountRepository.removedExpiredAccounts(new LocalDate(2011, 1, 1)); - assertThat(accountRepository.count(), is(1L)); - } - - public void findsExpiredAccounts() { - - Account expired = accountRepository.findOne(1L); - Account valid = accountRepository.findOne(2L); - - Iterable findAll = accountRepository.findAll(expiresBefore(new LocalDate(2011, 3, 1))); - - assertThat(findAll, hasItem(expired)); - assertThat(findAll, not(hasItem(valid))); - } -} diff --git a/jpa/spring-data-jpa-showcase/src/test-snippets/java/org/springframework/data/jpa/showcase/snippets/test/CustomerRepositoryIntegrationTest.java b/jpa/spring-data-jpa-showcase/src/test-snippets/java/org/springframework/data/jpa/showcase/snippets/test/CustomerRepositoryIntegrationTest.java deleted file mode 100644 index d51cf49d..00000000 --- a/jpa/spring-data-jpa-showcase/src/test-snippets/java/org/springframework/data/jpa/showcase/snippets/test/CustomerRepositoryIntegrationTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.springframework.data.jpa.showcase.snippets.test; - -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.*; -import static org.springframework.data.jpa.domain.Specifications.*; -import static org.springframework.data.jpa.showcase.snippets.CustomerSpecifications.*; - -import java.util.List; - -import org.joda.time.LocalDate; -import org.springframework.data.jpa.domain.Specification; -import org.springframework.data.jpa.showcase.after.CustomerRepository; -import org.springframework.data.jpa.showcase.core.Customer; - -/** - * Snippets to show the usage of {@link Specification}s. - * - * @author Oliver Gierke - */ -public class CustomerRepositoryIntegrationTest { - - private CustomerRepository repository; - - public void findsCustomersBySpecification() throws Exception { - - Customer dave = repository.findOne(1L); - - LocalDate expiryLimit = new LocalDate(2011, 3, 1); - List result = repository.findAll(where(accountExpiresBefore(expiryLimit))); - - assertThat(result.size(), is(1)); - assertThat(result, hasItems(dave)); - } -} diff --git a/jpa/spring-data-jpa-showcase/src/test/java/org/springframework/data/jpa/showcase/AbstractShowcaseTest.java b/jpa/spring-data-jpa-showcase/src/test/java/example/springdata/jpa/showcase/AbstractShowcaseTest.java similarity index 59% rename from jpa/spring-data-jpa-showcase/src/test/java/org/springframework/data/jpa/showcase/AbstractShowcaseTest.java rename to jpa/spring-data-jpa-showcase/src/test/java/example/springdata/jpa/showcase/AbstractShowcaseTest.java index 4f23ba21..cd17c165 100644 --- a/jpa/spring-data-jpa-showcase/src/test/java/org/springframework/data/jpa/showcase/AbstractShowcaseTest.java +++ b/jpa/spring-data-jpa-showcase/src/test/java/example/springdata/jpa/showcase/AbstractShowcaseTest.java @@ -1,15 +1,31 @@ -package org.springframework.data.jpa.showcase; +/* + * Copyright 2011-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package example.springdata.jpa.showcase; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.data.jpa.showcase.AbstractShowcaseTest.TestConfig; import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests; import org.springframework.test.context.transaction.BeforeTransaction; import org.springframework.transaction.annotation.Transactional; +import example.springdata.jpa.showcase.AbstractShowcaseTest.TestConfig; + /** * @author Oliver Gierke */ diff --git a/jpa/spring-data-jpa-showcase/src/test/java/org/springframework/data/jpa/showcase/after/AccountRepositoryIntegrationTest.java b/jpa/spring-data-jpa-showcase/src/test/java/example/springdata/jpa/showcase/after/AccountRepositoryIntegrationTest.java similarity index 83% rename from jpa/spring-data-jpa-showcase/src/test/java/org/springframework/data/jpa/showcase/after/AccountRepositoryIntegrationTest.java rename to jpa/spring-data-jpa-showcase/src/test/java/example/springdata/jpa/showcase/after/AccountRepositoryIntegrationTest.java index efcb9e3c..15df7752 100644 --- a/jpa/spring-data-jpa-showcase/src/test/java/org/springframework/data/jpa/showcase/after/AccountRepositoryIntegrationTest.java +++ b/jpa/spring-data-jpa-showcase/src/test/java/example/springdata/jpa/showcase/after/AccountRepositoryIntegrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2013 the original author or authors. + * Copyright 2011-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.showcase.after; +package example.springdata.jpa.showcase.after; import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; @@ -22,9 +22,10 @@ import java.util.List; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.jpa.showcase.AbstractShowcaseTest; -import org.springframework.data.jpa.showcase.core.Account; -import org.springframework.data.jpa.showcase.core.Customer; + +import example.springdata.jpa.showcase.AbstractShowcaseTest; +import example.springdata.jpa.showcase.core.Account; +import example.springdata.jpa.showcase.core.Customer; /** * Integration tests for Spring Data JPA {@link AccountRepository}. diff --git a/jpa/spring-data-jpa-showcase/src/test/java/org/springframework/data/jpa/showcase/after/CustomerRepositoryIntegrationTest.java b/jpa/spring-data-jpa-showcase/src/test/java/example/springdata/jpa/showcase/after/CustomerRepositoryIntegrationTest.java similarity index 87% rename from jpa/spring-data-jpa-showcase/src/test/java/org/springframework/data/jpa/showcase/after/CustomerRepositoryIntegrationTest.java rename to jpa/spring-data-jpa-showcase/src/test/java/example/springdata/jpa/showcase/after/CustomerRepositoryIntegrationTest.java index 41e6359c..0477ec58 100644 --- a/jpa/spring-data-jpa-showcase/src/test/java/org/springframework/data/jpa/showcase/after/CustomerRepositoryIntegrationTest.java +++ b/jpa/spring-data-jpa-showcase/src/test/java/example/springdata/jpa/showcase/after/CustomerRepositoryIntegrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2013 the original author or authors. + * Copyright 2011-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.showcase.after; +package example.springdata.jpa.showcase.after; +import static example.springdata.jpa.showcase.snippets.CustomerSpecifications.*; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; import static org.springframework.data.jpa.domain.Specifications.*; -import static org.springframework.data.jpa.showcase.snippets.CustomerSpecifications.*; import java.util.List; @@ -27,8 +27,9 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; -import org.springframework.data.jpa.showcase.AbstractShowcaseTest; -import org.springframework.data.jpa.showcase.core.Customer; + +import example.springdata.jpa.showcase.AbstractShowcaseTest; +import example.springdata.jpa.showcase.core.Customer; /** * Integration tests for Spring Data JPA {@link CustomerRepository}. diff --git a/jpa/spring-data-jpa-showcase/src/test/java/org/springframework/data/jpa/showcase/before/AccountServiceIntegrationTest.java b/jpa/spring-data-jpa-showcase/src/test/java/example/springdata/jpa/showcase/before/AccountServiceIntegrationTest.java similarity index 82% rename from jpa/spring-data-jpa-showcase/src/test/java/org/springframework/data/jpa/showcase/before/AccountServiceIntegrationTest.java rename to jpa/spring-data-jpa-showcase/src/test/java/example/springdata/jpa/showcase/before/AccountServiceIntegrationTest.java index 134d0123..c4fd99d7 100644 --- a/jpa/spring-data-jpa-showcase/src/test/java/org/springframework/data/jpa/showcase/before/AccountServiceIntegrationTest.java +++ b/jpa/spring-data-jpa-showcase/src/test/java/example/springdata/jpa/showcase/before/AccountServiceIntegrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2013 the original author or authors. + * Copyright 2011-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.showcase.before; +package example.springdata.jpa.showcase.before; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; @@ -22,9 +22,10 @@ import java.util.List; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.jpa.showcase.AbstractShowcaseTest; -import org.springframework.data.jpa.showcase.core.Account; -import org.springframework.data.jpa.showcase.core.Customer; + +import example.springdata.jpa.showcase.AbstractShowcaseTest; +import example.springdata.jpa.showcase.core.Account; +import example.springdata.jpa.showcase.core.Customer; /** * Integration test for {@link AccountService}. diff --git a/jpa/spring-data-jpa-showcase/src/test/java/org/springframework/data/jpa/showcase/before/CustomerServiceIntegrationTest.java b/jpa/spring-data-jpa-showcase/src/test/java/example/springdata/jpa/showcase/before/CustomerServiceIntegrationTest.java similarity index 86% rename from jpa/spring-data-jpa-showcase/src/test/java/org/springframework/data/jpa/showcase/before/CustomerServiceIntegrationTest.java rename to jpa/spring-data-jpa-showcase/src/test/java/example/springdata/jpa/showcase/before/CustomerServiceIntegrationTest.java index 2ada0d05..33671cdd 100644 --- a/jpa/spring-data-jpa-showcase/src/test/java/org/springframework/data/jpa/showcase/before/CustomerServiceIntegrationTest.java +++ b/jpa/spring-data-jpa-showcase/src/test/java/example/springdata/jpa/showcase/before/CustomerServiceIntegrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2013 the original author or authors. + * Copyright 2011-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.jpa.showcase.before; +package example.springdata.jpa.showcase.before; import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; @@ -22,8 +22,9 @@ import java.util.List; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.jpa.showcase.AbstractShowcaseTest; -import org.springframework.data.jpa.showcase.core.Customer; + +import example.springdata.jpa.showcase.AbstractShowcaseTest; +import example.springdata.jpa.showcase.core.Customer; /** * Integration test for {@link CustomerService}. diff --git a/mongodb/src/main/java/org/springframework/data/examples/mongodb/customer/Address.java b/mongodb/src/main/java/example/springdata/mongodb/customer/Address.java similarity index 94% rename from mongodb/src/main/java/org/springframework/data/examples/mongodb/customer/Address.java rename to mongodb/src/main/java/example/springdata/mongodb/customer/Address.java index 1f7e2a1f..62257d0b 100644 --- a/mongodb/src/main/java/org/springframework/data/examples/mongodb/customer/Address.java +++ b/mongodb/src/main/java/example/springdata/mongodb/customer/Address.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.examples.mongodb.customer; +package example.springdata.mongodb.customer; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/mongodb/src/main/java/org/springframework/data/examples/mongodb/customer/Customer.java b/mongodb/src/main/java/example/springdata/mongodb/customer/Customer.java similarity index 96% rename from mongodb/src/main/java/org/springframework/data/examples/mongodb/customer/Customer.java rename to mongodb/src/main/java/example/springdata/mongodb/customer/Customer.java index 18a6e0cf..12c44a58 100644 --- a/mongodb/src/main/java/org/springframework/data/examples/mongodb/customer/Customer.java +++ b/mongodb/src/main/java/example/springdata/mongodb/customer/Customer.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.examples.mongodb.customer; +package example.springdata.mongodb.customer; import lombok.Data; diff --git a/mongodb/src/main/java/org/springframework/data/examples/mongodb/customer/CustomerRepository.java b/mongodb/src/main/java/example/springdata/mongodb/customer/CustomerRepository.java similarity index 96% rename from mongodb/src/main/java/org/springframework/data/examples/mongodb/customer/CustomerRepository.java rename to mongodb/src/main/java/example/springdata/mongodb/customer/CustomerRepository.java index 81592d79..c872ab26 100644 --- a/mongodb/src/main/java/org/springframework/data/examples/mongodb/customer/CustomerRepository.java +++ b/mongodb/src/main/java/example/springdata/mongodb/customer/CustomerRepository.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.examples.mongodb.customer; +package example.springdata.mongodb.customer; import java.util.List; diff --git a/mongodb/src/main/java/org/springframework/data/examples/mongodb/shop/Invoice.java b/mongodb/src/main/java/example/springdata/mongodb/shop/Invoice.java similarity index 94% rename from mongodb/src/main/java/org/springframework/data/examples/mongodb/shop/Invoice.java rename to mongodb/src/main/java/example/springdata/mongodb/shop/Invoice.java index cc1a5fc4..3c5ed9de 100644 --- a/mongodb/src/main/java/org/springframework/data/examples/mongodb/shop/Invoice.java +++ b/mongodb/src/main/java/example/springdata/mongodb/shop/Invoice.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.examples.mongodb.shop; +package example.springdata.mongodb.shop; import java.util.List; diff --git a/mongodb/src/main/java/org/springframework/data/examples/mongodb/shop/LineItem.java b/mongodb/src/main/java/example/springdata/mongodb/shop/LineItem.java similarity index 95% rename from mongodb/src/main/java/org/springframework/data/examples/mongodb/shop/LineItem.java rename to mongodb/src/main/java/example/springdata/mongodb/shop/LineItem.java index ee3cc0b2..3f663884 100644 --- a/mongodb/src/main/java/org/springframework/data/examples/mongodb/shop/LineItem.java +++ b/mongodb/src/main/java/example/springdata/mongodb/shop/LineItem.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.examples.mongodb.shop; +package example.springdata.mongodb.shop; import lombok.Data; import lombok.RequiredArgsConstructor; diff --git a/mongodb/src/main/java/org/springframework/data/examples/mongodb/shop/Order.java b/mongodb/src/main/java/example/springdata/mongodb/shop/Order.java similarity index 96% rename from mongodb/src/main/java/org/springframework/data/examples/mongodb/shop/Order.java rename to mongodb/src/main/java/example/springdata/mongodb/shop/Order.java index 0b67d3ad..46b38392 100644 --- a/mongodb/src/main/java/org/springframework/data/examples/mongodb/shop/Order.java +++ b/mongodb/src/main/java/example/springdata/mongodb/shop/Order.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.examples.mongodb.shop; +package example.springdata.mongodb.shop; import java.util.ArrayList; import java.util.Date; diff --git a/mongodb/src/main/java/org/springframework/data/examples/mongodb/shop/OrderRepository.java b/mongodb/src/main/java/example/springdata/mongodb/shop/OrderRepository.java similarity index 94% rename from mongodb/src/main/java/org/springframework/data/examples/mongodb/shop/OrderRepository.java rename to mongodb/src/main/java/example/springdata/mongodb/shop/OrderRepository.java index f459ed78..6b112289 100644 --- a/mongodb/src/main/java/org/springframework/data/examples/mongodb/shop/OrderRepository.java +++ b/mongodb/src/main/java/example/springdata/mongodb/shop/OrderRepository.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.examples.mongodb.shop; +package example.springdata.mongodb.shop; import org.springframework.data.repository.CrudRepository; diff --git a/mongodb/src/main/java/org/springframework/data/examples/mongodb/shop/OrderRepositoryCustom.java b/mongodb/src/main/java/example/springdata/mongodb/shop/OrderRepositoryCustom.java similarity index 94% rename from mongodb/src/main/java/org/springframework/data/examples/mongodb/shop/OrderRepositoryCustom.java rename to mongodb/src/main/java/example/springdata/mongodb/shop/OrderRepositoryCustom.java index c3c795f4..e584c8fd 100644 --- a/mongodb/src/main/java/org/springframework/data/examples/mongodb/shop/OrderRepositoryCustom.java +++ b/mongodb/src/main/java/example/springdata/mongodb/shop/OrderRepositoryCustom.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.examples.mongodb.shop; +package example.springdata.mongodb.shop; /** * The interface for repository functionality that will be implemented manually. diff --git a/mongodb/src/main/java/org/springframework/data/examples/mongodb/shop/OrderRepositoryImpl.java b/mongodb/src/main/java/example/springdata/mongodb/shop/OrderRepositoryImpl.java similarity index 92% rename from mongodb/src/main/java/org/springframework/data/examples/mongodb/shop/OrderRepositoryImpl.java rename to mongodb/src/main/java/example/springdata/mongodb/shop/OrderRepositoryImpl.java index 868eff03..bbbc319c 100644 --- a/mongodb/src/main/java/org/springframework/data/examples/mongodb/shop/OrderRepositoryImpl.java +++ b/mongodb/src/main/java/example/springdata/mongodb/shop/OrderRepositoryImpl.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.examples.mongodb.shop; +package example.springdata.mongodb.shop; import static org.springframework.data.mongodb.core.aggregation.Aggregation.*; import static org.springframework.data.mongodb.core.query.Criteria.*; @@ -43,7 +43,7 @@ class OrderRepositoryImpl implements OrderRepositoryCustom { * to define arithmetical expressions. Note how we work with property names only and don't have to mitigate the nested * {@code $_id} fields MongoDB usually requires. * - * @see org.springframework.data.examples.mongodb.shop.OrderRepositoryCustom#getInvoiceFor(org.springframework.data.examples.mongodb.shop.Order) + * @see example.springdata.mongodb.shop.OrderRepositoryCustom#getInvoiceFor(example.springdata.mongodb.shop.Order) */ @Override public Invoice getInvoiceFor(Order order) { diff --git a/mongodb/src/test/java/org/springframework/data/examples/mongodb/TestConfiguration.java b/mongodb/src/test/java/example/springdata/mongodb/TestConfiguration.java similarity index 96% rename from mongodb/src/test/java/org/springframework/data/examples/mongodb/TestConfiguration.java rename to mongodb/src/test/java/example/springdata/mongodb/TestConfiguration.java index 86eee972..c84d0f0d 100644 --- a/mongodb/src/test/java/org/springframework/data/examples/mongodb/TestConfiguration.java +++ b/mongodb/src/test/java/example/springdata/mongodb/TestConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.examples.mongodb; +package example.springdata.mongodb; import org.springframework.context.annotation.Configuration; import org.springframework.data.mongodb.config.AbstractMongoConfiguration; diff --git a/mongodb/src/test/java/org/springframework/data/examples/mongodb/customer/CustomerRepositoryIntegrationTest.java b/mongodb/src/test/java/example/springdata/mongodb/customer/CustomerRepositoryIntegrationTest.java similarity index 96% rename from mongodb/src/test/java/org/springframework/data/examples/mongodb/customer/CustomerRepositoryIntegrationTest.java rename to mongodb/src/test/java/example/springdata/mongodb/customer/CustomerRepositoryIntegrationTest.java index 6d3528af..73fdb4f3 100644 --- a/mongodb/src/test/java/org/springframework/data/examples/mongodb/customer/CustomerRepositoryIntegrationTest.java +++ b/mongodb/src/test/java/example/springdata/mongodb/customer/CustomerRepositoryIntegrationTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.examples.mongodb.customer; +package example.springdata.mongodb.customer; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; @@ -24,7 +24,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.examples.mongodb.TestConfiguration; import org.springframework.data.mongodb.core.geo.Distance; import org.springframework.data.mongodb.core.geo.GeoResults; import org.springframework.data.mongodb.core.geo.Metrics; @@ -33,6 +32,8 @@ import org.springframework.data.querydsl.QSort; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import example.springdata.mongodb.TestConfiguration; + /** * Integration test for {@link CustomerRepository}. * diff --git a/mongodb/src/test/java/org/springframework/data/examples/mongodb/shop/OrderRepositoryIntegrationTests.java b/mongodb/src/test/java/example/springdata/mongodb/shop/OrderRepositoryIntegrationTests.java similarity index 94% rename from mongodb/src/test/java/org/springframework/data/examples/mongodb/shop/OrderRepositoryIntegrationTests.java rename to mongodb/src/test/java/example/springdata/mongodb/shop/OrderRepositoryIntegrationTests.java index 4edb0cff..e37dc9bf 100644 --- a/mongodb/src/test/java/org/springframework/data/examples/mongodb/shop/OrderRepositoryIntegrationTests.java +++ b/mongodb/src/test/java/example/springdata/mongodb/shop/OrderRepositoryIntegrationTests.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.examples.mongodb.shop; +package example.springdata.mongodb.shop; import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.number.IsCloseTo.*; @@ -25,10 +25,11 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.examples.mongodb.TestConfiguration; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import example.springdata.mongodb.TestConfiguration; + /** * Integration tests for {@link OrderRepository}. *