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