Hibernate Inheritance Table structure

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.