Correction...
actually a QBE is owrking fine with partially populated objects (i m using iwht another object that is not inherited)
It looks to me that the problem might be related with the mapping strategy i am using.
Here are two different examples, one works and the other does not
this is Configurator class, no inheritance at all, i am populating just one property, xsltPATH
here's generated query
Code:
Hibernate: select this_.id as id0_0_, this_.command as command0_0_, this_.mappin
gFile as mappingF3_0_0_, this_.normalizer as normalizer0_0_, this_.translator as
translator0_0_, this_.validator as validator0_0_, this_.xsltPath as xsltPath0_0
_, this_.site as site0_0_ from Configurator this_ where (this_.xsltPath=?)
And here's the example tha ti so nt working. I am using a table per class hierarchy. i have one object (TransferRecordImpl) and 3 subclasses (ReplenRequest, ExpectedReceipt and ReceiptConfirmation).
I created a ReplenRequest and populate it iwth only 2 properties, and here's what Hibernate generates as 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=?)
So, it is using ALL properties of the exampleInstance (ReplenRequest), and that is why is failing
So, i guess i have only 2 solutions for this case:
1) drop queryBYExample when using table per class hierarchy
2) try to use a different mapping strategy (mayb table per subclass will fix it..)
does anyone suggest any other solution?
I'd love to know why Hibernate QBE behaves that way for table per class inheritance.... anyone could give me a good explanation?
thanks in advance and regars
Marco