-->
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: table mapping with runtime object type ?
PostPosted: Wed Jun 07, 2006 3:37 am 
Regular
Regular

Joined: Wed Mar 08, 2006 2:07 am
Posts: 50
Location: Bangalore
Hi,

I had a question in mind...

suppose my entire framework is working and using an classes by name SuperA , SuperB, SuperC ... SuperZ (assume they have on 'id' key field, there is no hibernate mapping file for these classes).


Now I add a jar '1.jar' which extends Super[A-Z] and has class names like SubA1 , SubB1 , SubC1 ... SubZ1. These classes have hbm files with table mapping into some db. These can have its own set of attributes.

But suppose now I create only more child hierarchy and try to replace '1.jar' with '2.jar' which extends Super[A-Z] and has class names like SubA2 , SubB2, SubC2 ... SubZ2. These classes also have their hbm files and map to some table in some db.


Now what I am expecting is ...
sample code :

Code:
SuperA implementation = getA();
juggleA(implementation);
session.save(implementation);



Now depending on what implementation is returned by getA() ... I would want hibernate to insert 'implementation' object into its respective table.

Is that possible .. ??

_________________
Prashant Jain

... right now I am in need of some credits !


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 07, 2006 8:13 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Yes. It's impossible not to do that, as Hibernate uses mappings based on the object's class, not the variable's type. That is, hibernate completely ignores that fact that implementation is treated as a SuperA by your code, it uses only implementation.getClass() to determine what mapping to use.

_________________
Code tags are your friend. Know them and use them.


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.