diff --git a/spring-data-rest/src/main/java/com/baeldung/config/DbConfig.java b/spring-data-rest/src/main/java/com/baeldung/config/DbConfig.java index 26d882d6a0..05fa27bbff 100644 --- a/spring-data-rest/src/main/java/com/baeldung/config/DbConfig.java +++ b/spring-data-rest/src/main/java/com/baeldung/config/DbConfig.java @@ -64,22 +64,22 @@ public class DbConfig { @Configuration @Profile("h2") -@PropertySource("persistence-h2.properties") +@PropertySource("classpath:persistence-h2.properties") class H2Config {} @Configuration @Profile("hsqldb") -@PropertySource("persistence-hsqldb.properties") +@PropertySource("classpath:persistence-hsqldb.properties") class HsqldbConfig {} @Configuration @Profile("derby") -@PropertySource("persistence-derby.properties") +@PropertySource("classpath:persistence-derby.properties") class DerbyConfig {} @Configuration @Profile("sqlite") -@PropertySource("persistence-sqlite.properties") +@PropertySource("classpath:persistence-sqlite.properties") class SqliteConfig {} diff --git a/spring-data-rest/src/main/java/com/baeldung/models/Subject.java b/spring-data-rest/src/main/java/com/baeldung/models/Subject.java new file mode 100644 index 0000000000..b3b9a5b0a0 --- /dev/null +++ b/spring-data-rest/src/main/java/com/baeldung/models/Subject.java @@ -0,0 +1,37 @@ +package com.baeldung.models; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +public class Subject { + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + private long id; + + @Column(nullable = false) + private String name; + + public Subject() { + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/spring-data-rest/src/main/java/com/baeldung/repositories/SubjectRepository.java b/spring-data-rest/src/main/java/com/baeldung/repositories/SubjectRepository.java new file mode 100644 index 0000000000..a91ae2d505 --- /dev/null +++ b/spring-data-rest/src/main/java/com/baeldung/repositories/SubjectRepository.java @@ -0,0 +1,15 @@ +package com.baeldung.repositories; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RestResource; +import com.baeldung.models.Subject; + +public interface SubjectRepository extends PagingAndSortingRepository { + + @RestResource(path = "nameContains") + public Page findByNameContaining(@Param("name") String name, Pageable p); + +} \ No newline at end of file