Hibernate3中的hbm2java和hbm2ddl的ant脚本实现
来源:互联网 发布:linux reboot失效 编辑:程序博客网 时间:2024/04/19 02:57
最近在看那个很火的《精通Hibernate》,发现里面都是针对hibernate2.1进行讲解了,但我们用的是hibernate3.1,很多地方都不一样,原来的那些hbm2ddl,hbm2java的脚本都不管用了,于是到处查资料,折腾了两天,终于搞定了,希望后来人不要再走弯路。
<taskdef name="hbm2ddl"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="project.class.path"/>
<hbm2ddl destdir="${ schema.dir }">
<configuration configurationfile="${ source.root }/hibernate.cfg.xml" />
<hbm2ddl export="true" console="false" create="true" update="false" drop="false" outputfilename="bestunix.sql"/>
</hbm2ddl>
</target>
<taskdef name="hbm2java"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="project.class.path"/>
<hbm2java destdir="${ source.root }">
<configuration configurationfile="${ source.root }/hibernate.cfg.xml" />
<hbm2java generics="true" ejb3="false"/>
<cfg2hbm/>
</hbm2java>
</target>
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="project.class.path"/>
<hibernatetool destdir="${ source.root }">
<configuration configurationfile="${ source.root }/hibernate.cfg.xml" />
<hbm2ddl export="true" console="false" create="true" update="false" drop="false" outputfilename="bestunix.sql"/>
<hbm2java generics="true" ejb3="false"/>
<cfg2hbm/>
</hibernatetool>
</target>
1.Hibernate-tools.jar这个包已经不像以前那么好找了,现在是放在hibernate-tools这个eclipse插件里面,用的时候要从里面搜索一下才能找到。
2.Hibernate-tools这个插件的用法,见官方网站的flash演示,使用非常方便。
Ant脚本已经跟2有很大差别了,这个我折腾了一天多,终于搞定了,贴出来大家看一下,更详细的信息可以看 http://www.hibernate.org/hib_docs/tools/ant/
Hbm2ddl:
<taskdef name="hbm2ddl"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="project.class.path"/>
<hbm2ddl destdir="${ schema.dir }">
<configuration configurationfile="${ source.root }/hibernate.cfg.xml" />
<hbm2ddl export="true" console="false" create="true" update="false" drop="false" outputfilename="bestunix.sql"/>
</hbm2ddl>
</target>
Hbm2java :
<taskdef name="hbm2java"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="project.class.path"/>
<hbm2java destdir="${ source.root }">
<configuration configurationfile="${ source.root }/hibernate.cfg.xml" />
<hbm2java generics="true" ejb3="false"/>
<cfg2hbm/>
</hbm2java>
</target>
同时完成两个任务:
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="project.class.path"/>
<hibernatetool destdir="${ source.root }">
<configuration configurationfile="${ source.root }/hibernate.cfg.xml" />
<hbm2ddl export="true" console="false" create="true" update="false" drop="false" outputfilename="bestunix.sql"/>
<hbm2java generics="true" ejb3="false"/>
<cfg2hbm/>
</hibernatetool>
</target>
3. 用来生成html格式的数据库文档<hbm2doc>在ant脚本中好像暂时不行,还是要借助Hibernate-tool这个Eclipse插件来完成
- Hibernate3中的hbm2java和hbm2ddl的ant脚本实现
- Hibernate3中的hbm2java和hbm2ddl的ant脚本实现(转)
- hibernate3下hbm2ddl和hbm2java的配置
- hibernate3.2 hbm2java hbm2ddl
- hbm2java和hbm2ddl工具的使用
- hbm2java和hbm2ddl工具的使用
- hbm2java和hbm2ddl的使用步骤
- hbm2java和hbm2ddl工具的使用
- Hibernate tools的hbm2ddl和hbm2java
- hbm2java和hbm2ddl的使用步骤
- hbm2java和hbm2ddl的使用步骤
- 使用Hibernate-tools中的hbm2java和hbm2ddl根据hbm文件自动生成pojo和数据库脚本
- 使用Hibernate-tools中的hbm2java和hbm2ddl根据hbm文件自动生成pojo和数据库脚本
- 使用Hibernate-tools中的hbm2java和hbm2ddl根据hbm文件自动生成pojo和数据库脚本
- 在MyEclipse的web项目/java项目中,使用Hibernate-tools中的hbm2java和hbm2ddl工具,根据hbm文件自动生成pojo和数据库脚本
- hbm2ddl hbm2java
- 运行hbm2java工具和hbm2ddl工具
- 《精通Hibernate》学习(2)——hbm2java和hbm2ddl工具
- 单选按钮检测
- MSFlexGrid使用技巧
- 如何用ASP/JSP实现摄像头的网络直播
- 协议大全
- Javascript语言进行文件操作
- Hibernate3中的hbm2java和hbm2ddl的ant脚本实现
- 进化中Hibernate3脚本
- 2.21
- Windows环境下32位汇编语言程序设计
- 跨组织流程管理的现状
- mail 日本語 勉強
- 2004年度最酷网名
- 给代码签名的六个步骤
- __irq声明IRQ和FIQ中断处理函数