Giter VIP home page Giter VIP logo

spring-boot-query-types's Introduction

spring-boot-query-types

Post man collection is in resource folder .

1- Named query using specification dynamic filter(without projection), sort and pagination =>

Page<ProductEntity> findAll(Specification<ProductEntity> specification, Pageable pageable);

2- Named query using projection and pageable

<T> Page<T> findAllBy(Class<T> type, Pageable pageable);

3- Named query using projection but not with pageable, it returns all results even if it's 10 or 1000

<T> List<T> getAllBy(Class<T> type);

4- Native query without limit, offset and where clause

@Query(value = "SELECT p.id, p.en_name, b.id AS 'brandId', b.en_name AS 'brandEnName' FROM product p LEFT OUTER JOIN brand b ON b.id = p.brand_id;", nativeQuery = true) List<GetProductIdEnNameAndBrandDto> findAllByNativeQuery();

5- From a file

@Query(value = "CALL spGetAllProducts(); ", nativeQuery = true) List<GetProductIdAndEnNameDto> getAllFromFile();

6- JPQL

@Query(value = "select a from ProductEntity a where a.id = :id") GetProductIdAndEnNameDto findByIdJPQL(@Param("id") Long id);

7- Entity graph

@EntityGraph(attributePaths = { "brand" }) Optional<ProductEntity> findById(Long id);

8- JPQL

@Query(value = "select a from ProductEntity a where a.enName like %:enName%") List<GetProductIdAndEnNameDto> findAllByEnNameLikeJPQL(@Param("enName") String enName);

9- Named query

List<GetProductIdAndEnNameDto> getAllByEnNameContains(String enName);

spring-boot-query-types's People

Contributors

zahraasgharzadeh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

hakimrabet

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.