Javaren就是爪洼人!

一起来研究java

常用链接

统计

最新评论

hibernate 3.2.5 使用hbm映射文件来生成java源代码和ddl脚本

Hibernate 3.2.x和2.x生成java源代码和ddl脚本的方法差不多,但是使用的hibernate类包变新的了:
org.hibernate.tool.ant.HibernateToolTask

下面是build.xml文件中有关的一段:

<!-- Generate the java code for all
  
-- mapping files in our source tree -->
<target name="hbm2java" depends="prepare"
    description
="Generate Java source">
    
<taskdef name="hibernatetool"
       classname
="org.hibernate.tool.ant.HibernateToolTask"
       classpathref
="project.class.path"/>
    
<hibernatetool destdir="${src}">
      
<configuration
          configurationfile
="${bin}/hibernate.cfg.xml"/>
      
<hbm2java jdk5="true"/>
    
</hibernatetool>
</target>
<!-- create ddl form  *.hbm.xml -->
<target name="hbm2ddl" depends="prepare"
  description
="Generate DB schema from the O/R mapping files">
    
<taskdef name="hibernatetool"
      classname
="org.hibernate.tool.ant.HibernateToolTask"
      classpathref
="project.class.path"/>
    
<hibernatetool destdir="${sql}">
       
<configuration
         configurationfile
="${bin}/hibernate.cfg.xml"/>
       
<hbm2ddl export="false" outputfilename="ddl.sql"/>
    
</hibernatetool>
</target>
其中,
<hbm2java jdk5="true"/>表示生成的java源文件是1.5以后的版本。

posted on 2007-12-02 13:41 Terry Lee 阅读(899) 评论(0)  编辑  收藏 所属分类: Hibernate 3.2.x


只有注册用户登录后才能发表评论。


网站导航: