程序员通过Hibernate_tool生成代码和映射文件
它支持Eclispe插件方式和Ant方式。这里主要将采用Ant方式。这样可以脱离Eclipse:) 1,准备好Hiberbate.cfg.xml.主要是告诉工具取哪的数据库和表格
它支持Eclispe插件方式和Ant方式。这里主要将采用Ant方式。这样可以脱离Eclipse:)
1,准备好Hiberbate.cfg.xml.主要是告诉工具取哪的数据库和表格
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEhibernate-configurationPUBLIC
"-//Hibernate/HibernateConfigurationDTD3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<propertyname="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<propertyname="hibernate.connection.password">tt</property>
<propertyname="hibernate.connection.url">jdbc:oracle:thin:@10.1.248.23:1521:tt</property>
<propertyname="hibernate.connection.username">tt</property>
<propertyname="hibernate.default_schema">tt</property>
<propertyname="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property>
</session-factory>
</hibernate-configuration>
2,编写Ant脚本。这一步是要定义ant任务,以及生成POJO和HBM.XML配置文件
<taskdefname="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="project.class.path"/>
<targetname="hibernatecode">
<hibernatetooldestdir="E:\gg\yy\3123\src">
<jdbcconfigurationconfigurationfile="E:\gg\yy\3123\build\hibernate.cfg.xml"packagename="com.tt.wss.hibernate"
/>
<hbm2java>
<hbm2dao>
</hibernatetool>
</target>
<targetname="hibernatehbm">
<hibernatetooldestdir="E:\gg\yy\3123\src">
<jdbcconfigurationconfigurationfile="E:\gg\yy\3123\build\hibernate.cfg.xml"packagename="com.asia.wss.hibernate"
/>
<hbm2hbmxml>
</hibernatetool>
</target>
相关推荐:
| 软考各科备考资源 | ||
| 资源名称 | 获取方式 | 资源链接 |
| 2026下半年软考各科考试真题汇总 | 免费下载 | 点击获取 |
| 2026年5月高项各科真题汇总 | 免费刷题 | 点击获取 |
| 2026年10月第二批集成基础知识真题 | 免费下载 | 点击获取 |
| 2026年下半年 软件设计师基础知识真题 | 免费下载 | 点击获取 |
| 2026上半年软考各科真题答案汇总 | 免费下载 | 点击获取 |
| 【历年真题】软考各科历年真题答案解析汇总 | 免费刷题 | 点击刷题 |
| 更多软考备考资料请点此查看 | ||