aspose file tools*
The moose likes Object Relational Mapping and the fly likes is there a way to map an abstract class without creating a table for it? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "is there a way to map an abstract class without creating a table for it?" Watch "is there a way to map an abstract class without creating a table for it?" New topic
Author

is there a way to map an abstract class without creating a table for it?

Elhanan Maayan
Ranch Hand

Joined: May 04, 2009
Posts: 113
hi

we have an abstract class which only has an id and a few properties of create update date etc..

all entities must extends this class, is there a way to create an hbm file for this but NOT create a table for it?

i don't want to create a huge hbm file for these classes


also is there a way to map java 5 enum type? i know there is Enumerated annoation, but what is it's equvalent in hbm? or do i have to extend userType for this?
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

all entities must extends this class, is there a way to create an hbm file for this but NOT create a table for it?


Well, if you used a table-per-class strategy, only one table would be created for all subtypes. That would sorta solve your problem.

-Cameron McKenzie
Elhanan Maayan
Ranch Hand

Joined: May 04, 2009
Posts: 113
that exactly what i don't want to do, i want each subtype to have it's own table, but the super type should have no table, i only want to reuse the property mappings.
sudheer kiran
Ranch Hand

Joined: Jun 26, 2008
Posts: 237

when making a table for each subclass then you can access all data.
why you need to map abstract class.
i think you dont need to map abstract class and no need of any table.


Sudheer
SCWCD, SCJP 5
Elhanan Maayan
Ranch Hand

Joined: May 04, 2009
Posts: 113
my original intention was to avoid mapping column and property duplication from an abstract class
Christian Dillinger
Ranch Hand

Joined: Jul 20, 2009
Posts: 189
Yes you can...



with a subclass like that:



You have to have the named generator in every subclass because it seems to invisible in subclasses if you declare it only in the superclass.

Sorry, didn't see that you asked for the xml-solution... But maybe this works the same way. Have to check it...
Elhanan Maayan
Ranch Hand

Joined: May 04, 2009
Posts: 113
then what is managed entity annotation? at first ithought union-sublclass would fit but i cannot use discriminator col wih it and icannot mix annotations with xml
 
wood burning stoves
 
subject: is there a way to map an abstract class without creating a table for it?