-->
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: Is there a design pattern for this...?
PostPosted: Sat Jan 10, 2004 10:06 am 
Newbie

Joined: Sat Jan 10, 2004 9:30 am
Posts: 1
Hi there !

Imagine that in your application you want to manage documents. For this you have in your database a DOCUMENTS table. This table has a column named DOC_TYPE. As the name says, this colomn gives the type of the document (for exemple txt, doc, xls, ppt , htm...).

On the java side you have a Document class mapped to this DOCUMENTS table. But we also have subclasses like TxtDocument, DocDocument, XlsDocument... inheriting from the Document class.

What I would like to do, is to get a list of documents, but this list will not contain Document objects, but the corresponding Document sublcass of the DOCUMENTS.TYPE field.

For exemple, if DOCUMENT.TYPE = 'doc' -> DocDocuement class, if DOCUMENT.TYPE = 'xls' -> XlsDocument class....

Any idee of how to implement it ?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 10, 2004 10:32 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Well, just map the subclasses like described in the Hibernate Reference, see http://www.hibernate.org/hib_docs/reference/html/or-mapping.html#or-mapping-s1-11 and http://www.hibernate.org/hib_docs/reference/html/inheritance.html - Where is the Problem?


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.