-->
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.  [ 5 posts ] 
Author Message
 Post subject: Problems while fetching NULL values when using HQL
PostPosted: Sun Jul 31, 2005 3:45 pm 
Beginner
Beginner

Joined: Tue Jun 21, 2005 2:21 am
Posts: 22
hi

I have a table named Category which has recursive bidirectional relationship . It has following fields
ID ---> Primary Key
NAME
PARENT_ID --> Foreign key referred to ID of this table
Sequence

I have done neccsary changes in the mapping file for this . But to meet my business needs, i need to fetch all the parent_id which are null (ORDERED by sequence ) I have a property named parentcategory and chilecategory in my Category POJO

public class Category {

private int id...
.....
private Category parentCategory
private set categoties
.....
public addChildCategory(Ctagory category){
.....
....
}

i wrote one sql which says
Query query = session.createQuery(from Category as c where parentCategory is null order by sequence ) .But this is throwing internal representation error . but when i tried to execute the o/p of query in toan i'm getting proper result.

can anyone help me in solving this problem . Am i missing any piece in HQL .?...

thanks
balaji


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 31, 2005 3:54 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Yes, you are missing something. :)
You always have to refer to the object you want to select.

from Category as c where c.parentCategory is null order by c.sequence

Best regards
Sven


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 01, 2005 12:52 am 
Beginner
Beginner

Joined: Tue Jun 21, 2005 2:21 am
Posts: 22
sorry i missed that in my text here .

actually i have my alias references ,as u mentioned .still i'm facing this problem .


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 01, 2005 7:22 am 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Post the exact exception, your POJOs wiith at least all necessary attributes (where is sequence?), the HQL query you are using as well as your mappings.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 02, 2005 12:47 am 
Beginner
Beginner

Joined: Tue Jun 21, 2005 2:21 am
Posts: 22
the problem was actually with attribute type mismatch . I mapped a varchar2 (20) type to int .:) which was basic cause for this problem .
it has been solved now and i thank u for your eagerness .

-Balaji


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