发布时间: 2012-08-03 00:12:14 作者: rapoo
Hibernate继承映射方式一
继承映射方式一:一个子类一张表 ,一张表对应一个配置文件
场景:父类person,子类student、teacher
Person.java
Teacher.hbm.xml
测试类:
package com.fgh.hibernate;import org.hibernate.Session;import org.hibernate.SessionFactory;import org.hibernate.Transaction;import org.hibernate.cfg.Configuration;public class ExtendMappingTest {private static SessionFactory sessionFactory;static {try {sessionFactory = new Configuration().configure().buildSessionFactory();} catch (Exception e) {e.printStackTrace();}}public static void main(String[] args) {Session session = sessionFactory.openSession();Transaction tx = null;try {tx = session.beginTransaction();Student student = new Student();student.setName("zhangsan");student.setCardId("213421342");Teacher teacher = new Teacher();teacher.setName("lilaoshi");teacher.setSalary(4000);session.save(student);session.save(teacher);tx.commit();} catch (Exception e) {e.printStackTrace();if (null != tx) {tx.rollback();}} finally {session.close();}}}
关于连通图的有关问题这道题小弟我直
多矩形切割拼接原材料固定,该如何处
字符串变换有关问题
DFS有序数列的全排列
一个栈的输入序列为a,b,c,d若在入栈
发个算法题解决方案
微软谷歌的一道面试题:怎么分隔没有空
位图排序的有关问题
求解分枝定界算法解决思路
后缀表达式,该怎么解决