#53 - Enable -parameters for compilation.
Removed obsolete @Param annotations from repository interfaces. Upgraded to Fowler snapshots for JPA 2.1 examples as we need a fix in derived stored procedure execution to work correctly. Related issues: DATAJPA-681.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
* Copyright 2013-2015 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.
|
||||
@@ -55,6 +55,6 @@ public interface UserRepository extends CrudRepository<User, Long>, UserReposito
|
||||
* @param firstname
|
||||
* @return
|
||||
*/
|
||||
@Query("select u from User u where u.firstname = ?1")
|
||||
@Query("select u from User u where u.firstname = :firstname")
|
||||
List<User> findByFirstname(String firstname);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
* Copyright 2013-2015 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.
|
||||
@@ -22,7 +22,6 @@ import org.springframework.data.domain.Slice;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
@@ -63,19 +62,18 @@ public interface SimpleUserRepository extends CrudRepository<User, Long> {
|
||||
* @param firstname
|
||||
* @return
|
||||
*/
|
||||
@Query("select u from User u where u.firstname = ?")
|
||||
@Query("select u from User u where u.firstname = :firstname")
|
||||
List<User> findByFirstname(String firstname);
|
||||
|
||||
/**
|
||||
* Returns all users with the given name as first- or lastname. Makes use of the {@link Param} annotation to use named
|
||||
* parameters in queries. This makes the query to method relation much more refactoring safe as the order of the
|
||||
* method parameters is completely irrelevant.
|
||||
* Returns all users with the given name as first- or lastname. This makes the query to method relation much more
|
||||
* refactoring safe as the order of the method parameters is completely irrelevant.
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
@Query("select u from User u where u.firstname = :name or u.lastname = :name")
|
||||
List<User> findByFirstnameOrLastname(@Param("name") String name);
|
||||
List<User> findByFirstnameOrLastname(String name);
|
||||
|
||||
/**
|
||||
* Returns the total number of entries deleted as their lastnames match the given one.
|
||||
@@ -126,5 +124,5 @@ public interface SimpleUserRepository extends CrudRepository<User, Long> {
|
||||
* @return
|
||||
*/
|
||||
@Query("select u from User u where u.firstname = :#{#user.firstname} or u.lastname = :#{#user.lastname}")
|
||||
Iterable<User> findByFirstnameOrLastname(@Param("user") User user);
|
||||
Iterable<User> findByFirstnameOrLastname(User user);
|
||||
}
|
||||
|
||||
@@ -10,5 +10,9 @@
|
||||
|
||||
<artifactId>spring-data-jpa-jpa21</artifactId>
|
||||
<name>Spring Data JPA - JPA 2.1 specific features</name>
|
||||
|
||||
<properties>
|
||||
<spring-data-releasetrain.version>Fowler-BUILD-SNAPSHOT</spring-data-releasetrain.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
* Copyright 2013-2015 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.
|
||||
@@ -19,7 +19,6 @@ import javax.persistence.EntityManager;
|
||||
|
||||
import org.springframework.data.jpa.repository.query.Procedure;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
/**
|
||||
* Simple repository interface for {@link User} instances. The interface is used to declare so called query methods,
|
||||
@@ -36,7 +35,7 @@ public interface UserRepository extends CrudRepository<User, Long> {
|
||||
* @see User
|
||||
*/
|
||||
@Procedure(name = "User.plus1")
|
||||
Integer plus1BackedByOtherNamedStoredProcedure(@Param("arg") Integer arg);
|
||||
Integer plus1BackedByOtherNamedStoredProcedure(Integer arg);
|
||||
|
||||
/**
|
||||
* Directly map the method to the stored procedure in the database (to avoid the annotation madness on your domain
|
||||
|
||||
16
pom.xml
16
pom.xml
@@ -72,6 +72,22 @@
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<compilerArgument>-parameters</compilerArgument>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-libs-snapshot</id>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-2015 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.
|
||||
@@ -16,16 +16,14 @@
|
||||
package example.stores;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* Spring configuration class main application bootstrap point.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@EnableAutoConfiguration
|
||||
@ComponentScan
|
||||
@SpringBootApplication
|
||||
public class StoreApp {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-2015 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.
|
||||
@@ -20,7 +20,6 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.geo.Distance;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.data.rest.core.annotation.RestResource;
|
||||
|
||||
/**
|
||||
@@ -32,6 +31,5 @@ import org.springframework.data.rest.core.annotation.RestResource;
|
||||
public interface StoreRepository extends PagingAndSortingRepository<Store, String> {
|
||||
|
||||
@RestResource(rel = "by-location")
|
||||
Page<Store> findByAddressLocationNear(//
|
||||
@Param("location") Point location, @Param("distance") Distance distance, Pageable pageable);
|
||||
Page<Store> findByAddressLocationNear(Point location, Distance distance, Pageable pageable);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user