-->
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: Can a class have 2 One-to-One Mapping
PostPosted: Sat Dec 04, 2010 12:37 pm 
Newbie

Joined: Thu Dec 02, 2010 11:36 am
Posts: 2
Hi all,
I am using struts2 + hibernate for my current project
I have a student table which has following data
a) serialno <primary key>
b) firstname
c) lastname

I have a registration table which has following data
a) id <primary key>
b) serialno <this is the serial no from the student table>
c) registrationno

I have a demanddraft table which has following data
a) id <primary key>
b) serialno <this is the serial no from the student table>
c) demanddraftno

My condition is as follows.
1) Create the student
2) Create a registration for the student based on serial_no
3) Create a demand draft for the student based on serial_no

My problems is as below
1) There is one-to-one mapping between student and registration and also student and demand draft.
How to do this ?
2) What is the best approach for this kind of design ?


Regards,
Vanlal

Code:
@Entity
@Table(name = "student")
public class Student implements Serializable {
     
   private RegistrationInfo regninfo;
   
   public void setRegninfo(RegistrationInfo regninfo) {
      this.regninfo = regninfo;
   }

   @OneToOne
   @JoinColumn(name="regninfo_id")
   public RegistrationInfo getRegninfo() {
      return regninfo;
   }

   private DDInfo ddinfo;
   
   @OneToOne
   @JoinColumn(name="ddinfo_id")    
   public DDInfo getDdinfo() {
      return ddinfo;
   }

   public void setDdinfo(DDInfo ddinfo) {
      this.ddinfo = ddinfo;
   }


Top
 Profile  
 
 Post subject: Re: Can a class have 2 One-to-One Mapping
PostPosted: Mon Dec 06, 2010 9:36 am 
Newbie

Joined: Tue Sep 21, 2004 11:21 am
Posts: 8
seems ok.
you can have multiple mappings.


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.