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: Mapping "one-to-one" sur clef étrangère
PostPosted: Tue Aug 22, 2006 5:12 am 
Newbie

Joined: Tue Aug 22, 2006 5:04 am
Posts: 2
Bonjour,

Je me bats depuis quelques temps afin de mapper comme je le souhaite mes objets.

Pour faire simple, disons que j'ai deux tables:
COMMANDE:
    COMMANDE_ID -> clef primaire: séquence
    LIBELLE

CLIENT:
    CLIENT_ID -> clef primaire: séquence
    COMMANDE_ID -> identifiant de la table commande
    NOM -> Nom du client


Cela correspond à un mappring 1...n mais je souhaite garder cette hierarchie de table car cela me permet de splitter mes informations de manière plus conviviable.

Le mapping me pose problème, car je souhaite accéder à mon objet client à partir de mon objet commande. Le problème est que je n'arrive pas à trouver un mapping one-to-one me permettant de faire cela.
Je ne souhaite pas récupérer ma commande à partir du client, mais uniquement mon client à partir de la commande.

Merci de votre aide.

Cordialement.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 22, 2006 3:59 pm 
Regular
Regular

Joined: Fri Aug 18, 2006 2:40 pm
Posts: 51
Location: Metz, France
Un truc comme ca
Code:
<class name="Commande" table="COMMANDE">
....
<one-to-one name"client" class="Client" property-ref="commande"/>
....
</class>

<class name="Client" table="CLIENT">
....
<many-to-one name="commande" class="Commande" column="COMMANDE_ID" unique="true"/>
....
</class>


Si ca marche un commande.getClient() devrait faire l'affaire.
cf http://www.hibernate.org/hib_docs/v3/re ... n-onetoone

_________________
Denis
Don't forget to rate ... thanks.


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.