File tree Expand file tree Collapse file tree 3 files changed +56
-4
lines changed
spring-data-rest/src/main/java/com/baeldung Expand file tree Collapse file tree 3 files changed +56
-4
lines changed Original file line number Diff line number Diff line change @@ -64,22 +64,22 @@ final Properties additionalProperties() {
6464
6565@ Configuration
6666@ Profile ("h2" )
67- @ PropertySource ("persistence-h2.properties" )
67+ @ PropertySource ("classpath: persistence-h2.properties" )
6868class H2Config {}
6969
7070@ Configuration
7171@ Profile ("hsqldb" )
72- @ PropertySource ("persistence-hsqldb.properties" )
72+ @ PropertySource ("classpath: persistence-hsqldb.properties" )
7373class HsqldbConfig {}
7474
7575
7676@ Configuration
7777@ Profile ("derby" )
78- @ PropertySource ("persistence-derby.properties" )
78+ @ PropertySource ("classpath: persistence-derby.properties" )
7979class DerbyConfig {}
8080
8181
8282@ Configuration
8383@ Profile ("sqlite" )
84- @ PropertySource ("persistence-sqlite.properties" )
84+ @ PropertySource ("classpath: persistence-sqlite.properties" )
8585class SqliteConfig {}
Original file line number Diff line number Diff line change 1+ package com .baeldung .models ;
2+
3+ import javax .persistence .Column ;
4+ import javax .persistence .Entity ;
5+ import javax .persistence .GeneratedValue ;
6+ import javax .persistence .GenerationType ;
7+ import javax .persistence .Id ;
8+
9+ @ Entity
10+ public class Subject {
11+
12+ @ Id
13+ @ GeneratedValue (strategy =GenerationType .IDENTITY )
14+ private long id ;
15+
16+ @ Column (nullable = false )
17+ private String name ;
18+
19+ public Subject () {
20+ }
21+
22+ public long getId () {
23+ return id ;
24+ }
25+
26+ public void setId (long id ) {
27+ this .id = id ;
28+ }
29+
30+ public String getName () {
31+ return name ;
32+ }
33+
34+ public void setName (String name ) {
35+ this .name = name ;
36+ }
37+ }
Original file line number Diff line number Diff line change 1+ package com .baeldung .repositories ;
2+
3+ import org .springframework .data .domain .Page ;
4+ import org .springframework .data .domain .Pageable ;
5+ import org .springframework .data .repository .PagingAndSortingRepository ;
6+ import org .springframework .data .repository .query .Param ;
7+ import org .springframework .data .rest .core .annotation .RestResource ;
8+ import com .baeldung .models .Subject ;
9+
10+ public interface SubjectRepository extends PagingAndSortingRepository <Subject , Long > {
11+
12+ @ RestResource (path = "nameContains" )
13+ public Page <Subject > findByNameContaining (@ Param ("name" ) String name , Pageable p );
14+
15+ }
You can’t perform that action at this time.
0 commit comments