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