-->
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: One-to-one mapping
PostPosted: Thu Jan 10, 2008 8:08 pm 
Newbie

Joined: Thu Jan 10, 2008 7:48 pm
Posts: 3
I have tables:

User
-userId PK
-username
-password

Student
-studentId PK
-firstname
-secondname
-dateofbirth
-userId

Teacher
-teacherId PK
-name
-phone
-email
-userId

Parent
-parentId PK
-name
-address
-phone
-userId

I want join table like this:

USER <--one-to-one--> STUDENT (with userId)
USER <--one-to-one--> PARENT (with userId)
USER <--one-to-one--> TEACHER(with userId)

How can I do it?? Do I must us <union-subclass> or <joined-subclass> or something like this??


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 11, 2008 6:36 am 
Newbie

Joined: Fri Jan 11, 2008 5:50 am
Posts: 9
What are you wanting to know? How to write the Hibernate Mapping document?

I'll start you off...

Code:
<class name="user">
    <id name="id" type="long">
        <generator class="native"/>
    </id>
    <property name="username" />
    <property name="password" />
</class>

<class name="student">
    <id name="studentId">
        <generator class="native"/>
    </id>
    <property name="firstname" />
    <property name="secondname" />
    <property name="dateofbirth" />
    <one-to-one name="userId"
        class="user" />
</class>


Hope this helps

Andy[/code]


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.