querydsl

QueryDsl - subquery in collection expression

半城伤御伤魂 提交于 2019-12-18 10:55:31
问题 I'm using spring-data-jpa and querydsl (3.2.3) I have a scenario where I'm creating set of predicates based on user filer/input. All of these comes to BooleanExpression . My simplified model looks as following: @Entity public class Invoice { @ManyToOne private Supplier supplier; } @Entity public class Supplier { private String number; } @Entity public class Company { private String number; private boolean active } Now, what I'm struggling with is this query: SELECT * FROM Invoice WHERE

How to easy implement 'REST API query language' with Querydsl and Spring Data to filter the entities?

蓝咒 提交于 2019-12-18 05:25:06
问题 How to easy implement a kind of 'REST API query language' with Spring Data to filter the entities? For example, for the following Person entity: @Data @Entity public class Person { @Id @GeneratedValue private Long id; private LocalDate dob; // date of birth private String name; @Formula("timestampdiff('year', dob, now())") private Integer age; public Person(String name, LocalDate dob) { this.name = name; this.dob = dob; } } I would like to get its data with such a request: GET /people?name=jo

Replacing deprecated QuerydslJpaRepository with QuerydslJpaPredicateExecutor fails

≡放荡痞女 提交于 2019-12-18 03:37:13
问题 I needed some custom QueryDSL enabled query methods and followed this SO answer. That worked great, but after upgrading to Spring Boot 2.1 (which upgrades Spring Data), I've found that QuerydslJpaRepository has been deprecated. Simply replacing it with QuerydslJpaPredicateExecutor - which the documentation tells me to use - leads to an error: Caused by: java.lang.IllegalArgumentException: Object of class [...ProjectingQueryDslJpaRepositoryImpl] must be an instance of interface org

How to get fully materialized query from querydsl

僤鯓⒐⒋嵵緔 提交于 2019-12-17 18:21:21
问题 I am trying to use querydsl for building dynamic queries for dynamic schemas. I am trying to get just the query instead of having to actually execute it. So far I have faced two issues: - The schema.table notation is absent. Instead I only get the table name. - I have been able to get the query but it separates out the variables and puts '?' instead which is understandable. But I am wondering if there is some way to get fully materialized query including the parameters. Here is my current

Can Spring Data REST's QueryDSL integration be used to perform more complex queries?

只谈情不闲聊 提交于 2019-12-17 08:25:12
问题 I'm currently building a REST API in which I want clients to easily filter on most properties of a specific entity. Using QueryDSL in combination with Spring Data REST (an example by Oliver Gierke) allows me to easily get to 90% of what I want by allowing clients to filter by combining query parameters which refer to properties (e.g. /users?firstName=Dennis&lastName=Laumen ). I can even customize the mapping between the query parameters and an entity's properties by implementing the

Can Spring Data REST's QueryDSL integration be used to perform more complex queries?

喜夏-厌秋 提交于 2019-12-17 08:25:06
问题 I'm currently building a REST API in which I want clients to easily filter on most properties of a specific entity. Using QueryDSL in combination with Spring Data REST (an example by Oliver Gierke) allows me to easily get to 90% of what I want by allowing clients to filter by combining query parameters which refer to properties (e.g. /users?firstName=Dennis&lastName=Laumen ). I can even customize the mapping between the query parameters and an entity's properties by implementing the

Dynamic spring data jpa repository query with arbitrary AND clauses

爱⌒轻易说出口 提交于 2019-12-16 21:00:12
问题 I'm using Spring data jpa repositories , Got a requirement to give search feature with different fields. Entering fields before search is optional.I have 5 fields say EmployeeNumber , Name , Married , Profession and DateOfBirth . Here i need to query only with the given values by user and other fields should be ignored.Ex, Input : EmployeeNumber: ,Name:St,Married: ,Professsion:IT,DateOfBirth: Query : Select * from Employee e where Name like 'St%' and Profession like 'IT%'; Input :

QueryDsl and @JsonAutoDetect - Q classes not generated

社会主义新天地 提交于 2019-12-13 18:18:45
问题 I figured out that if entity class has @jsonAutoDetect annotation, the Q class not generated, Here is the example : https://github.com/prilia/SpringJpa-Quarydsl-Test/tree/master/JpaSpringQuarydsl If remove JsonAutoDetect Q classes genereted fine, Please, how can I use with entity class as json ? 回答1: In cases like these always disable the execution of the ATP plugin and see if your build has other issues. e.g. https://github.com/prilia/SpringJpa-Quarydsl-Test/blob/master/JpaSpringQuarydsl/pom

Automatic trimming in QueryDSL with Bean Projection

末鹿安然 提交于 2019-12-13 15:27:12
问题 I have the following QueryDSL query: List<DTOPerson> names = query.from(p) .where(p.lastname.like("%smith%")) .orderBy(p.lastname.asc(), p.firstname.asc()) .list(Projections.bean(DTOPerson.class, p.lastname, p.firstname)); What I would like to have is this: List<DTOPerson> names = query.from(p) .where(p.lastname.like("%smith%")) .orderBy(p.lastname.asc(), p.firstname.asc()) .list(Projections.bean(DTOPerson.class, p.lastname.trim(), p.firstname.trim())); But when I do that, QueryDSL gives me

Create (querydsl) metamodel for Entity from jar

。_饼干妹妹 提交于 2019-12-13 14:59:12
问题 I'm having problems generating the querydsl metamodel (i.e. the Q-classes) for an Entity comming from a jar included in the dependencies for my project. The class (BaseEntity) is an abstract baseclass for most of my entities (annotated with @MappedSuperclass) and for project reasons and dependencies to other projects this baseclass has to be in a separate jar. When I now include this jar as a dependency for the project which contains my non-abstract entities and try to generate the metamodel