-->
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.  [ 6 posts ] 
Author Message
 Post subject: Session.Find() Trick
PostPosted: Wed Nov 01, 2006 2:51 am 
Regular
Regular

Joined: Mon Aug 28, 2006 6:35 am
Posts: 66
Location: Middle East
Dear members,

When i'm using an hql
such as :

string hql = "SELECT Cat.Id,Cat.Cat,Cat.Status,Cat.cathasparent FROM nhExhibition.Business.Category as Cat";
session.find(hql);

where Cat.Id is of type int
Cat.Cat is of type string
Cat.Status of type boolean
Cat.cathasparent of type Category

I'm getting a List of objects (categories) which Cat.cathasparent is different than null ..
In other words, i'm getting a List of all the Category objects except those who have the Cat.cathasparent value = null ...
But i want to retrieve all the Category objects (including those having Cat.cathasparent value = null) ...

how it can be done ?

Regards,
Jojo

_________________
In Code We Trust


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 01, 2006 6:43 am 
Beginner
Beginner

Joined: Fri Oct 20, 2006 8:02 am
Posts: 36
You aren't getting all Categories ?
you don't need to specify the properties you need.
Just to know, do you have any category with null hasparentcat?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 01, 2006 7:28 am 
Regular
Regular

Joined: Mon Aug 28, 2006 6:35 am
Posts: 66
Location: Middle East
Dear anuarneto,

i'd like to get some properties of all the "categories objects" (table) from the database ..

and yes, i'm getting the category objects having cathasparent != null ..
those (categories) having the null values aren't retrieved from the database .

how can achieve that ?

Regards,
Jojo

_________________
In Code We Trust


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 01, 2006 10:28 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
Can You post the generated SQL?

Gert

_________________
If a reply helps You, rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 01, 2006 11:01 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Add an explicit left join to your query, "SELECT Cat.Id,Cat.Cat,Cat.Status,chp FROM nhExhibition.Business.Category as Cat left join Cat.cathasparent as chp"


Top
 Profile  
 
 Post subject: Session.Find() Trick
PostPosted: Thu Nov 02, 2006 2:00 am 
Regular
Regular

Joined: Mon Aug 28, 2006 6:35 am
Posts: 66
Location: Middle East
Thanks a lot Sergey, It worked like a charm .
But can you please explain me about it ..?

i'm using sqlserver express 2005, and i thought that the joints are required only with MsAccess Database .. i thought that i could avoid these joints by using the "select from ... where ..=(select ... from ..) "
and i've read some topics about joins,which says that it is required when using MS Access only .

Anyway, this join has worked well although i didn't define anything related to the joins in my mapping files :|, shall i add properties to my mapping files inn order to use these joints ?

Is there any query composer, or something which helps in composing my HQl s graphically and get the query?

Thanks in advance, :D

by the way, thanks gert for the last reply

Regards,
Jojo Rico

_________________
In Code We Trust


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.