-->
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: RTM-Done, still don't get it. one-to-one mapping
PostPosted: Mon Feb 02, 2004 2:31 pm 
Newbie

Joined: Sat Jan 31, 2004 8:22 pm
Posts: 4
Hello, I have read the documentation on this, and searched the archives, maybe it is there but i could not find it.

I have one java class that has to be mapped to 2 differetn database tables.

Javaclass User
id
firstName
lastName
userName
password
role

this has to go to 2 tables.

DB table user
id (pk)
firstName
lastName
userName
password

DB table userRole
id (pk,fk)
userName
role
Code:
<hibernate-mapping>
    <class name="SystemUserDTO" table="users">
      <id name="userId" type="integer" unsaved-value="0">
         <generator class="identity"/>
      </id>
        <property name="firstName"/>
        <property name="lastName"/>
        <property name="password"/>
        <property name="userName"/>
        <property name="role"/>
    </class>
</hibernate-mapping>

Yeah its not much but I don't know what to do after this.

I really don't get the mapping of this to the database. Most of the one-to-one relationships that I see have 2 javaclasses, so this is still just a one-to-one relationship?. I might be missing something. But if someone could help me out with this, it would be appriciated.
Thanks for you time.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 02, 2004 2:33 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You need two classes, User and UserRole. Then stick to the examples. Spreading one class over two tables is not possible (may be in 2.2.)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 02, 2004 2:35 pm 
Newbie

Joined: Sat Jan 31, 2004 8:22 pm
Posts: 4
Thanks for clearing that up. and the quick responce.


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.