-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem using primary foreign key and foreign key in many-to
PostPosted: Fri Sep 21, 2007 10:30 pm 
Newbie

Joined: Mon Nov 08, 2004 6:41 pm
Posts: 5
Location: Asuncion, Paraguay
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]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.