[计算机软件及应用]hibernate.ppt

[计算机软件及应用]hibernate

利用Hibernate提供的工具类来创建数据库表 创建CreateDB类 public class CreateDB { public static void main(String[] args) throws Exception{ //读取配置文件 Configuration cfg = new Configuration().configure(); //创建SchemaExport对象 SchemaExport export = new SchemaExport(cfg); //创建数据库表 export.create(true,true); } } * * 单向关联中: 对于给定的Order对象,如果想获得与它关联的Customer对象: Customer customer = order.getCustomer(); 对于给定的Customer对象,如果想过的与它关联的Order对象就需要调用HibernateAPI了: String hql = from Order o where o.customer.id=?; orderList = session.createQuery(hql).setInteger(0, customer.getId()).list(); 这样做的原因是: Customer对象不与Order对象关联 关

文档评论(0)

1亿VIP精品文档

相关文档