Hibernate3 Learning Notes (15) | Inheritance mapping

Source: Internet
Author: User
Tags inheritance mysql database

Here are 3 ways to discuss inheritance mappings in detail:

1.Table per concrete class

The inheritance relationship follows the following figure:

The data table is designed as follows:

The MySQL database performs the following DDL:

1.CREATE TABLE DefaultUser (
2. ID INT (one) not NULL auto_increment PRIMARY KEY,
3. name VARCHAR not NULL default ',
4. someproperty VARCHAR (100)
5.);
6.
7.CREATE TABLE PowerUser (
8. ID INT (one) not NULL auto_increment PRIMARY KEY,
9. name VARCHAR not NULL default ',
otherproperty VARCHAR (100)
11.);

User.java

1.package Com.hb3.pack_08.model;
2.
3.public class User {
4. 5. Private Integer ID;
6. private String name;
7.
8. Public User () {
9. }
Ten. Public Integer getId () {
return ID;
. }
Public void SetId (Integer id) {
this.id = ID;
. }
Public String GetName () {
return name;
. }
Public void SetName (String name) {
this.name = name;
A. }
23.}

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.