Git Product home page Git Product logo

spring-boot-jpa-rest-demo-filter-paging-sorting's Introduction

spring-boot-jpa-rest-demo-filter-paging-sorting

An example application using Spring boot MVC, Spring Data JPA with the ability to do filter, pagination and sorting.

Filter

REST APIs handles filter as followed in the demo application.

It parses and converts the following notions as org.springframework.data.jpa.domain.Specification. The operation and specification mapping are kept as operation to lambda functions.

Symbol Operation example filter query param
eq Equals city=eq:Sydney
neq Not Equals country=neq:uk
gt Greater Than amount=gt:10000
gte Greater Than or equals to amount=gte:10000
lt Less Than amount=lt:10000
lte Less Than or equals to amount=lte:10000
in IN country=in:uk, usa, au
nin Not IN country=nin:fr, de, nz
btn Between joiningDate=btn:2018-01-01, 2016-01-01
like Like firstName=like:John

Paging

The API's query params 'pageNumber' & 'pageSize' are converted to org.springframework.data.domain.PageRequest

Sample .....?pageSize=10&pageNumber=2

Sorting

'sort' query param with comma separated attributes prefixed with either '+' (ASC Order) or '-' (DESC Order) are converted to org.springframework.data.domain.Sort with org.springframework.data.domain.PageRequest

Example: .....?sort=+salary,+joiningDate

Technology stack

  • Spring Boot
  • Spring MVC
  • Spring Data JPA
  • Hibernate 5.x
  • Swagger
  • Spring Boot Test/JUnit/Mockito/RestAssured

Prerequisites

  • JDK 8
  • Maven

Run

mvn spring-boot:run

spring-boot-jpa-rest-demo-filter-paging-sorting's People

Contributors

vijjayy81 avatar

Watchers

James Cloos avatar Satish Kotadiya avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.