-->
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: Implementing loose relationship
PostPosted: Tue Dec 21, 2004 4:36 pm 
Beginner
Beginner

Joined: Mon Sep 06, 2004 9:36 am
Posts: 35
Hibernate version: 2.17

In my database I have 2 tables which, in combination, represents 1 entity. But there is no foreign key relationship between these two tables.

My first table 'Frequency' has 2 columns:
frequency_id
frequency_name

My second table 'ObjectDescription' has 3 columns :
language_id
object_id
description

So if I have this data in Frequency:
frequency_id frequency_name
1 Weekly

then in ObjectDescription:
language_id object_id description
1 1 Weekly Transmission
2 1 Weekly Transmission (in French)
3 1 Weekly Transmission (in Spanish)
(where language_id '1' is English, '2' is French etc.)

At runtime I know which language_id I will be working on. My question is how to represent the Frequency class and its mapping file?

public class Frequency {
frequencyId Integer;
frequencyName String;
}


Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 21, 2004 5:30 pm 
Beginner
Beginner

Joined: Mon Sep 06, 2004 9:36 am
Posts: 35
Sorry I forget to mention another column in the second table 'ObjectDescription' :
table_name
object_id
language_id
description

and the data in ObjectDescription is like this :

table_name, object_id, language_id, description
--------------------------------------------------------
FREQUENCY, 1, 1, Weekly Transmission
FREQUENCY, 1, 2, Weekly Transmission (in French)
FREQUENCY, 1, 3, Weekly Transmission (in Spanish)

the query to get the complete Frequency is :

declare @v_Language int
set @v_Language = 1

SELECT f.frequency_id, f.frequency_name, od.description
FROM frequency f, objectdescription od
WHERE f.frequency_id = od.object_id
and od.table_name = 'FREQUENCY'
and f.language_id = @v_Language

Normal users can only read/query these tables. So if a normal user A login for English then he will see only the English Description;

A Super user can update these tables. So a super user B can see and update English/French/Spanish translations.

I am going to use a DAO Layer. So I was thinking about the best design for these classes. Any input?

Thanks


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.