Changed top-level package to example.springdata.
Added missing Apache license headers and adapted copyright range.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 <em>not</em>
|
||||
* automatically add the {@code orm.xml} <em>if</em> 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.
|
||||
*
|
||||
@@ -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;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
* Package showing auditing support with Spring Data repositories.
|
||||
*/
|
||||
package org.springframework.data.jpa.example.repository.auditing;
|
||||
package example.springdata.jpa.auditing;
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<User> myCustomBatchOperation() {
|
||||
|
||||
@@ -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<User> myCustomBatchOperation() {
|
||||
return getJdbcTemplate().query(COMPLICATED_SQL, new UserRowMapper());
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Package showing a repository interface to use basic query method execution functionality as well as <em>customized</em> repository functionality.
|
||||
*/
|
||||
package org.springframework.data.jpa.example.repository.custom;
|
||||
package example.springdata.jpa.custom;
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
@@ -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}
|
||||
*
|
||||
@@ -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}.
|
||||
*
|
||||
@@ -17,4 +17,4 @@
|
||||
*
|
||||
* @author Thomas Darimont
|
||||
*/
|
||||
package org.springframework.data.jpa.example.repository.basics;
|
||||
package example.springdata.jpa.basics;
|
||||
@@ -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.
|
||||
*
|
||||
@@ -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.*;
|
||||
|
||||
@@ -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}.
|
||||
*
|
||||
@@ -2,7 +2,7 @@
|
||||
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
|
||||
|
||||
<persistence-unit name="jpa.sample.plain">
|
||||
<class>org.springframework.data.jpa.example.repository.simple.User</class>
|
||||
<class>example.springdata.jpa.simple.User</class>
|
||||
<properties>
|
||||
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
|
||||
<property name="hibernate.connection.url" value="jdbc:hsqldb:mem:spring" />
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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() {
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
@@ -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.
|
||||
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.
|
||||
@@ -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<Account, Long> {
|
||||
|
||||
/**
|
||||
* Returns all accounts belonging to the given {@link Customer}.
|
||||
*
|
||||
* @param customer
|
||||
* @return
|
||||
*/
|
||||
List<Account> findByCustomer(Customer customer);
|
||||
}
|
||||
@@ -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<Customer, Long>, JpaSpecificationExecutor<Customer> {
|
||||
|
||||
/**
|
||||
* Returns a page of {@link Customer}s with the given lastname.
|
||||
*
|
||||
* @param lastname
|
||||
* @param pageable
|
||||
* @return
|
||||
*/
|
||||
Page<Customer> findByLastname(String lastname, Pageable pageable);
|
||||
}
|
||||
@@ -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<Account> findByCustomer(Customer customer);
|
||||
}
|
||||
@@ -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<Account> findByCustomer(Customer customer) {
|
||||
|
||||
TypedQuery<Account> query = em.createQuery("select a from Account a where a.customer = ?1", Account.class);
|
||||
query.setParameter(1, customer);
|
||||
|
||||
return query.getResultList();
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
@@ -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<Customer> 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<Customer> 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<Customer> findByLastname(String lastname, int page, int pageSize) {
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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<Account, Long> {
|
||||
|
||||
/**
|
||||
* Returns all accounts belonging to the given {@link Customer}.
|
||||
*
|
||||
* @param customer
|
||||
* @return
|
||||
*/
|
||||
List<Account> findByCustomer(Customer customer);
|
||||
}
|
||||
@@ -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<Customer, Long>, JpaSpecificationExecutor<Customer> {
|
||||
|
||||
/**
|
||||
* Returns a page of {@link Customer}s with the given lastname.
|
||||
*
|
||||
* @param lastname
|
||||
* @param pageable
|
||||
* @return
|
||||
*/
|
||||
Page<Customer> findByLastname(String lastname, Pageable pageable);
|
||||
}
|
||||
@@ -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<Account> findByCustomer(Customer customer);
|
||||
}
|
||||
@@ -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<Account> findByCustomer(Customer customer) {
|
||||
|
||||
TypedQuery<Account> query = em.createQuery("select a from Account a where a.customer = ?1", Account.class);
|
||||
query.setParameter(1, customer);
|
||||
|
||||
return query.getResultList();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -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<Account, Long>, AccountRepositoryCustom,
|
||||
QueryDslPredicateExecutor<Account> {
|
||||
|
||||
/**
|
||||
* Returns all accounts belonging to the given {@link Customer}.
|
||||
*
|
||||
* @param customer
|
||||
* @return
|
||||
*/
|
||||
List<Account> findByCustomer(Customer customer);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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<Account> query = cb.createQuery(Account.class);
|
||||
Root<Account> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -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<Account, Long>, AccountRepositoryCustom,
|
||||
QueryDslPredicateExecutor<Account> {
|
||||
|
||||
/**
|
||||
* Returns all accounts belonging to the given {@link Customer}.
|
||||
*
|
||||
* @param customer
|
||||
* @return
|
||||
*/
|
||||
List<Account> findByCustomer(Customer customer);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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<Account> query = cb.createQuery(Account.class);
|
||||
Root<Account> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<bean id="accountDaoImpl" class="org.springframework.data.jpa.showcase.after.AccountDaoJdbcImpl">
|
||||
<bean id="accountDaoImpl" class="example.springdata.jpa.showcase.after.AccountDaoJdbcImpl">
|
||||
<property name="template">
|
||||
<bean class="org.springframework.jdbc.core.JdbcTemplate">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
|
||||
@@ -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<Account> findAll = accountRepository.findAll(expiresBefore(new LocalDate(2011, 3, 1)));
|
||||
|
||||
assertThat(findAll, hasItem(expired));
|
||||
assertThat(findAll, not(hasItem(valid)));
|
||||
}
|
||||
}
|
||||
@@ -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<Customer> result = repository.findAll(where(accountExpiresBefore(expiryLimit)));
|
||||
|
||||
assertThat(result.size(), is(1));
|
||||
assertThat(result, hasItems(dave));
|
||||
}
|
||||
}
|
||||
@@ -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<Account> findAll = accountRepository.findAll(expiresBefore(new LocalDate(2011, 3, 1)));
|
||||
|
||||
assertThat(findAll, hasItem(expired));
|
||||
assertThat(findAll, not(hasItem(valid)));
|
||||
}
|
||||
}
|
||||
@@ -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<Customer> result = repository.findAll(where(accountExpiresBefore(expiryLimit)));
|
||||
|
||||
assertThat(result.size(), is(1));
|
||||
assertThat(result, hasItems(dave));
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
*/
|
||||
@@ -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}.
|
||||
@@ -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}.
|
||||
@@ -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}.
|
||||
@@ -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}.
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
@@ -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) {
|
||||
@@ -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;
|
||||
@@ -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}.
|
||||
*
|
||||
@@ -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}.
|
||||
*
|
||||
Reference in New Issue
Block a user