Could somebody help me to construct the query I need?
With all my tries I get a "Path expected for join" error message.
I have two tables: Areas and AreasLocal. The first is structured as a tree table.
With the next query, I am able to get the whole areas tree (eagerly and with a fetch strategy).
Code:
Query query = this.sessionFactory.getCurrentSession().createQuery(
"from Areas areas" +
" left join fetch areas.childs childs" +
" where areas.parent.idArea = 1");
BUT, I don't know how can I get the areas names, which resides in the AreasLocal table (which acts as a i18n repository).
Code:
<hibernate-mapping>
<class name="somepaq.Areas" table="areas">
<id name="idArea" type="java.lang.Integer">
<column name="ID_AREA" />
</id>
<many-to-one name="parent" class="somepaq.Areas" fetch="select">
<column name="ID_PADRE"/>
</many-to-one>
<set name="childs" table="areas" inverse="true" lazy="false" fetch="select">
<key>
<column name="ID_PADRE"/>
</key>
<one-to-many class="somepaq.Areas" />
</set>
</class>
</hibernate-mapping>
Code:
<hibernate-mapping>
<class name="somepaq.AreasLocal" table="areas_local">
<composite-id name="id" class="somepaq.AreasLocalId">
<key-property name="idArea" type="java.lang.Integer">
<column name="ID_AREA" />
</key-property>
<key-property name="idLocal" type="java.lang.Integer">
<column name="ID_LOCAL" />
</key-property>
</composite-id>
<property name="name" type="string">
<column name="NAME" not-null="true" />
</property>
</class>
</hibernate-mapping>
Thanks a lot.