CREATE TABLE ph_diadoracommunity_users (
u_id int(10) unsigned NOT NULL default '0',
name varchar(10) ,
email varchar(10) ,
PRIMARY KEY (u_id),
KEY u_id (u_id)
) TYPE=MyISAM;
CREATE TABLE ph_diadoracommunity_users_lv1 (
u_id int(10) unsigned default '0',
address varchar(30) default '0',
KEY u_id (u_id)
) TYPE=MyISAM;
CREATE TABLE ph_diadoracommunity_users_lv2 (
u_id int(10) unsigned NOT NULL default '0',
code varchar(10) default '0',
PRIMARY KEY (u_id),
KEY u_id (u_id)
) TYPE=MyISAM;
The mapping:
<hibernate-mapping>
<class name="ph.news.model.UtenteBase" table="ph_diadoracommunity_users" >
<id name="id" type="int" column="u_id" unsaved-value="0">
<generator class="identity"/>
</id>
<property name="name"/>
<property name="email"/>
<joined-subclass name="ph.news.model.UtenteLivello1" table="ph_diadoracommunity_users_lv1">
<key column="u_id"/>
<property name="address"/>
<joined-subclass name="ph.news.model.UtenteLivello2" table="ph_diadoracommunity_users_lv2">
<key column="u_id"/>
<property name="code"/>
</joined-subclass>
</joined-subclass>
</class>
</hibernate-mapping>
I don't know if this is the right way to model this situation (I think NO) but note that a ph.news.model.UtenteLivello1 (UserLevel1) MUST BE ALSO a ph.news.model.UtenteBase (BaseUser)
|