-->
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.  [ 1 post ] 
Author Message
 Post subject: need help to design business objects
PostPosted: Tue Sep 12, 2006 12:56 am 
Beginner
Beginner

Joined: Sat Oct 08, 2005 2:13 am
Posts: 47
Hello

Hibernate version:3.1

Mapping documents:Annotation

Name and version of the database you are using:MySql 4.5

I designed my database to be multilanguage, something like this:

table Patient_Info (id, admit_date, status, type, discharge_date)
table Patient_info_locale (patient_id, locale_id, name, family)

[name and family in second table will be inserted in different languages]

at first, I create a class for each and made a master/detail relation between them. but it made many problems for other programmers. using this strategy is very hard. because you always should challenge with the collections and there are many tables in the databse like this one. i want my programmers work with only one class not a class with a collection. I mean if I need some info from a patient I use PatientInfoLocale class and access to all attribute of patient with advantages of inheritance. I am detested using PatientInfo class and then load its collection (eg. patientInfo.getPatientInfoLocales() )

in my opinion, both patient_info and patient_info_locale are identical conceptually. so I decided to use joined inheritance strategy.

now, It buffled me. because in this strategy the subtype has the same primary key in the super type. so , for example, if the information of a patient being inserted in two different language (for example English and Russian) the primary key constraint will violated and insertion will failed.
what will happen on locale_id?

is there any other way than inheritance to solve this problem? for exmple consider these classes:

Code:
@Entity
@Table(name="patient_info")
public class PatientInfo implements Serializable {
   @Id
   private long id;

   //rest of the codes
}

@Entity
@Table(name="patient_info_locale")
@IdClass(PatientInfoLocalePk.class)
public class PatientInfoLocale extends PatientInfo {

    @Id
    private long id;
    @Id
    private int localeId;


   //rest of the codes
}


but in second table there is no field of parent table (except id as a foreign key)

how can I use inheritance advantages in this situation?
please help me out.

thank you so much in advance.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.