Hibernate 继承表结构
有Product , Book ,Clothes三张表
Product:id,name
Book: id ,name,pageCount
Clothes: id ,name ,size
创建三张表
产品表
create table product(
id number(2) primary key,
name varchar2(10)
);
书表
create table booktbl(
id number(2) ,
name varchar2(10),
pageCount number(3),
foreign key(id) references product(id)
);
create sequence book_seq
increment by 1
start with 1
nomaxvalue nominvalue nocache; CREATE TRIGGER book_trigger BEFORE
INSERT ON booktbl FOR EACH ROW WHEN(new.id is null)
begin
select book_seq.nextval into:new.id from dual;
end; drop table booktbl;
drop sequence book_seq;
brop trigger book_trigger; 服装表
create table clothestbl(
id number(2) references product(id),
name varchar2(10),
closize number(5)
); create sequence clothes_seq
increment by 1
start with 1
nomaxvalue nominvalue nocache; CREATE TRIGGER clo_trigger
before
INSERT ON clothestbl
FOR EACH ROW
WHEN(new.id is null)
begin
select clothes_seq.nextval into:new.id from dual;
end; drop table clothestbl;
drop sequence clothes_seq;
brop trigger clo_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 继承表结构的更多相关文章
- Hibernate笔记——表的的4种继承关系
原文:http://justsee.iteye.com/blog/1070588 ===================================== 一.继承关系_整个继承树映射到一张表 对象 ...
- 为什么要用hibernate 与基于数据库表结构的项目开发
最近开始学习hibernate,其实并不知道要学习什么,有什么用.后来问了一下同事,他就说快捷方便简单,很多事情不用自己做他会帮你做好,但是我觉得不应该是这样的,于是我就去搜了一下,就搜到了一篇帖子, ...
- Hibernate之SchemaExport+配置文件生成表结构
首先要生成表,得先有实体类,以Person.java为例: /** * * @author Administrator * @hibernate.class table="T_Person& ...
- 菜鸟学SSH(十一)——Hibernate之SchemaExport+配置文件生成表结构
今天说点基础的东西,说说怎样通过SchemaExport跟Hibernate的配置文件生成表结构.事实上方法很easy,仅仅须要两个配置文件,两个Java类就能够完毕. 首先要生成表,得先有实体类,以 ...
- 菜鸟学SSH(十二)——Hibernate与Spring配合生成表结构
前几天向大家介绍了一种用工具类生成数据表的方法,只是之前的方法须要使用一个跟项目关系不大的工具类.不免让人认为有些多余,所以呢.今天再向大家介绍一种方法.即Hibernate与Spring配合生成表结 ...
- Hibernate由model类自动同步数据库表结构
在开发中遇到了个问题,每次测试数据库增加表结构的时候,本地pull下最新代码导致启动报错,上网搜了快速解决办法---->hibernate 配置属性中,hibernate.hbm2ddl.aut ...
- Hibernate使用自定义脚本替换注解或者xml文件中的自动生成表结构
本文作者:苏生米沿 本文地址:http://blog.csdn.net/sushengmiyan/article/details/50534361 我们都清楚,可以使用hibernate的metada ...
- hibernate.hbm2ddl.auto=update不能自动生成表结构
在写上篇文章<spring整合springmvc和hibernate>的时候,曾遇到一个问题 INFO: Server startup in 8102 ms Hibernate: inse ...
- Hibernate中:不看数据库,不看XML文件,不看查询语句,怎么样能知道表结构?
Hibernate中:不看数据库,不看XML文件,不看查询语句,怎么样能知道表结构? 解答:可以看与XML文件对应的域模型.
随机推荐
- JS页面延迟执行一些方法(整理)
一般在JS页面延迟执行一些方法.可以使用以下的方法 jQuery.delay()方法简介 http://shawphy.com/2010/11/jquery-delay.html jQuery中que ...
- 过滤字符串html标签方法
过滤字符串html标签方法,如果输入的过滤标签为“*”,那么给字符串加上p标签 public static string noTagHtml(string str, string tagname) { ...
- C#入门经典第七章,错误调试
调试模式下执行应用程序-------F5或是绿色的运行箭头 非模式下,调试---开始执行不调试(ctrl+F5)
- postgres 错误duplicate key value violates unique constraint 解决方案
SELECT setval('tablename_id_seq', (SELECT MAX(id) FROM tablename)+1) 主要是:serial key其实是由sequence实现的,当 ...
- Sonya and Problem Wihtout a Legend
Sonya and Problem Wihtout a Legend Sonya was unable to think of a story for this problem, so here co ...
- iOS启动屏 ➕ 闪屏的方法
转载自:http://www.starming.com/index.php?v=index&view=21 在- (BOOL)application:(UIApplication *)appl ...
- Java对数函数及Java对数运算
Java对数函数及Java对数运算 2010-05-17 10:32 中国IT实验室 佚名 关键字:Java Java对数函数的计算方法非常有问题,然而在API中却有惊人的误差.但是假如运用了 ...
- Express静态服务器
做应用的时候,如果需要给人测试,需要搭建本地服务器: 下载apache tomcat,各种配置,复杂得很. 之前在网上找到python的实现,在文件夹内运行一行代码就可以了,但是可惜,本机访问都很慢. ...
- 皓轩的jquery mobile之路(二)
jQuery Mobile 使用 HTML5 & CSS3 最小的脚本来布局网页. 编写代码要注意最外层div需要添加data-role="page" ,标题需要添加dat ...
- mysql优化---优化工具MySQL performance tuning primer script
MySQL performance tuning primer script一个简单好用的mysql优化工具,其实一个shell脚本 下载: $ wget http://www.day32.com/M ...