When I trace the Hibernate SQL with bound parameters and execute the SQL directly it returns the expected result.
DEBUG SQL - select rechtsvorg0_.nr as nr1_49_, rechtsvorg0_.kurzname as kurzname2_49_, rechtsvorg0_.langname as langname3_49_, rechtsvorg0_.entscheidungArt as entscheidungArt4_49_, rechtsvorg0_.gueltigBis as gueltigBis5_49_, rechtsvorg0_.gueltigVon as gueltigVon6_49_, rechtsvorg0_.kategorieNr as kategorieNr7_49_, rechtsvorg0_.objektArt as objektArt8_49_, rechtsvorg0_.refNr as refNr9_49_ from WR.WR_SL_RECHTSVORGANG rechtsvorg0_ where rechtsvorg0_.kategorieNr>=? and rechtsvorg0_.kategorieNr<? and rechtsvorg0_.gueltigVon>=? order by rechtsvorg0_.langname
TRACE BasicBinder - binding parameter [1] as [INTEGER] - [110]
TRACE BasicBinder - binding parameter [2] as [INTEGER] - [120]
TRACE BasicBinder - binding parameter [3] as [DATE] - [Tue Jan 01 10:15:52 CET 2013]
When I run
Code:
select rechtsvorg0_.nr as nr1_49_, rechtsvorg0_.kurzname as kurzname2_49_, rechtsvorg0_.langname as langname3_49_, rechtsvorg0_.entscheidungArt as entscheidungArt4_49_, rechtsvorg0_.gueltigBis as gueltigBis5_49_, rechtsvorg0_.gueltigVon as gueltigVon6_49_, rechtsvorg0_.kategorieNr as kategorieNr7_49_, rechtsvorg0_.objektArt as objektArt8_49_, rechtsvorg0_.refNr as refNr9_49_ from WR.WR_SL_RECHTSVORGANG rechtsvorg0_ where rechtsvorg0_.kategorieNr>=110 and rechtsvorg0_.kategorieNr<120 and rechtsvorg0_.gueltigVon>=to_date('01-01-2013', 'DD-MM-YYYY') order by rechtsvorg0_.langname
from SQL Developer I get the expected result. So it seems that Hibernate generates valid SQL.
After playing around I have found that apparently ojdbc7 does not work properly with date comparisons using >=.
After changing to >
Code:
@NamedQuery(name = "Rechtsvorgang.findZulassungsarten", query = "SELECT r from Rechtsvorgang r WHERE r.kategorieNr >= :kategorieNrLower AND r.kategorieNr < :kategorieNrUpper AND gueltigVon > :gueltigVon ORDER BY r.langname")
and adusting the gueltigVon Parameter accordingly the application works as expected again.