做调整。
编写测试类Test
package test;
import java.util.List;
import Dao.DeptDAO;
import entity.Dept;
publicclass Test { }
/**
* @param args */
publicstaticvoid main(String[] args) { }
// TODO Auto-generated method stub DeptDAO deptDao=new DeptDAO(); List
System.out.println(\部门名称:\+dept.getDname()); }
【补充】hibernate.cfg.xml,添加配置参数
hbm2ddl.auto,从实体类POJO及实体映射文
件生成数据库表。
create,表示启动时先drop,再create
create-drop,也表示创建,在系统关闭前执行一次drop
update,启动时会检查scheme是否一致,如不一致会做scheme更新
validate,启动时验证现有scheme与你配置的hibernate是否一致,如果不一致就抛出异常,并不做更新
【提示】tcreatetable.java代码如下:
package test;
import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration;
publicclass tcreatetable { }
publicstaticvoid main(String[] args) { }
// TODO Auto-generated method stub
Configuration conf=new Configuration().configure(); SessionFactory sf=conf.buildSessionFactory();