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: Dynamic subtypes
PostPosted: Fri May 02, 2008 8:30 am 
Newbie

Joined: Fri May 02, 2008 8:18 am
Posts: 2
Hello,

I'm just starting with hibernate, my only ORM experience was with Rails' ActiveRecord. While I'm enjoying the experience so far, I have a very specific doubt that I couldn't find the answer to, anywhere.

The use case is the following: We have three entitities classes, A, B and C. C, when created, may be of A or B type depending on user input. In other words, the C inheritance hierachy may change at runtime but only in the creation (new record) process.

Another more solid example: The C class would be the "Client" class. However, "Client" may be a "Company" or "Person", depending on what the user chooses in a combo box when creating this object.

Is it bad modelling? Someone told me that a simple attribute on the client class would suffice, however, I don't feel that this way I would be leveraging OOP.

Thanks,

Marcelo.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 02, 2008 3:45 pm 
Newbie

Joined: Fri May 02, 2008 8:18 am
Posts: 2
Hi, sorry for the bump, but I really need some enlightenment here!


Top
 Profile  
 
 Post subject: suggestion
PostPosted: Sun May 04, 2008 3:59 am 
Senior
Senior

Joined: Sun Jun 11, 2006 10:41 am
Posts: 164
Create a COMPANY or a PERSON object, depending on the user input. Pass it to hibernate. Assuming you created proper mapping files, and declared the inheritence strategy correctly, hibernate will store both types appropriately. You will have to provide more detail on how to actually access this data by your application, so I can try to assist in hibernate-side design.

thanks.


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.