Hi people! I nedd your help :D
Im using Hibernate 3.2
I generated this mapping with hibernate tools within eclipse
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd ">
<!-- Generated 14/09/2007 11:13:32 AM by Hibernate Tools 3.2.0.beta8 -->
<hibernate-mapping>
<class name="domain.MemoriaEntidad"
table="memoria_entidad" schema="presupuesto">
<composite-id name="id"
class="domain.MemoriaEntidadId">
<key-property name="codigo" type="java.lang.String ">
<column name="codigo" length="20" />
</key-property>
<key-property name="anio" type="java.lang.Short">
<column name="anio" />
</key-property>
</composite-id>
<many-to-one name="clasificador"
class="domain.Clasificador "
update="false" insert="false" fetch="select">
<column name="anio" not-null="true" />
<column name="clasificador_dominio_id" not-null="true" />
<column name="codigo" length="20" not-null="true" />
</many-to-one>
<property name="baseLegal" type="java.lang.String">
<column name="base_legal" length="2000" />
</property>
</class>
</hibernate-mapping>
I have 2 primary anf foreign keys: codigo and anio.
And One extra foreign key codigo_dominio_id.
This three foreign keys are used in a many-to-one relationship.
But when i try to insert it i have a problem because clasificador_dominio_id can't be null. This is a BD constraint. And i wrote the many-to-one element with a insert="false".
How can i specify just one column in a many-to-one mapping to be insert="true" and the other be insert="false"?
This prevents me to asociate my class MemoriaEntidad with Clasificador beacuse it's foreign key is no inserted in the query.
I tried using insert="true" but it games me a duplicate error because anio and codigo are allready inserted as primary key.
Thanks in advance and sorry 3 tha english :D[/code]