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.  [ 3 posts ] 
Author Message
 Post subject: Changing the discriminator
PostPosted: Fri Jan 02, 2009 10:55 am 
Beginner
Beginner

Joined: Sat Oct 18, 2008 10:25 am
Posts: 30
Hi,

I have a class hierarchy. The superclass in Person. It has a subclass Lodger which has a subclass Alumni.

When a lodger move out, he becomes an alumni. An alumni can come back and move in again, then he becomes a lodger. I mapped the hierarchy with a discriminator and everythings work fine.

When I want to change a lodger to an alumni or contrary, I have to change the discriminator from "l" to "a" respectively from "a" to "l".

Is there a simple way to achieve this?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 02, 2009 4:41 pm 
Red Hat Associate
Red Hat Associate

Joined: Mon Aug 16, 2004 11:14 am
Posts: 253
Location: Raleigh, NC
IMO this is a bad use for inheritance. Subclasses reflect a specialization of their superclass and in this case you've got a single entity that has multiple states. I'd consider factoring out the extra information on that sub-subclass and storing it in an optional many-to-one associated entity. This way when the status changes you can remove the extra info and change a flag.

Sorry for not answering your initial question -- but think of how this could work in Java (it can't; you can't just make some object into another).

-Chris

_________________
Chris Bredesen
Senior Software Maintenance Engineer, JBoss


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 03, 2009 10:09 am 
Beginner
Beginner

Joined: Sat Oct 18, 2008 10:25 am
Posts: 30
Hi Chris,

thank you for your answer.

Then I will try it in the way you described.

Greetings,

Christopher


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.