Thanks pkleindl. I've a filter defined to select only certain attributes (i.e on the ATTRIBUTE_ID column) and i've enabled it, along with fetch=subselect
The SQL generated is like (for 4 attribute_ids in filter):
Code:
Hibernate: select this_.PRODUCT_ID as PRODUCT1_5_0_, this_.PRODUCT_CODE as PRODUCT2_5_0_, this_.PRODUCT_STATUS as PRODUCT3_5_0_ from PRODUCT this_
Hibernate: select complexpro0_.PRODUCT_ID as PRODUCT1_1_, complexpro0_.ATTRIBUTE_ID as ATTRIBUTE2_1_, complexpro0_.ERP_ID as ERP3_1_, complexpro0_.PRODUCT_ID as PRODUCT1_7_0_, complexpro0_.ATTRIBUTE_ID as ATTRIBUTE2_7_0_, complexpro0_.ERP_ID as ERP3_7_0_, complexpro0_.ATTRIBUTE_VALUE as ATTRIBUTE4_7_0_ from PRODUCT_ATTRIBUTE_CLOB complexpro0_ where complexpro0_.ATTRIBUTE_ID IN (?, ?, ?, ?) and complexpro0_.PRODUCT_ID in (select this_.PRODUCT_ID from PRODUCT this_)
select simpleprod0_.PRODUCT_ID as PRODUCT1_1_, simpleprod0_.ATTRIBUTE_ID as ATTRIBUTE2_1_, simpleprod0_.ERP_ID as ERP3_1_, simpleprod0_.PRODUCT_ID as PRODUCT1_6_0_, simpleprod0_.ATTRIBUTE_ID as ATTRIBUTE2_6_0_, simpleprod0_.ERP_ID as ERP3_6_0_, simpleprod0_.ATTRIBUTE_VALUE as ATTRIBUTE4_6_0_ from PRODUCT_ATTRIBUTE simpleprod0_ where simpleprod0_.ATTRIBUTE_ID IN (?, ?, ?, ?) and simpleprod0_.PRODUCT_ID in (select this_.PRODUCT_ID from PRODUCT this_)
4 SQLs like ( 1 per Attribute in the filter) :
Code:
Hibernate: select attribute0_.ATTRIBUTE_ID as ATTRIBUTE1_3_0_, attribute0_.ATTRIBUTE_NAME as ATTRIBUTE2_3_0_, attribute0_.ALIAS_NAME as ALIAS3_3_0_ from ATTRIBUTE attribute0_ where attribute0_.ATTRIBUTE_ID=?
The sub-selects are fetching all the data i need, both simple and complex attributes that match the filter. But i dont understand why the last 4 SQLs are fired, when the Attribute values have been already fetched. Any idea?