[BAEL-10781] - Added code for spring data rest pagination
This commit is contained in:
parent
4d90ca6c58
commit
d16167ea63
@ -64,22 +64,22 @@ public class DbConfig {
|
|||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@Profile("h2")
|
@Profile("h2")
|
||||||
@PropertySource("persistence-h2.properties")
|
@PropertySource("classpath:persistence-h2.properties")
|
||||||
class H2Config {}
|
class H2Config {}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@Profile("hsqldb")
|
@Profile("hsqldb")
|
||||||
@PropertySource("persistence-hsqldb.properties")
|
@PropertySource("classpath:persistence-hsqldb.properties")
|
||||||
class HsqldbConfig {}
|
class HsqldbConfig {}
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@Profile("derby")
|
@Profile("derby")
|
||||||
@PropertySource("persistence-derby.properties")
|
@PropertySource("classpath:persistence-derby.properties")
|
||||||
class DerbyConfig {}
|
class DerbyConfig {}
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@Profile("sqlite")
|
@Profile("sqlite")
|
||||||
@PropertySource("persistence-sqlite.properties")
|
@PropertySource("classpath:persistence-sqlite.properties")
|
||||||
class SqliteConfig {}
|
class SqliteConfig {}
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -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<Subject, Long> {
|
||||||
|
|
||||||
|
@RestResource(path = "nameContains")
|
||||||
|
public Page<Subject> findByNameContaining(@Param("name") String name, Pageable p);
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user