I have it working this way:
Code:
/**
* @hibernate.class table="organization"
*/
public class Organization implements Serializable
{
...
/**
* @hibernate.id generator-class="native" column="id" type="long" unsaved-value="-1"
*/
public long getId()
{
return this.id;
}
Code:
/**
* @hibernate.joined-subclass table="client" column="organization_id"
* @hibernate.joined-subclass-key column="organization_id"
*/
public class Client extends Organization
{
...
XDoclet generated Orgnaization.hbm.xml:
Code:
<hibernate-mapping
>
<class
name="com.regul8.hibernate.organization.Organization"
table="organization"
>
<id
name="id"
column="id"
type="long"
unsaved-value="-1"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Organization.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
.....
<joined-subclass
name="com.regul8.hibernate.organization.Client"
table="client"
>
<key
column="organization_id"
/>
..........
</joined-subclass>
</class>
</hibernate-mapping>
The tables are defined like this:
Code:
CREATE TABLE `organization`
(
`id` int(11) NOT NULL auto_increment,
PRIMARY KEY (`id`),
)
Code:
CREATE TABLE `client`
(
`organization_id` int(11) NOT NULL,
KEY `organization_id` (`organization_id`),
CONSTRAINT `client_ibfk_1` FOREIGN KEY (`organization_id`) REFERENCES `organization` (`id`)
)
This works absolutely fine :-)