Spring Data JPA and Querydsl to fetch subset of columns using bean/constructor projection

Looks like custom repository implementation is the way to go for now until something similar available in spring data. I have gone through http://static.springsource.org/spring-data/data-jpa/docs/current/reference/html/repositories.html#repositories.custom-implementations Here is my implementation which works. However it would be good to have this method available directly in Spring-Data-JPA Step 1: Intermediate interface for shared behavior public interface CustomQueryDslJpaRepository <T, ID … Read more

Creating multiple aliases for the same QueryDSL path in Spring Data

You can create a transient property bound to QueryDSL this way: @Transient @QueryType(PropertyType.SIMPLE) public String getNameEndsWith() { // Whatever code, even return null } If you are using the QueryDSL annotation processor, you will see the “nameEndsWith” in the metadata Qxxx class, so you can bind it like any persisted property, but without persisting it.

Dynamic spring data jpa repository query with arbitrary AND clauses

You can use Specifications that Spring-data gives you out of the box. and be able to use criteria API to build queries programmatically.To support specifications you can extend your repository interface with the JpaSpecificationExecutor interface public interface CustomerRepository extends SimpleJpaRepository<T, ID>, JpaSpecificationExecutor { } The additional interface(JpaSpecificationExecutor ) carries methods that allow you to execute … Read more

What is the difference between must and filter in Query DSL in elasticsearch?

must contributes to the score. In filter, the score of the query is ignored. In both must and filter, the clause(query) must appear in matching documents. This is the reason for getting same results. You may check this link Score The relevance score of each document is represented by a positive floating-point number called the … Read more