每个具体子类映射一张表:
sql语句:
/* 每个具体子类映射一张表 */
CREATE TABLE t_concrete_bankaccount(
id NUMBER(10) PRIMARY KEY,
owner VARCHAR2(15),
code VARCHAR2(15),
created DATE,
bankname VARCHAR2(20),
bankswift VARCHAR2(20)
);
CREATE TABLE t_concrete_creditcart(
id NUMBER(10) PRIMARY KEY,
owner VARCHAR2(15),
code VARCHAR2(15),
created DATE,
credit_card_type VARCHAR2(20),
expired_month VARCHAR2(20),
expired_year VARCHAR2(20)
);
映射文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.iotek.basic.inheritance.pojo">
<class name="BillingDetails">
<id name="id" column="ID" type="long">
<generator class="sequence">
<param name="sequence">t_billing_seq</param>
</generator>
</id>
<property name="owner" type="string" column="OWNER"/>
<property name="created" type="date" column="CREATED"/>
<property name="code" type="string" column="CODE"/>
<union-subclass name="CreditCard" table="T_CONCRETE_CREDITCART">
<property name="type" type="string" column="CREDIT_CARD_TYPE" />
<property name="expMonth" type="string" column="EXPIRED_MONTH" />
<property name="expYear" type="string" column="EXPIRED_YEAR" />
</union-subclass>
<union-subclass name="BankAccount" table="T_CONCRETE_BANKACCOUNT">
<property name="bankName" type="string" column="BANKNAME" />
<property name="bankSwift" type="string" column="BANKSWIFT" />
</union-subclass>
</class>
</hibernate-mapping>
1.png
2.png