1
可以說我有一個MySQL表工件如下:如何在querydsl中使用mysql now()函數?
artifact_id VARCHAR(50)
locked_status炭(1)
valid_till日期時間
Select artifact_id from artifact where locked_status='Y'
對於上述查詢,我有querydsl表示爲:
SQLTemplates templates = new MySQLTemplates();
Configuration configuration = new Configuration(templates);
QArtifact artifact = new QArtifact("a");
SQLQuery<?> query = new SQLQuery<Void>(con, templates);
List<String> artifactIds = query.select(artifact.artifact_id)
.from(artifact)
.where(artifact.locked_status.eq("Y"))
.fetch();
如何在querydsl中表示以下查詢?
Select artifact_id from artifact where locked_status='Y' and valid_till > now()
獲取此錯誤 - 使用Expressions.currentTimestamp()選項時,類型TemporalExpression中的(Timestamp)之後的方法不適用於參數(DateTimeExpression )。 –
Vedha
好吧,然後試試這個:'DateTimeExpression.currentTimestamp(Timestamp.class)'。它實際上和上面的表達式一樣,用另一個Class作爲參數。 – Simon
謝謝,按預期工作 – Vedha