Gili
Gili

Reputation: 90160

How to specify parenthesis in QueryDSL?

Borrowing an example from http://en.wikipedia.org/wiki/Hierarchical_and_recursive_queries_in_SQL#Common_table_expression:

WITH RECURSIVE temp (n, fact) AS 
(SELECT 0, 1 -- Initial Subquery
  UNION ALL 
 SELECT n+1, (n+1)*fact FROM temp -- Recursive Subquery 
        WHERE n < 9)
SELECT * FROM temp;

How would you express (n+1)*fact versus n+(1*fact) in the SELECT clause using QueryDSL?

Upvotes: 1

Views: 616

Answers (1)

Timo Westk&#228;mper
Timo Westk&#228;mper

Reputation: 22200

Querydsl handles parenthesis internally in the serialization. Your expressions can be expressed like this in Querydsl

n.add(1).times(fact)

and

n.add(fact.times(1))

Upvotes: 1

Related Questions