Questions tagged [querydsl]

Querydsl is a framework which enables the construction of type-safe SQL-like queries for multiple backends including JPA, MongoDB and SQL in Java.

Querydsl is a framework which enables the construction of type-safe SQL-like queries for multiple backends including , and in .

Instead of writing queries as inline strings or externalizing them into XML files they are constructed via a fluent API.

1985 questions
8
votes
4 answers

Select only specific column in Spring with Querydsl?

Let say i have model called Employee with 70 column. How can i implement query SELECT id from t_employee in spring + querydsl without modifying lot of code from this code. BooleanExpression paramEmployee = qEmployee.company.id.eq(new…
8
votes
3 answers

Spring with Query Dsl custom binding and or operation doesn't work

i have following reQuirement Query: "/article?category=kitchen&category=sports" This Query is working without custom bindings. It will give me all Kitchen and sports articles as Response. It is doing an OR-Operation somehow. But i need to customize…
Emre Öztürk
  • 2,660
  • 4
  • 16
  • 19
8
votes
2 answers

QueryDsl: Exception "argument type mismatch" with projection bean and oneToMany or manyToMany association

I have an association manyToMany between User and Role entities (User >---< Role) I wanted to perform this query: createQuery() .from(qUser) .leftJoin(qUser.roles, qRole) .where(qUser.login.eq(login)) .singleResult( …
Thibaud Sowa
  • 402
  • 4
  • 19
8
votes
2 answers

Querydsl, subquery in SELECT

I'm running the following SQL as a native query but I would like to know if there is a way to run it in JPAQuery in order to use tuples or class instantiation. SELECT a.*, (SELECT exists (SELECT 1 FROM Table b WHERE b.a_code = a.code AND…
Sandy
  • 547
  • 3
  • 9
  • 20
8
votes
3 answers

QueryDSL: convert list of BooleanExpression to Predicate

I'm trying to create a query that would depend on number of boolean parameters. The function that creates the predicate looks like this: Predicate createPredicate(Boolean param1, Boolean param2) { List booleanExpressions = new…
Paweł Kozikowski
  • 1,025
  • 2
  • 11
  • 23
8
votes
1 answer

Pivot-like result with JPA/QueryDSL

We are using JPA2, Spring Data and QueryDSL in our project. I have the following tables and related JPA entities: table Person (id, ...) table Activity (id, type, ...) @Entity @Configurable public class Activity { @ElementCollection …
swinkler
  • 1,703
  • 10
  • 20
8
votes
1 answer

QueryDSL Left Join with additional conditions in ON

Is it possible to do the following query in QueryDSL? SELECT p.* FROM parts_table p LEFT JOIN inventory_balance_table i ON (p.part_no = i.part_no AND i.month = MONTH(CURRENT_DATE) AND i.year = YEAR(CURRENT_DATE)); Inventory…
Cezille07
  • 350
  • 1
  • 7
  • 17
8
votes
2 answers

Is there any REST API query standard / DSL to express complex filters in GET URL?

I am currently researching for an elegant way, for my REST API under development, to express filters for GET requests returning collections. I'd like to express queries as "http://[...]?filter=expressions", where I am going to evaluate the…
Marius Schmidt
  • 633
  • 6
  • 18
8
votes
2 answers

Generic code failed with Spring data and Querydsl

i use querydsl that's why i don't need method like findByName() and all my repository interface are empty. So i try to make genric code to avoid repetitive interface with empty methods because i have many classes in my entities mapped by…
Hayi
  • 6,972
  • 26
  • 80
  • 139
8
votes
1 answer

Why is query dsl entity path limited to four levels?

Im currently using the maven apt plugin to generate the EntityPath base classes. com.mysema.maven maven-apt-plugin 1.0.4
geneqew
  • 2,401
  • 5
  • 33
  • 48
8
votes
2 answers

How to left join unrelated entities?

When i try to run a query like this: QA A = QA.a; QB B = QB.b; ... from(A) .leftJoin(B).with(B.name.eq(A.nameSomething)); (A and B entities are not related) I'm always getting this error: Caused by: org.hibernate.hql.ast.QuerySyntaxException: Path…
lorak
  • 113
  • 1
  • 6
8
votes
0 answers

Cross Join When Building Predicate for QueryDSL

I am using Query DSL with Spring Data Jpa with QueryDslPredicateExecutor I have the following Entities; @Table(name="a_table") @Entity public class A { @OneToOne @JoinColumn(name = "b_id") private B…
shazin
  • 21,379
  • 3
  • 54
  • 71
8
votes
2 answers

How do you specify multi-column OrderSpecifier for use in SpringData and QueryDsl? Is this possible

So I have the following query below: public Iterable findAll(Dealer dealer) { QDealer qdealer = QDealer.dealer; BooleanExpression where = null; if(dealer.getId() != null && dealer.getId() != 0) { …
8
votes
1 answer

How to join when building Predicate(s), but without having a JPAQuery instance

When building a Predicate for the Entity Book, I would like to be able to left join on Category (ManyToMany) to add a AND Predicate on Category. I could simply achieve that if I have the JPAQuery instance : if (catId != null) { …
Gauthier Peel
  • 1,438
  • 2
  • 17
  • 35
8
votes
1 answer

Simple (E1 AND E2) OR (E3 AND E4) expression in QueryDSL

How do I express in QueryDSL where clause in form: WHERE (E1 AND E2) OR (E3 AND E4) E1..E4 are arbitrary boolean expressions. The point is to have a query started within parenthesis, thus (E1 AND E2).
csviri
  • 1,159
  • 3
  • 16
  • 31