Hi all,
Here is my little problem.
I try to make a request with HQL using AND and OR clause.
Here is the HQL :
Query query = session.createQuery(""from Planning where Utilisateur.Id = " + oUtilisateur.getId() + " AND ( (DateDebut >= '01/05/2008' AND DateDebut <= '31/05/2008') OR (DateFin >= '01/05/2008' AND DateFin <= '31/05/2008') ) ORDER BY DateDebut"") ;
Problem is that the generated request (see below) doesn't match the HQL above. Any ideas ?
Thank you in advance for your help. I don't see my mistake.
Hibernate version:3.2.6
Mapping documents:<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="fr.mycompany.myproject.object"> <class name="Planning" table="planning"> <id name="Id" column="id"> <generator class="sequence"> <param name="sequence">seq_planning</param> </generator> </id> <property name="DateDebut" column="date_deb" /> <property name="DateFin" column="date_fin" /> <property name="Code" column="code" /> <many-to-one name="Utilisateur" class="fr.mycompany.myproject.object.Utilisateur" cascade="none"> <column name="id_utilisateur" /> </many-to-one> </class> </hibernate-mapping>
Name and version of the database you are using:Oracle 9
The generated SQL (show_sql=true): Hibernate: select planning0_.id as id28_, planning0_.date_deb as date2_28_, planning0_.date_fin as date3_28_, planning0_.code as code28_, planning0_.id_utilisateur as utilisateur7_28_ from planning planning0_ where planning0_.id_utilisateur=1055 and (planning0_.date_deb>='01/05/2008' and planning0_.date_deb<='31/05/2008' or planning0_.date_fin>='01/05/2008' and planning0_.date_fin<='31/05/2008') order by planning0_.date_deb
|