My mapping:
Code:
<joined-subclass name="ime.sodc.model.local.Local" table="local"
lazy="false">
<key column="oid" />
<property name="descricao" type="java.lang.String"
update="true" insert="true" access="property" column="descricao" />
<property name="nome" type="java.lang.String" update="true"
insert="true" access="property" column="nome" />
<!--
<many-to-one name="posicaoGeografica"
class="ime.sodc.model.local.PosicaoGeografica" column="id_posicao"
cascade="save-update,merge" outer-join="false" lazy="false"/>
-->
<property name="oidPosicaoGeografica" type="long" />
<many-to-one name="divisaoTerritorialPai"
class="ime.sodc.model.local.DivisaoTerritorial"
column="id_divpai" lazy="false" cascade="save-update,merge" outer-join="false"/>
<!--
<many-to-one name="pontoDeReferenciaGeografico"
class="ime.sodc.model.local.Ponto" column="id_ponto"
cascade="save-update,merge" lazy="false">
</many-to-one>
-->
<property name="oidPontoDeReferenciaGeografico" type="long" />
<joined-subclass
name="ime.sodc.model.local.DivisaoTerritorial"
table="divisaoterritorial" lazy="false">
<key column="oid" />
<!-- <property name="tipo" column="tipo"></property>-->
<many-to-one name="tipo"
class="ime.sodc.model.local.TipoDivisaoTerritorial"
column="id_tipodivisaoterritorial"
cascade="save-update,merge" lazy="false">
</many-to-one>
<property name="area" column="area"></property>
<property name="codigoIBGE" column="codigoibge"></property>
<property name="sigla" column="sigla"></property>
<list name="listaSubDivisoes" table="listasubdivisoes"
cascade="save-update,merge" lazy="false" inverse="false" outer-join="false">
<key column="id_divpai"></key>
<index column="count" />
<one-to-many class="ime.sodc.model.local.Local" />
</list>
<joined-subclass name="ime.sodc.model.local.Municipio"
table="municipio" lazy="false">
<key column="oid" />
</joined-subclass>
</joined-subclass>
Hope that helps to help me hehe
my query is something like this:
Code:
List lista;
Query sqlQuery = aSession.createSQLQuery("select oid from divisaoterritorial where codigoibge like '__'")
.addScalar("oid",Hibernate.LONG);
List listaValores = sqlQuery.list();
Query q = aSession.createQuery("from tipo in class Local where tipo.oid in (:id_list)");
q.setParameterList("id_list",listaValores);
lista = q.list();
To perform more efficiency (sorry about my english), i´m getting a list of oids to perform a query in other table. In this example, I have a list of oids from the table divisaoterritorial and I´m using this list to do a query on the table local.