JPQL相当于numtodsinterval

时间:2012-08-07 15:30:13

标签: sql oracle plsql jpql date-arithmetic

我有一个SQL查询:

SELECT * 
FROM G1, G2, G3 
WHERE G1.G2_ID=G2.ID AND G1.G3_ID=G3.ID 
AND  (G3.CreationTime- G2.CreationTime) > NUMTODSINTERVAL( 300, 'day' );

我需要这个查询的JPQL形式。实际上我被困在了NUMTODSINTERVAL部分。

1 个答案:

答案 0 :(得分:0)

您可以重新制定查询,例如这样(使用Joda-Time):

Duration dur = Duration.standardDays(300);
DateTime dt = new DateTime(G2.KAYIT_OLUSTURMA);//Assuming G2.KAYIT_OLUSTURMA is of java.util.Date type
DateTime calc = dt.plus(dur);


SELECT * 
FROM GEBELIKTAKIP G1, GEBEBILDIRIM G2, GEBELIKSONUCU G3 
WHERE G1.GEBELIKBILDIRIM_ID=G2.ID AND G1.GEBELIKSONUC_ID=G3.ID 
AND  G3.KAYIT_OLUSTURMA > :calc