首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > XML SOAP >

用hibernate透过xml文件建表

2012-09-27 
用hibernate通过xml文件建表1 编写java类3 在hibernate.hbm.xml文件中添加 property namehbm2ddl.auto

用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

热点排行