The Artima Developer Community
Sponsored Link

Design Forum
To use inheritance or not

1 reply on 1 page. Most recent reply: Mar 4, 2004 10:28 AM by Twice Tshwenyane

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Twice Tshwenyane

Posts: 2
Nickname: mytwice
Registered: Mar, 2004

To use inheritance or not Posted: Mar 2, 2004 12:30 AM
Reply to this message Reply
Advertisement
I'm new here and i wonder if this is the right place to ask this question.
Basically i'm in the process of developing a library system demo and plan to use hibernate for my DB layer. what i have planned to do is to convert my object model into relational. The main issue that i have concerns inheritance.


I have so far identified 2 inheritance hierarchies involving the users of the library system and the library items. I have a normal LibraryUser(student), MemberOfStaff(lecturer/prof) and Librarian who all inherit from LibraryMember. I also have Book, Journal, CD-ROM and Tape who all inherit from LibraryItem.


One of the main problem is should i map all the inheritance hierarchies to a single table or each concrete class to a table or each class to a table? In case of hibernate i think that is a case of using either sub-class or joined-sub-class or just class.


At the code level(domain object) my confusion lies here:

[b]either[/b]
public class user 
{
 .....
  Set borrowedBooks;
  Set borrowedCDs;
  ....
  settters/getters
  .......
}

in the above case i think i'll be using separate tables and it'll be easier to add items like books,journals..


[b]OR[/b]

[code]
public class user
{
.....
Set borrowedLibraryItems;
....
settters/getters
.......
}

[/code]
In this case i'm representing borrowed items using the superclass. With this scenario how would i insert/retrieve a specific item(as a libraty item might be a book journal/book/cd ?).


the other thing in this dilemma is that any one(staff and librarian) except the student can borrow a journal.


So my main questions/confusion, should i map to a single table for hierarchies or several tables and should i maitain references using the sperclass or subclasses?


Twice Tshwenyane

Posts: 2
Nickname: mytwice
Registered: Mar, 2004

Re: To use inheritance or not Posted: Mar 4, 2004 10:28 AM
Reply to this message Reply
Ok i kind of withdraw this entry because i think it is more hibernate specific and also i'm working on it. Thanx.

Flat View: This topic has 1 reply on 1 page
Topic: Connection Pooling Error Previous Topic   Next Topic Topic: newbie-Q.  Deciding on classes

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use