Bonjour,
je n'arrive pas à mapper correctement les tables de ma base avec NHibernate.
En fait je dispose de trois classes : Contrat - Intérimaire - client.
Sachant que la classe Contrat possède une clef primaire multiple = NumContrat + NumClient + NumInterimaire
Donc NumClient et NumInterimaire sont aussi des clefs étrangères pour la table contrat.
La question dont je ne trouve pas la réponse est comment dois-je mapper tous ça ?
Pour contrat :
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<!--Built with MyGeneration/Template/NHibernate (c) by OHM (alvy77@hotmail.com)
based on NHibernate lujan99 0.9.20 (c) by lujan99@usa.net-->
<class name="adecco.Entities.Contrat,adecco" table="contrat" lazy="false">
<composite-id name="Id" class="adecco.Entities.ContratId,adecco">
<key-property name="NumContrat" column="num_contrat" type="int" />
<!-- <key-property name="ClientNumClient" column="client_num_client" type="int" /> -->
<many-to-one name="ClientNumClient"
column="client_num_client"
unique="true"
not-null="true"/>
<!-- <key-property name="InterimaireMatricule" column="interimaire_matricule" type="int" /> -->
<many-to-one name="InterimaireMatricule"
column="interimaire_matricule"
unique="true"
not-null="true"/>
</composite-id>
<property type="int" not-null="true" name="TypeAvenantId" column="type_avenant_id" />
<property type="int" not-null="true" name="QualificationId" column="qualification_id" />
<property type="int" not-null="true" name="StatutContratId" column="statut_contrat_id" />
<property type="DateTime" not-null="true" name="DateAvenant" column="date_avenant" />
<property type="boolean" not-null="true" name="TacheRisque" column="tache_risque" />
<property type="boolean" not-null="true" name="Intemperie" column="intemperie" />
<property type="boolean" not-null="true" name="Risque" column="risque" />
<property type="boolean" not-null="true" name="SurveillanceMedical" column="surveillance_medical" />
</class>
</hibernate-mapping>
|
Pour client :
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<!--Built with MyGeneration/Template/NHibernate (c) by OHM (alvy77@hotmail.com)
based on NHibernate lujan99 0.9.20 (c) by lujan99@usa.net-->
<class name="adecco.Entities.Client,adecco" table="client" lazy="false">
<id name="NumClient" column="num_client" type="int">
<generator class="native" />
</id>
<property type="int" not-null="true" name="SecteurActiviteId" column="secteur_activite_id" />
<property type="int" not-null="true" name="RaisonSocialId" column="raison_social_id" />
<property type="string" length="255" name="Adresse" column="adresse" />
<property type="string" length="14" name="NumSiret" column="num_siret" />
<property type="string" length="10" name="Telephone" column="telephone" />
<one-to-one name="contrat"
property-ref="NumClient"/>
</class>
</hibernate-mapping>
|
Pour Interimaire :
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<!--Built with MyGeneration/Template/NHibernate (c) by OHM (alvy77@hotmail.com)
based on NHibernate lujan99 0.9.20 (c) by lujan99@usa.net-->
<class name="adecco.Entities.Interimaire,adecco" table="interimaire" lazy="false">
<id name="Matricule" column="matricule" type="int">
<generator class="native" />
</id>
<property type="int" not-null="true" name="RoutagePaieId" column="routage_paie_id" />
<property type="string" not-null="true" length="20" name="Nom" column="nom" />
<property type="string" not-null="true" length="255" name="LieuEditionContrat" column="lieu_edition_contrat" />
<property type="DateTime" not-null="true" name="DateNaissance" column="date_naissance" />
<property type="boolean" not-null="true" name="Retraite" column="retraite" />
<one-to-one name="contrat"
property-ref="Matricule"/>
</class>
</hibernate-mapping>
|
Si quelqu'un voit comment faire, ce serai d'un grand secours...
Cordialement.