Git Product home page Git Product logo

spring-repository-plus's Introduction

中文版

spring-repository-plus

https://github.com/ZhongjunTian/spring-repository-plus This is actually a good implementation of spring JPA Specification interface, it makes front-end having full control of filtering data with very little back-end code.

Querying with spring-repository-plus is as simple as:

or

Here is ALL your back-end code

    @PostMapping("/persons")
    public List<Person> filter(@RequestBody Filter filter){
        return selectFrom(personRepository).leftJoin("address").where(filter).findAll();
    }
    public interface PersonRepository extends JpaRepository<Person, Long>,JpaSpecificationExecutor {
    }

But with such little code, you can also filter data by ANY complex logic (and, or) and ANY operations (equal, startswith, endswith, greaterthan...)

The example below is equivalent to lastName='Tian' AND (address.city='Dallas' OR address.city like 'San%')

or

Table definition

CREATE TABLE PERSON (
	id BIGINT GENERATED BY DEFAULT AS IDENTITY,
	first_name varchar(255) not null,
	last_name varchar(255) not null,
	address_id int null
);
CREATE TABLE ADDRESS (
	id BIGINT GENERATED BY DEFAULT AS IDENTITY,
	city varchar(255) not null
);

And please feel free to give me any advice.

User guide

clone and run

git clone https://github.com/ZhongjunTian/spring-repository-plus.git
cd spring-repository-plus
mvn spring-boot:run

You can look at PersonControllerTest.java and TestEntityControllerTest.java for more details,

spring-repository-plus's People

Contributors

zhongjuntian avatar wgayton avatar zhichongli avatar

Watchers

James Cloos avatar Ladislav Sopko 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.