我有3个查询:
1
@Query(value = "select * from ACCOUNT_TRANSACTION at where
at.TRANS_DATETIME >= coalesce(:#{#fromDate}, at.TRANS_DATETIME)",
nativeQuery = true)
2
@Query(value = "select * from ACCOUNT_TRANSACTION at where
(:#{#fromDate} is null or at.TRANS_DATETIME >= :#{#fromDate}) ",
nativeQuery = true)
3
@Query(value = "select at from AccountTransaction at where
:#{#fromDate} is null or at.transDatetime >= :#{#fromDate} ")
查询1,2不使用错误消息:
ORA-00932:不一致的数据类型:预期DATE得到BINARY。
查询3工作!
柱:
@XmlElement(name = "transDatetime")
@XmlJavaTypeAdapter(DateAdapter.class)
private Date transDatetime;
@Basic
@Column(name = "TRANS_DATETIME")
public Date getTransDatetime() {
return transDatetime;
}
public void setTransDatetime(Date transDatetime) {
this.transDatetime = transDatetime;
}
你能告诉我1,2中的错误吗?谢谢!
更新:
4
@Query(value = "SELECT * FROM ACCOUNT_TRANSACTION at WHERE at.TRANS_DATETIME >= (CASE WHEN :#{#fromDate} is null then at.TRANS_DATETIME ELSE :#{#fromDate} END )", nativeQuery = true)
我在查询但是不起作用的情况下尝试过。 似乎本机查询失败了。