views:

3504

answers:

2

I'm trying to write this query using Hibernate 3 and Oracle 10.

from Alert alert
where alert.expiration > current_date()
order by alert.priority, alert.updated, alert.name

It's creating SQL like this -

Hibernate: select alert0_.ANNOUNCEMENTS_ID as ANNOUNCE1_1_, alert0_.ANNOUNCEMENT
S_NAME as ANNOUNCE2_1_, alert0_.ANNOUNCEMENTS_PRIORITY as ANNOUNCE3_1_, alert0_.
ANNOUNCEMENTS_EXPIRATION as ANNOUNCE4_1_, alert0_.ANNOUNCEMENTS_UPDATE_DATE as A
NNOUNCE5_1_ from NYC311_ANNOUNCEMENTS alert0_ where (alert0_.ANNOUNCEMENTS_EXPIR
ATION>current_date()) order by  alert0_.ANNOUNCEMENTS_PRIORITY , alert0_.ANNOUNC
EMENTS_UPDATE_DATE , alert0_.ANNOUNCEMENTS_NAME

I'm getting all of these wacky errors like "missing right parenthesis" when there is apparently perfectly balanced parenthesis.

Why is Oracle freaking out at this? Is there a better way to write my HQL query?

+1  A: 

Is current_date() a Hibernate function?

I would use sysdate instead.

like this:

where alert.expiration > sysdate

or to ignore time of day

where alert.expiration > trunc(sysdate)

Lost in Alabama
Current_date and Current_timestamp are Oracle functions. Current_date = Sysdate but Oracle doesn't need () after a function call.
+2  A: 

should'nt it be current_date ? hibernate should translate it, to the proper dialect

Michael Lange