-->
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: Polymorphism in the same table.
PostPosted: Mon Oct 24, 2005 5:45 am 
Newbie

Joined: Mon Oct 24, 2005 5:33 am
Posts: 1
I know that this might sound strange but due to constraints on the DB this is the way it must be.
What we are trying to do is persist information from an objects state to the DB. This basically involves the state pattern.
For example we have a DoorState which is an interface. This DoorState is implemented by two concrete states (DoorOpen and DoorClosed). The state context object is the Door class.
This might seem simple to persist to the DB using two tables but the problem we have is that it must be persisted to 1 DB.
Ie the Door class’s number attribute is mapped to the DOOR table’s NUMBER column; then the DoorState description attribute is mapped to the DOOR table’s DESC column.
So far things that we have tried range from using hibernates’ subclass inheritance mapping to persist the DoorState; unfortunately this means we have to have to have a separate table for the states. Another approach is to use the component element. This provides the functionality of putting the information into the same table but does not seem to support polymorphism.

The example is pretty simple here but it is being implemented in a more functional way.

Any help would you greatly appreciated.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 24, 2005 9:01 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
As I understand "State" instance has no state in this design pattern (context is a persistent object)


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.