JPA and query interval

1,794 views
Skip to first unread message

Mickaël GENTIL

unread,
Dec 9, 2011, 6:25:54 AM12/9/11
to play-fr...@googlegroups.com
Hi all,

I want to create a query that check a date stored in a table with an interval (with Postgresql).

I've tested it with 2 methods :

1) 
user = models.User.find("guid = ? and status = ? and updated >= (now() - interval '20 minutes')"udid, Status.ACCEPTED).first();


2)
Calendar now = Calendar.getInstance();
now.add(Calendar.MINUTE, -20);
user = models.User.find("guid = ? and status = ? and updated >= ?"udid, Status.ACCEPTED, now.getTime()).first();



The result of the first method is an error : ERROR ~ line 1:81: unexpected token: '20 minutes'

And second method don't throw me an error, but the user object is null (i've checked my data with the same request directly on postgresql).

Anybody can help me to understand how to do this trick?

Thx.

Mickaël.

Yudao

unread,
Dec 9, 2011, 8:33:57 AM12/9/11
to play-framework
Sorry for the inconvenience.

The second method works great. It was an another problem.

Shame on me :)

Thx.

Mickaël.

Reply all
Reply to author
Forward
0 new messages