Reto wrote:
Can you show me the full mapping for your classes and the relationship?
Reto
Sure, below follow the full mapping file.
Cidades class (not relationship)
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 1.1//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-1.1.dtd">
<hibernate-mapping>
<class
name="br.com.junior.models.Cidades"
table="cidades"
>
<id
name="codigo"
column="codigo"
type="java.lang.Integer"
>
<generator class="assigned">
</generator>
</id>
<property
name="nome"
type="java.lang.String"
column="nome"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Cidades.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
Clientes here have the many-to-one relationship
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 1.1//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-1.1.dtd">
<hibernate-mapping>
<class
name="br.com.junior.models.Cidades"
table="cidades"
>
<id
name="codigo"
column="codigo"
type="java.lang.Integer"
>
<generator class="assigned">
</generator>
</id>
<property
name="nome"
type="java.lang.String"
column="nome"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Cidades.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
Talking with a friend, he said that is not a good idea to use 2 differents session. We need to avoid to use 2 Session (maybe performance). I'll try to change my architecture