Giter Club home page Giter Club logo

Comments (2)

darrachequesne avatar darrachequesne commented on May 25, 2024

Hi! That is a great question. The basic Specification is indeed limited to class attributes or @manytoone relationships. The SQL counterpart are:

  • "attribute" => WHERE table.attribute = :value
  • "relatedEntity.attribute" => JOIN relatedEntity WHERE relatedEntity.attribute = :value

That is the very basic usage. For more complex needs, my opinion is that Datatables (and thus this implementation) has absolutly no clue about what the user wants to do. So it lets him make whatever he wants (handling @manytomany relationships, using 'BETWEEN' clause...) through the following method: public DataTablesOutput<T> findAll(DataTablesInput input, Specification<T> additionalSpecification).

With this, the user is able to either pass directly the input object mapped from the request (the basic usage) or process this input to create an additionalSpecification according to his needs. Please see this example: https://github.com/darrachequesne/demo-spring-datatables/blob/master/src/main/java/demo/controller/UserRestController.java#L46

In that example, the "classic" filter value is cleared, and a custom Specification is built from the latter. I think it should cover most use-cases, but please tell me if I'm wrong.

from spring-data-jpa-datatables.

tomcgn avatar tomcgn commented on May 25, 2024

Hi Damien,
Thanks for your insights. Your design condiserations are straightforward and fully serve the purpose. As far as I can see, the Specification passed as parameter to findAll can not be written in a way that it is capable to handle collection attributes. Finally, I ended up rewriting your DataTablesRepositoryImpl and wire the required specification in its public DataTablesOutput<T> findAll(DataTablesInput input, Specification<T> additionalSpecification) and thus gain control over related SetAttributes via Subquerys . The datatables now work fine and serverside processing with spring-data-jpa-datatables reduces the time for pages to get displayed a lot. Again, thanks for sharing!
Tom

from spring-data-jpa-datatables.

Related Issues (20)

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.