利用Middlegen Hibernate3產生hbm.xml配置和java類

來源:互聯網
上載者:User

在配置Middlegen Hibernate3過程中遇到的一些問題

1. Couldn't connect to database: encoding not supported!!

 解決辦法:刪除之前的資料庫jar包,引入附件中的資料庫包db2java.jar、db2jcc_javax.jar、db2jcc.jar

2. 成功產生xml後再產生java檔案時異常doesn't support the "output" attribute 與net/sf/hibernate/MappingException

   因為引用的是Hibernate3要與之前的Hibernate2配置有很大不同修改配置

 Hibernate3:

Xml代碼  
  1.  <target name="hbm2java"   description="Generate .java from .hbm files.">  
  2.     <taskdef  
  3.        name="hbm2java"  
  4.        classname="org.hibernate.tool.ant.HibernateToolTask"  
  5.        classpathref="lib.class.path"  
  6.     />  
  7.     <hbm2java destdir="${build.gen-src.dir}">  
  8. <configuration>  
  9.     <fileset dir="${build.gen-src.dir}">  
  10.         <include name="**/*.hbm.xml"/>  
  11.     </fileset>  
  12. </configuration>  
  13. <hbm2java jdk5="true" />  
  14. lt;/hbm2java>  
  15.   
  16.  </target>  

 Hibernate2:

Xml代碼  
  1.  <target name="hbm2java" description="Generate .java from .hbm files.">  
  2.     <taskdef  
  3.        name="hbm2java"  
  4.        classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"  
  5.        classpathref="lib.class.path"  
  6.     />  
  7.   
  8. <hbm2java output="${build.gen-src.dir}">  
  9.     <fileset dir="${build.gen-src.dir}">  
  10.         <include name="**/*.hbm.xml"/>  
  11.     </fileset>  
  12. </hbm2java>  
  13.  </target>  

 3.Don't use old DTDs, read the Hibernate 3.x Migration Guide!

 解決辦法:修改middlegen-hibernate-plugin-2.1.jar 中的\middlegen\plugins\hibernate\hibernate.vm

 改之前:

Xml代碼  
  1. <?xml version="1.0"?>  
  2. <!DOCTYPE hibernate-mapping PUBLIC  
  3.     "-//Hibernate/Hibernate Mapping DTD 2.0//EN"  
  4.     "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >  

 

改之後: 

Xml代碼  
  1. <?xml version="1.0"?>  
  2. <!DOCTYPE hibernate-mapping PUBLIC  
  3.     "-//Hibernate/Hibernate Mapping DTD 3.0//EN"  
  4.     "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >  

 完整工程見附件,自己修改build.xml java類及XML檔案的輸出目錄;

Xml代碼  
  1. <property name="ehr.basedir" value="<span style="color: #ff9900;">D:\WORK_EHR\workspaceEHR\EHR</span>"/>  

 

[middlegen] No <table> elements specified. Reading all tables. This might take a while...

如果想要產生指定表,可以在middlegen任務節點中添加<table name="tableName"/>

 

  • Middlegen_Hibernate3.rar (6.3 MB)
  • 下載次數: 185
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.