Select MAX timestamp with JPA2 Criteria API

前端 未结 1 2096
萌比男神i
萌比男神i 2021-02-06 23:07

So my entity has:

@Column(name=\"TS\", nullable=false)
private java.sql.Timestamp timestamp; 

My generated MetaModel has:

publi         


        
相关标签:
1条回答
  • 2021-02-06 23:58

    Instead of max one should use CriteriaBuilder.greatest for Timestamp (and for Date, String and other Comparables as well). And if you ever need MIN for Timestamp, then use least method instead

    Similar kind of issue can be be faced with less/greater/equal comparisons. Firs one accepts argument that extends Number, second one is for other comparables:

    • lt vs. lessThan
    • le vs. lessThanOrEqualTo
    • ge vs. greaterThanOrEqualTo
    • gt vs. greaterThan
    0 讨论(0)
提交回复
热议问题