There is product, book, clothes three sheets
Product:id,name
book:id, Name,pagecount
clothes:id, name, Size
Create three Sheets
Product TableCreate TableProduct (id number(2)Primary Key, namevarchar2(Ten) ); Book tableCreate Tablebooktbl (id number(2), namevarchar2(Ten), PageCount number(3), Foreign Key(id)ReferencesProduct (id));Createsequence Book_seq increment by 1Start with 1nomaxvalue nominvalue nocache;CREATE TRIGGERBook_trigger beforeINSERT onBooktbl forEach ROW when(new.id is NULL)beginSelectBook_seq.nextval into: new.id fromdual;End;Drop Tablebooktbl;Dropsequence Book_seq;bropTriggerbook_trigger; Clothing TableCreate Tableclothestbl (id number(2)ReferencesProduct (id), Namevarchar2(Ten), closize number(5));Createsequence Clothes_seqincrement by 1Start with 1nomaxvalue nominvalue nocache;CREATE TRIGGERClo_triggerbeforeINSERT onClothestbl foreach ROW when(new.id is NULL)beginSelectClothes_seq.nextval into: new.id fromdual;End;Drop Tableclothestbl;Dropsequence Clothes_seq;bropTriggerclo_trigger;
Product.hlm.xml
<Class name="com.amaker.extendmodel.Product"Table="Product"> <ID Name="id"> <Generator class="native"></Generator> </Id> <Property name="name"></Property> <Joined-Subclass Name="com.amaker.extendmodel.Book"Table="booktbl"> <Key column="id"></Key> <Property name="pagecount"></Property> </Joined-Subclass> <Joined-Subclass Name="com.amaker.extendmodel.Clothes"Table="clothestbl"> <Key column="id"></Key> <Property name="size"column="closize"></Property> </Joined-Subclass> </Class>
<mapping resource= "com/amaker/extendmodel/product.hbm.xml"/>
Hibernate Inheritance Table structure