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.  [ 2 posts ] 
Author Message
 Post subject: Probleme clé étrangère...
PostPosted: Wed Dec 12, 2007 7:58 am 
Newbie

Joined: Wed Dec 12, 2007 7:35 am
Posts: 1
Voilà j'ai un problème avec la mapping hibernate d'une clé étrangère.

J'ai 2 tables :

- APPLICATION
* NOM_APP [cle primaire]
- FONCTION
* NOM_FCT [cle primaire]
* NOM_APP [cle étrangère]


Voici le mapping entre la classe APPLICATION et la table APPLICATION :

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<meta attribute="toto" inherit="true"/>


<class name="ss.Application" table="application">


<id name="nom_app" type="string" column="NOM_APP" length="32" >
<generator class="assigned">
</generator>
</id>

</class>
</hibernate-mapping>



Voici le mapping entre la classe FONCTION et la table FONCTION :

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<meta attribute="toto" inherit="true"/>


<class name="ss.Fonction" table="fonction">

<id name="NOM_FCT" type="string" column="MATRICULE" length="7" >
<generator class="assigned">
</generator>
</id>

<!-- mapping de la cle etrangere ??? -->


</class>

</hibernate-mapping>


comment faut il faire pour mapper la cle etrangere ?

je vous remercie ...


Top
 Profile  
 
 Post subject: Re: Probleme clé étrangère...
PostPosted: Wed Dec 12, 2007 12:15 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
astragon wrote:
comment faut il faire pour mapper la cle etrangere ?



vous pouvez definir la mapping comme les suivantes:


Code:
<hibernate-mapping>
    <meta attribute="toto" inherit="true"/>


   <class name="ss.Fonction" table="fonction">

       <id name="NOM_FCT"    type="string"   column="MATRICULE"   length="7" >
         <generator class="assigned">
         </generator>
       </id>

      <!-- mapping de la cle etrangere ??? -->
       <many-to-one property="application" column="NOM_APP" class="ss.Application"/>

   </class>

</hibernate-mapping>



Farzad-


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

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.