读书人

用hibernate透过xml文件建表

发布时间: 2012-09-27 11:11:17 作者: rapoo

用hibernate通过xml文件建表
1 编写java类




3 在hibernate.hbm.xml文件中添加
<property name="hbm2ddl.auto">create</property>
<mapping resource="com/student/bean/Course.hbm.xml"/>

package com.student.hibernate;import org.hibernate.cfg.Configuration;import org.hibernate.tool.hbm2ddl.SchemaExport;public class Test {    public static void main(String args[])throws Exception{    Configuration cfg=new Configuration().configure();    SchemaExport export=new SchemaExport(cfg);    export.create(true, true);    }}


5 运行main,即可建表course

读书人网 >XML SOAP

热点推荐