Polymorphic ORM Classes

Is it possible to make DB-VA construct tables for each generalization of a pesistable class ??
For example, the project I am working on, I need to have three types of users; an admin user, an advisor user and a member user. Each one of these users has similar fields that are used throughout the application. Therefore, each one of the user classes should inherit certain fields from the parent. So I have a parent class called User, and the three child classes Member, Advisor and Admin extend User. In addition, User and Advisor refence a class named Address. Admins do not have addresses. When I have DB-VA generate my code and database I get this as my User.hbm.xml


<hibernate-mapping>
	<class name="com.dba.orm.models.User" table="`User`" lazy="false" discriminator-value="User">
		<id name="userId" column="`userId`" type="long" unsaved-value="0">
			<generator class="native">
			</generator>
		</id>
		<discriminator column="`Discriminator`" type="string"/>
		<property name="userPassword" column="`userPassword`" type="string" not-null="false"/>
		<property name="userEmail" column="`userEmail`" type="string" not-null="false"/>
		<property name="firstName" column="`firstName`" type="string" not-null="false"/>
		<property name="lastName" column="`lastName`" type="string" not-null="false"/>
		<property name="active" column="`active`" type="boolean" not-null="false"/>
		<property name="lastVisit" column="`lastVisit`" type="date" not-null="false"/>
		<property name="dateAdded" column="`dateAdded`" type="date" not-null="false"/>
		<subclass name="com.dba.orm.models.Admin" discriminator-value="ADMIN" lazy="false">
			<property name="adminPerms" column="`adminPerms`" type="integer" not-null="false"/>
		</subclass>
		<subclass name="com.dba.orm.models.Advisor" discriminator-value="ADVISOR" lazy="false">
			<property name="advisorType" column="`advisorType`" type="integer" not-null="false"/>
			<property name="advisorFirmName" column="`advisorFirmName`" type="string" not-null="false"/>
			<property name="advisorPosition" column="`advisorPosition`" type="string" not-null="false"/>
			<property name="advisorPhoneWork" column="`advisorPhoneWork`" type="string" not-null="false"/>
			<property name="advisorPhoneMobile" column="`advisorPhoneMobile`" type="string" not-null="false"/>
			<property name="advisorLicenseNumber" column="`advisorLicenseNumber`" type="string" not-null="false"/>
		</subclass>
		<subclass name="com.dba.orm.models.Member" discriminator-value="MEMBER" lazy="false">
			<property name="memberPhoneHome" column="`memberPhoneHome`" type="string" not-null="false"/>
			<property name="memberPhoneMobile" column="`memberPhoneMobile`" type="string" not-null="false"/>
			<property name="memberNumberVisits" column="`memberNumberVisits`" type="integer" not-null="false"/>
			<property name="memberActivationCode" column="`memberActivationCode`" type="string" not-null="false"/>
		</subclass>
	</class>
</hibernate-mapping>

and a DDL that looks like:


create table `User` (`userId` bigint not null auto_increment, `userPassword` varchar(255), `userEmail` varchar(255), `firstName`
 varchar(255), `lastName` varchar(255), `active` tinyint(1), `lastVisit` 
date, `dateAdded` date, `Discriminator` varchar(255) not null, 
`memberPhoneHome` varchar(255), `memberPhoneMobile` varchar(255),
 `memberNumberVisits` int, `memberActivationCode` varchar(255), 
`adminPerms` int, `advisorType` int, `advisorFirmName` varchar(255), 
`advisorPosition` varchar(255), `advisorPhoneWork` varchar(255), 
`advisorPhoneMobile` varchar(255), `advisorLicenseNumber` 
varchar(255), primary key (`userId`)) type=InnoDB

That is a hideously large table that doesn’t allow me to normalize any of my data. In addition there are no references to my Address class anymore. I knw hibernate can persist polymorhic sub classes to a separate table using join tables. Is it possible to tell DB-VA to do this ?? Not having this feature seems to be a fairly serious shortcoming.

Dear Jim,

I just talk to our engineers and they said we will support generation with multiple tables very soon. And for the missing relationship problem, please make sure you have defined the role name of the association ends. DB-VA needs to specify the role name for persistent the relationships. If you have any further questions, please feel free to contact us again.

Best regards,
Rain