Reputation: 11
Recently, I wrote a program which is connection database!
I think that replace sql to querydsl;
For example SQL:
SELECT"MAX"(aa) AS big,"MIN"(aa) AS small FROM (
SELECT
"TO_NUMBER"(MONITOR_INFO."VALUE") aa
FROM
MONITOR_INFO
WHERE
MONITOR_INFO.DSID IN (9211)
AND MONITOR_INFO."TIME" BETWEEN "TO_DATE" (
'2013-09-03 00:00:00',
'yyyy-mm-dd hh24:mi:ss'
)
AND TO_DATE (
'2013-09-04 00:00:00',
'yyyy-mm-dd hh24:mi:ss'
)
)
How can I use Querydsl to replace?
Upvotes: 1
Views: 4360
Reputation: 22200
Let's assume you are using Querydsl SQL and you have generated your metamodel for Querydsl. Then you could describe the given query as
QMonitorInfo monitorInfo = QMonitorInfo.monitorInfo;
List<Tuple> result = query.from(monitorInfo)
.where(
monitorInfo.dsid.eq(9211),
monitorInfo.time.between(start, end))
.list(monitorInfo.value.castToNum(Integer.class).max(),
monitorInfo.value.castToNum(Integer.class).min());
Upvotes: 1