Hello, i have a problem with day() function in as a WHERE clause.
My system is an Ubuntu, with JDK 1.6, PostgreSQL 8.2.11, Hibernate 3.3.1.
My Query is as simple as:
Code:
@NamedQuery(name = "findReservesBySalaDia", query = "select r from Reserva as r WHERE
day(:diaHora) = day(r.diaHora))
Where :diaHora is a java.util.Date instance. As you can see i only want all Reserves that has been reserved at an specific day, no matter month nor year.
Ant what i gets is an exception:
Quote:
Caused by: org.postgresql.util.PSQLException: ERROR: function pg_catalog.date_part("unknown", "unknown") is not unique
Watching SQL generated by Hibernate:
Quote:
elect reserva0_.dboid as dboid2_, reserva0_.diaHora as diaHora2_, reserva0_.motiu as motiu2_, reserva0_.sala as sala2_, reserva0_.usuari as usuari2_ from Reserva reserva0_ where extract(day from ?)=extract(day from reserva0_.diaHora)
but if in postgres manual the function extract works like:
Code:
extract(hour from timestamp '2001-02-16 20:38:40')
it seems like the function is not properly converted, but i cannot ensure.
Anybody have any idea? Of course at least i can make it using a native query but i want to avoid that final solution.
Thank you very much for your help