-->
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: Little problem with a criteria
PostPosted: Wed Jan 03, 2007 1:18 pm 
Newbie

Joined: Thu Dec 21, 2006 11:01 am
Posts: 12
So, I have a problem with my criteria

There are 2 classes : Request and Enterprise

Request :
private Integer idRequest;
private Enterprise enterprise;

Enterprise :
private Integer idEnterprise;
private String enterName;

I would like to make a criteria to find the Request id from the Enterprise id.

Code:
Criteria criter = this.Session.createCriteria(Request.class).createCriteria("enterprise").add(Restrictions.eq("idEnterprise", new Integer(idEnter)))



This is the code that I make but it return nothing ! Whereas there is a lot of record in the db ...

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 03, 2007 3:55 pm 
Beginner
Beginner

Joined: Sun Nov 16, 2003 3:04 pm
Posts: 24
Turn on 'showSQL' and post the sql being generated. A great way to debug hibernate queries...


Top
 Profile  
 
 Post subject: Re: Little problem with a criteria
PostPosted: Wed Jan 03, 2007 5:04 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Flash31186 wrote:
I would like to make a criteria to find the Request id from the Enterprise id.

Code:
Criteria criter = this.Session.createCriteria(Request.class).createCriteria("enterprise").add(Restrictions.eq("idEnterprise", new Integer(idEnter)))



fortknox is right. You should activate the show_sql property to debug those kind of problem.

Regarding your query, when comparing ids, use the idEq() method instead. Maybe that's the problem.

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 04, 2007 4:33 am 
Newbie

Joined: Thu Dec 21, 2006 11:01 am
Posts: 12
Oh right ! I didn't know this property, I'll try it ...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 04, 2007 4:47 am 
Newbie

Joined: Thu Dec 21, 2006 11:01 am
Posts: 12
oh ... sorry it's an error when I acquire the enterprise id... but now I know that my query is right ... and the 'show_SQL' property is a very good thing !

thanks for your replies !


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.