Use middlegen hibernate3 to generate HBM. xml configuration and Java class

Source: Internet
Author: User

Some problems encountered during middlegen hibernate3 Configuration

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

Solution: Delete the database jar package and introduce the database packages db2java. jar, db2jcc_javax.jar, and db2jcc. jar in the attachment.

2. doesn' t support the "output" attribute and net/SF/hibernate/mappingexception

The reference is that hibernate3 must be significantly different from the previous hibernate2 configuration to modify the configuration.

Hibernate3:

XML Code  
  1. <Target name = "hbm2java" Description = "Generate. Java from. HBM Files.">
  2. <Taskdef
  3. Name = "hbm2java"
  4. Classname = "org. hibernate. tool. Ant. hibernatgateltask"
  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. </Target>

Hibernate2:

XML Code  
  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. <Hbm2java output = "$ {build. gen-src.dir}">
  8. <Fileset dir = "$ {build. gen-src.dir}">
  9. <Include name = "**/*. HBM. xml"/>
  10. </Fileset>
  11. </Hbm2java>
  12. </Target>

3. Don't use old dtds, read the hibernate 3.x migration guide!

Solution: modify \ middlegen \ plugins \ hibernate. VM in middlegen-hibernate-plugin-2.1.jar

Before modification:

XML Code  
  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>

 

After modification:

XML Code  
  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>

For the complete project, see the attachment and modify the output directory of the build. xml Java class and XML file;

XML Code  
  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...

To generate a specified table, you can add <Table name = "tablename"/>

 

  • Middlegen_hibernate3.rar (6.3 MB)
  • Downloads: 185

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.