-->
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.  [ 3 posts ] 
Author Message
 Post subject: One-to-one parent-enfant
PostPosted: Mon May 14, 2007 1:47 pm 
Newbie

Joined: Mon May 14, 2007 1:44 pm
Posts: 4
Bonjour,

J'ai, dans ma base de données, une relation parent-enfant, c'est-à-dire:

La table A contient une clé étrangère qui pointe sur la clé primaire de cette même table A.

Dans le java, ça devrait donner un objet A contenant un objet A (qui est son père). Quelqu'un peut-il m'aider pour réaliser ce genre de gymnastique au niveau du fichier de mapping ?

Merci d'avance.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 15, 2007 11:46 am 
Beginner
Beginner

Joined: Wed Oct 25, 2006 9:05 am
Posts: 40
Location: France, Lieusaint
Pour une one-to-many le mapping est le suivant:

Code:
<hibernate-mapping>
    <class name="Pere" table="TABLE_PERE"  >
        <id name="code">
            <column name="PK_CODE" length="10" />
            <generator class="assigned" />
        </id>
        <one-to-many name="groupeParent" class="Pere"
           fetch="select"
           cascade="save-update">
            <column name="FK_PERE_CODE" length="10" />
        </one-to-many>
        <property name="libelle">
            <column name="LIBELLE" />
        </property>
    </class>
</hibernate-mapping>


et la table PERE:



Quote:
1 PK_CODE CHAR(10 BYTE) Y
2 LIBELLE VARCHAR2(80 BYTE)
3 FK_PERE_CODE CHAR(10 BYTE)


Pour une <one-to-one> je pense qu'il suffit de remplacer <one-to-many> .


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 17, 2007 4:41 am 
Newbie

Joined: Mon May 14, 2007 1:44 pm
Posts: 4
Merci, j'essayais en fait d'utiliser une relation one-to-one.
Ta réponse m'a aidé à voir que je faisais n'importe quoi ! :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.