-->
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: How to represent a one-to-zero-or-one association ?
PostPosted: Sun Oct 24, 2004 7:04 pm 
Newbie

Joined: Sun Oct 24, 2004 2:31 pm
Posts: 1
Hi
I have to store informations about video programs. Each program can have several descriptions, depending on the media it is published on.

A way to represent them in database would be :
Code:
program < prog_id, title, ... >
desc_a < prog_id, prop_a1, prop_a2, ... >
desc_b < prog_id, prop_b1, ... >


Mapped objects :
Code:
public class Program {
   public long id;
   public String title;
   public DescA descA;
   public DescB descB;
}
public class DescA {
   public Program prog; /* optional */
   public String propA1;
   public int propA2;
   // ...
}


descN property of a Program object should be null if this program dosn't have a desc_N description. Descriptions can be added to a previously defined program.

I didn't find a good way to map this schema and thoses classes. (the solution would be near from a table-per-subclass inheritance mapping, but inheritance is not usable here.)
Does anyone have an idea for this mapping ? Or for alternative schema/classes ?

Thanx
Pierre Tramo


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.