David,
Syntax wise I think something similar to:
Code:
<table name="users" extends="employees"/>
would work nicely.
As for sample hbms the only changes I make between the standard hbm.xml generated by the Middlegen plugin and my inhertance classes are:
1) rename <class></class> to <joined-subclass></joined-subclass>
2) replace the <id></id> element with a <key></key> element
3) remove the one-to-one association links between both the parent and children classes
Samples:
Code:
Employee.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class
name="com.warfrog.hibernate.Employee"
table="employees"
>
<id
name="employeeId"
type="java.lang.Integer"
column="employee_id"
>
<generator class="native" />
</id>
<property
name="active"
type="java.lang.Boolean"
column="active"
not-null="true"
length="1"
>
<!-- Associations -->
<!-- bi-directional one-to-one association to User -->
<one-to-one
name="user"
class="com.warfrog.sterling.brokeronline.hibernate.User"
outer-join="auto"
cascade="delete"
/>
...other associations and properties removed...
</class>
</hibernate-mapping>
User.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class
name="com.warfrog.hibernate.User"
table="users"
>
<id
name="userId"
type="java.lang.Integer"
column="user_id"
>
<generator class="assigned" />
</id>
<property
name="username"
type="java.lang.String"
column="username"
not-null="true"
length="255"
/>
<property
name="password"
type="java.lang.String"
column="password"
not-null="true"
length="50"
/>
<!-- Associations -->
<!-- bi-directional one-to-one association to Employee -->
<one-to-one
name="employee"
class="com.warfrog.sterling.brokeronline.hibernate.Employee"
outer-join="auto"
constrained="true"
/>
...other associations and properties removed...
</class>
</hibernate-mapping>
Becomes
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class
name="com.warfrog.hibernate.Employee"
table="employees"
>
<id
name="employeeId"
type="java.lang.Integer"
column="employee_id"
>
<generator class="native" />
</id>
<property
name="active"
type="java.lang.Boolean"
column="active"
not-null="true"
length="1"
>
<!-- Associations -->
<!-- association to User removed -->
<joined-subclass
name="com.warfrog.hibernate.User"
table="users"
>
<key column="user_id"/>
<property
name="username"
type="java.lang.String"
column="username"
not-null="true"
length="255"
/>
<property
name="password"
type="java.lang.String"
column="password"
not-null="true"
length="50"
/>
<!-- Associations -->
<!-- association to Emploee removed -->
...other associations and properties removed...
</joined-subclass>
</class>
</hibernate-mapping>
The only other thing I can think of is making sure that multiple tables can inherit from a single parent (ex: User extends Employee, Manager extends Employee). Let me know if there's anything else I can do to help out.
Thanks again,
Tyler