Skip to content

Commit 797db3e

Browse files
committed
#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.
1 parent a50a345 commit 797db3e

File tree

7 files changed

+35
-22
lines changed

7 files changed

+35
-22
lines changed

jpa/example/src/main/java/example/springdata/jpa/custom/UserRepository.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2014 the original author or authors.
2+
* Copyright 2013-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -55,6 +55,6 @@ public interface UserRepository extends CrudRepository<User, Long>, UserReposito
5555
* @param firstname
5656
* @return
5757
*/
58-
@Query("select u from User u where u.firstname = ?1")
58+
@Query("select u from User u where u.firstname = :firstname")
5959
List<User> findByFirstname(String firstname);
6060
}

jpa/example/src/main/java/example/springdata/jpa/simple/SimpleUserRepository.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2014 the original author or authors.
2+
* Copyright 2013-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@
2222
import org.springframework.data.domain.Sort;
2323
import org.springframework.data.jpa.repository.Query;
2424
import org.springframework.data.repository.CrudRepository;
25-
import org.springframework.data.repository.query.Param;
2625

2726
import com.google.common.base.Optional;
2827

@@ -63,19 +62,18 @@ public interface SimpleUserRepository extends CrudRepository<User, Long> {
6362
* @param firstname
6463
* @return
6564
*/
66-
@Query("select u from User u where u.firstname = ?")
65+
@Query("select u from User u where u.firstname = :firstname")
6766
List<User> findByFirstname(String firstname);
6867

6968
/**
70-
* Returns all users with the given name as first- or lastname. Makes use of the {@link Param} annotation to use named
71-
* parameters in queries. This makes the query to method relation much more refactoring safe as the order of the
72-
* method parameters is completely irrelevant.
69+
* Returns all users with the given name as first- or lastname. This makes the query to method relation much more
70+
* refactoring safe as the order of the method parameters is completely irrelevant.
7371
*
7472
* @param name
7573
* @return
7674
*/
7775
@Query("select u from User u where u.firstname = :name or u.lastname = :name")
78-
List<User> findByFirstnameOrLastname(@Param("name") String name);
76+
List<User> findByFirstnameOrLastname(String name);
7977

8078
/**
8179
* 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> {
126124
* @return
127125
*/
128126
@Query("select u from User u where u.firstname = :#{#user.firstname} or u.lastname = :#{#user.lastname}")
129-
Iterable<User> findByFirstnameOrLastname(@Param("user") User user);
127+
Iterable<User> findByFirstnameOrLastname(User user);
130128
}

jpa/jpa21/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,9 @@
1010

1111
<artifactId>spring-data-jpa-jpa21</artifactId>
1212
<name>Spring Data JPA - JPA 2.1 specific features</name>
13+
14+
<properties>
15+
<spring-data-releasetrain.version>Fowler-BUILD-SNAPSHOT</spring-data-releasetrain.version>
16+
</properties>
1317

1418
</project>

jpa/jpa21/src/main/java/example/springdata/jpa/storedprocedures/UserRepository.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013 the original author or authors.
2+
* Copyright 2013-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@
1919

2020
import org.springframework.data.jpa.repository.query.Procedure;
2121
import org.springframework.data.repository.CrudRepository;
22-
import org.springframework.data.repository.query.Param;
2322

2423
/**
2524
* 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> {
3635
* @see User
3736
*/
3837
@Procedure(name = "User.plus1")
39-
Integer plus1BackedByOtherNamedStoredProcedure(@Param("arg") Integer arg);
38+
Integer plus1BackedByOtherNamedStoredProcedure(Integer arg);
4039

4140
/**
4241
* Directly map the method to the stored procedure in the database (to avoid the annotation madness on your domain

pom.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,22 @@
7272

7373
</dependencies>
7474

75+
<build>
76+
<plugins>
77+
<plugin>
78+
<groupId>org.apache.maven.plugins</groupId>
79+
<artifactId>maven-compiler-plugin</artifactId>
80+
<version>3.1</version>
81+
<configuration>
82+
<source>${java.version}</source>
83+
<target>${java.version}</target>
84+
<compilerArgument>-parameters</compilerArgument>
85+
</configuration>
86+
</plugin>
87+
</plugins>
88+
</build>
89+
90+
7591
<repositories>
7692
<repository>
7793
<id>spring-libs-snapshot</id>

rest/starbucks/src/main/java/example/stores/StoreApp.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014 the original author or authors.
2+
* Copyright 2014-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,16 +16,14 @@
1616
package example.stores;
1717

1818
import org.springframework.boot.SpringApplication;
19-
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
20-
import org.springframework.context.annotation.ComponentScan;
19+
import org.springframework.boot.autoconfigure.SpringBootApplication;
2120

2221
/**
2322
* Spring configuration class main application bootstrap point.
2423
*
2524
* @author Oliver Gierke
2625
*/
27-
@EnableAutoConfiguration
28-
@ComponentScan
26+
@SpringBootApplication
2927
public class StoreApp {
3028

3129
public static void main(String[] args) {

rest/starbucks/src/main/java/example/stores/StoreRepository.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014 the original author or authors.
2+
* Copyright 2014-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@
2020
import org.springframework.data.geo.Distance;
2121
import org.springframework.data.geo.Point;
2222
import org.springframework.data.repository.PagingAndSortingRepository;
23-
import org.springframework.data.repository.query.Param;
2423
import org.springframework.data.rest.core.annotation.RestResource;
2524

2625
/**
@@ -32,6 +31,5 @@
3231
public interface StoreRepository extends PagingAndSortingRepository<Store, String> {
3332

3433
@RestResource(rel = "by-location")
35-
Page<Store> findByAddressLocationNear(//
36-
@Param("location") Point location, @Param("distance") Distance distance, Pageable pageable);
34+
Page<Store> findByAddressLocationNear(Point location, Distance distance, Pageable pageable);
3735
}

0 commit comments

Comments
 (0)