I have two tables in my DB, T1 and T2. One column of T1 is a foreign key that references T2. I need only a part of the columns of T1 and T2 for my processing, thus I've created a DTO T1T2 that contains only the necessary columns. To map the DTO to these two tables with Hibernate, I used subselect attribute of the class element.
<hibernate-mapping>
<class
name="com.xconnect.cdrrecorder.processing.dto.IngressNumRuleVoipProfile"
table="numbermodificationrules"
subselect="select ... from T1 left join T2 on id1=id2 where ...">
<cache usage="read-only"/>
...
</class>
</hibernate-mapping>
I noticed that when i need to select for an object, Hibernate converts the request to two selects (one into the other).
Is there a better way to do this? What do you think about performances?
Thanks