Hi.
I have been playing around with hibernate where I work for some time now. I am getting good at it, and the hurdles I am facing now is in making HQL queries.
I can write HQL, i think its just plain inefficient.
My Object looks like this:
Code:
class TShirt -has many -> TShirtFeatures
class TShirtFeatures - has one -> TDesign - has one ->Designer
class TShirt -has one -> TShirtBatch
class ->TShirtBatch -has many -> TShirtBatchBusiness -has one -> Business
Each of these classes has a table in the database.
Now i need to find TShirts for a particular
Designer.name
and
TShirtBatchBusiness .Business.businessTypeEnum
---
This is where I get inefficient with my query:
Code:
Select t from TShirt t
LEFT JOIN t.tshirtFeatures tf
LEFT JOIN t.tshirtBatch.TShirtBatchBusiness tbb
where
and tf.tDesign.designer=:designerParameter
and tbb.business.typeEnum=:businessTypeEnumStringParameter
well, first of all, it results in cartesian product by business.typeEnum
(as many rows as there are constants in the enum)
Second of all, i think there are too many joins
Is it better to get records first and then use java to iterate over them?
or should i just change my query?
My mapping loads all sets as lazy.
I thought of using sub-select fetching, but that is not possible in the current design
Any help would be very much appreciated