-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Problem with parenthesis in HQL
PostPosted: Thu May 15, 2008 7:40 am 
Newbie

Joined: Thu May 15, 2008 5:43 am
Posts: 7
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


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 15, 2008 9:01 am 
Newbie

Joined: Thu May 15, 2008 5:43 am
Posts: 7
As i can see in Hibernate source, the problem shall be in SqlGeneratorBase class. But i can't for the moment fully understood this class. Could you help me to solve this problem ?
Regards,


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 19, 2008 5:34 am 
Newbie

Joined: Thu May 15, 2008 5:43 am
Posts: 7
hi,

I can't believe that nobody have encoured the same problem. Does anybody understood why i mean, or does anybody have an idea ?

Thanks in advance for your reply.
Regards,

Denez


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.