Skip to content

Commit 786ce2d

Browse files
committed
#149 - Polishing.
Renamed repository folder to repositories. Tweaked package name to reflect module name. Polished formatting in readme. Switched to Spring Boot version property for 1.7 RC1 upgrade. Original pull request: #162.
1 parent 5a25e80 commit 786ce2d

File tree

11 files changed

+73
-104
lines changed

11 files changed

+73
-104
lines changed

redis/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<module>cluster-sentinel</module>
2121
<module>example</module>
2222
<module>cluster</module>
23-
<module>repository</module>
23+
<module>repositories</module>
2424
</modules>
2525

2626
<dependencies>
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ Redis Repository support allows to convert, store, retrieve and index entities w
1010
@RedisHash("persons")
1111
class Person {
1212

13-
@Id String id;
14-
15-
@Indexed String firstname;
16-
@Indexed String lastname;
13+
@Id String id;
1714

18-
Gender gender;
19-
Address address;
15+
@Indexed String firstname;
16+
@Indexed String lastname;
2017

21-
@Reference List<Person> children;
18+
Gender gender;
19+
Address address;
20+
21+
@Reference List<Person> children;
2222
}
2323
```
2424

@@ -81,36 +81,36 @@ The below configuration uses [Jedis](https://github.com/xetorthio/jedis) to conn
8181
@EnableRedisRepositories
8282
class AppConfig {
8383

84-
@Bean
85-
RedisConnectionFactory connectionFactory() {
86-
return new JedisConnectionFactory();
87-
}
84+
@Bean
85+
RedisConnectionFactory connectionFactory() {
86+
return new JedisConnectionFactory();
87+
}
8888

89-
@Bean
90-
RedisTemplate<?, ?> redisTemplate(RedisConnectionFactory connectionFactory) {
89+
@Bean
90+
RedisTemplate<?, ?> redisTemplate(RedisConnectionFactory connectionFactory) {
9191

92-
RedisTemplate<byte[], byte[]> template = new RedisTemplate<byte[], byte[]>();
93-
template.setConnectionFactory(connectionFactory);
92+
RedisTemplate<byte[], byte[]> template = new RedisTemplate<byte[], byte[]>();
93+
template.setConnectionFactory(connectionFactory);
9494

95-
return template;
96-
}
95+
return template;
96+
}
9797
}
9898
```
9999

100-
Having the infrastructure in place you can go on declaring and using the `Repository` interface.
100+
Having the infrastructure in place you can go on declaring and using the `Repository` interface.
101101

102102
```java
103103
interface PersonRepository extends CrudRepository<Person, String> {
104104

105-
List<Person> findByLastname(String lastname);
105+
List<Person> findByLastname(String lastname);
106106

107-
Page<Person> findByLastname(String lastname, Pageable page);
107+
Page<Person> findByLastname(String lastname, Pageable page);
108108

109-
List<Person> findByFirstnameAndLastname(String firstname, String lastname);
109+
List<Person> findByFirstnameAndLastname(String firstname, String lastname);
110110

111-
List<Person> findByFirstnameOrLastname(String firstname, String lastname);
111+
List<Person> findByFirstnameOrLastname(String firstname, String lastname);
112112

113-
List<Person> findByAddress_City(String city);
113+
List<Person> findByAddress_City(String city);
114114
}
115115
```
116116

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
44

5-
<artifactId>spring-data-redis-repository-example</artifactId>
5+
<artifactId>spring-data-redis-repositories-example</artifactId>
66
<name>Spring Data Redis - Repository Support Example</name>
77

88
<parent>
@@ -12,39 +12,31 @@
1212
<relativePath>../pom.xml</relativePath>
1313
</parent>
1414

15+
<properties>
16+
<spring-data-releasetrain.version>Hopper-RC1</spring-data-releasetrain.version>
17+
</properties>
18+
1519
<dependencies>
1620

1721
<dependency>
1822
<groupId>org.springframework.boot</groupId>
1923
<artifactId>spring-boot-starter-data-redis</artifactId>
2024
</dependency>
25+
2126
<dependency>
2227
<groupId>${project.groupId}</groupId>
2328
<artifactId>spring-data-redis-example-utils</artifactId>
2429
<version>${project.version}</version>
2530
<scope>test</scope>
2631
</dependency>
32+
2733
<dependency>
2834
<groupId>com.github.kstyrc</groupId>
2935
<artifactId>embedded-redis</artifactId>
3036
<version>0.6</version>
3137
<scope>test</scope>
3238
</dependency>
33-
<dependency>
34-
<groupId>org.springframework.data</groupId>
35-
<artifactId>spring-data-redis</artifactId>
36-
<version>1.7.0.RC1</version>
37-
</dependency>
38-
<dependency>
39-
<groupId>org.springframework.data</groupId>
40-
<artifactId>spring-data-keyvalue</artifactId>
41-
<version>1.1.0.RC1</version>
42-
</dependency>
43-
<dependency>
44-
<groupId>org.springframework.data</groupId>
45-
<artifactId>spring-data-commons</artifactId>
46-
<version>1.12.0.RC1</version>
47-
</dependency>
39+
4840
</dependencies>
4941

5042
</project>

redis/repository/src/main/java/example/springdata/redis/repositories/Address.java renamed to redis/repositories/src/main/java/example/springdata/redis/repositories/Address.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package example.springdata.redis.domain;
16+
package example.springdata.redis.repositories;
1717

1818
import lombok.Data;
1919
import lombok.EqualsAndHashCode;

redis/repository/src/main/java/example/springdata/redis/repositories/ApplicationConfiguration.java renamed to redis/repositories/src/main/java/example/springdata/redis/repositories/ApplicationConfiguration.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package example.springdata.redis;
16+
package example.springdata.redis.repositories;
1717

1818
import org.springframework.context.annotation.Bean;
1919
import org.springframework.context.annotation.Configuration;
@@ -27,22 +27,13 @@
2727
*/
2828
@Configuration
2929
@EnableRedisRepositories
30-
public class AppConfig {
30+
public class ApplicationConfiguration {
3131

32-
/**
33-
* {@link RedisConnectionFactory} to be used when connecting to redis.
34-
*
35-
* @return
36-
*/
3732
@Bean
3833
RedisConnectionFactory connectionFactory() {
3934
return new JedisConnectionFactory();
4035
}
4136

42-
/**
43-
* @param connectionFactory
44-
* @return
45-
*/
4637
@Bean
4738
RedisTemplate<?, ?> redisTemplate(RedisConnectionFactory connectionFactory) {
4839

@@ -51,5 +42,4 @@ RedisConnectionFactory connectionFactory() {
5142

5243
return template;
5344
}
54-
5545
}

redis/repository/src/main/java/example/springdata/redis/repositories/Gender.java renamed to redis/repositories/src/main/java/example/springdata/redis/repositories/Gender.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package example.springdata.redis.domain;
16+
package example.springdata.redis.repositories;
1717

1818
/**
1919
* @author Christoph Strobl

redis/repository/src/main/java/example/springdata/redis/repositories/Person.java renamed to redis/repositories/src/main/java/example/springdata/redis/repositories/Person.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package example.springdata.redis.domain;
17-
18-
import java.lang.reflect.Field;
19-
import java.util.List;
16+
package example.springdata.redis.repositories;
2017

2118
import lombok.Data;
2219
import lombok.EqualsAndHashCode;
20+
import lombok.NoArgsConstructor;
21+
22+
import java.lang.reflect.Field;
23+
import java.util.List;
2324

2425
import org.springframework.data.annotation.Id;
2526
import org.springframework.data.annotation.Reference;
@@ -54,10 +55,12 @@
5455
@Data
5556
@EqualsAndHashCode(exclude = { "children" })
5657
@RedisHash("persons")
58+
@NoArgsConstructor
5759
class Person {
5860

5961
/**
60-
* The {@literal id} and {@link RedisHash#toString()} build up the {@literal key} for the Redis {@literal HASH}. <br />
62+
* The {@literal id} and {@link RedisHash#toString()} build up the {@literal key} for the Redis {@literal HASH}.
63+
* <br />
6164
*
6265
* <pre>
6366
* <code>
@@ -106,12 +109,10 @@ class Person {
106109
*/
107110
private @Reference List<Person> children;
108111

109-
public Person() {}
110-
111112
public Person(String firstname, String lastname, Gender gender) {
113+
112114
this.firstname = firstname;
113115
this.lastname = lastname;
114116
this.gender = gender;
115117
}
116-
117118
}

redis/repository/src/main/java/example/springdata/redis/repositories/PersonRepository.java renamed to redis/repositories/src/main/java/example/springdata/redis/repositories/PersonRepository.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package example.springdata.redis.domain;
16+
package example.springdata.redis.repositories;
1717

1818
import java.util.List;
1919

@@ -35,5 +35,4 @@ interface PersonRepository extends CrudRepository<Person, String> {
3535
List<Person> findByFirstnameOrLastname(String firstname, String lastname);
3636

3737
List<Person> findByAddress_City(String city);
38-
3938
}

0 commit comments

Comments
 (0)