-->
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.  [ 2 posts ] 
Author Message
 Post subject: QBE with partial data
PostPosted: Sun Jan 07, 2007 9:03 am 
Beginner
Beginner

Joined: Thu Apr 29, 2004 4:31 am
Posts: 42
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.1.2

Name and version of the database you are using:
HSQL

Hi all,
i have a problem in understanding Example query..
in my code i am executing following :
Code:
public List findByExample(Object exampleInstance) {
        Criteria crit = getSession().createCriteria(exampleInstance.getClass());
        Example example =  Example.create(exampleInstance);
        crit.add(example);
        return crit.list();
}


this result in the following SQL
Code:
Hibernate: select this_.id as id4_0_, this_.creationTimestamp as creation3_4_0_,
this_.status as status4_0_, this_.dlfSiteRef as dlfSiteRef4_0_, this_.transmiss
ionNumber as transmis6_4_0_, this_.transmissionTimestamp as transmis7_4_0_, this
_.interfaceType as interfac8_4_0_, this_.valid as valid4_0_, this_.manualInd as
manualInd4_0_, this_.operatorRef as operato17_4_0_, this_.productRef as productR
ef4_0_, this_.locationRef as locatio10_4_0_, this_.scanDate as scanDate4_0_, thi
s_.scanTime as scanTime4_0_, this_.scanner as scanner4_0_, this_.stockOutInd as
stockOu22_4_0_ from transferrecord this_ where this_.type=0 and (this_.creationT
imestamp=? and this_.status=? and this_.dlfSiteRef=? and this_.transmissionNumbe
r=? and this_.transmissionTimestamp=? and this_.interfaceType=? and this_.valid=
? and this_.manualInd=? and this_.operatorRef=? and this_.productRef=? and this_
.locationRef=? and this_.scanDate=? and this_.scanTime=? and this_.scanner=? and
this_.stockOutInd=?)


i struggled in undestanding why it wasn not working, and then i realized that in QBE it is selecting ALL properties of the example class passed.
I havent populated all of them, and that is the reason why it was failingn for me...

Is it possibe to use QBE when i just use a subset of the properties in the exampleInstance?
I'd like to have something dynamic, so that if i pass down an exampleInstance with 3 properties populated out of 7, it will do a QBE on those 3 properties....
is it possible?

thanks in advance and regards
Marco


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 07, 2007 1:02 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
I guess you should write a specific PropertySelector to ask Hibernate to process null value as something to be not included in the where clause.

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


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