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
- <Target name = "hbm2java" Description = "Generate. Java from. HBM Files.">
- <Taskdef
- Name = "hbm2java"
- Classname = "org. hibernate. tool. Ant. hibernatgateltask"
- Classpathref = "Lib. Class. path"
- />
- <Hbm2java destdir = "$ {build. gen-src.dir}">
- <Configuration>
- <Fileset dir = "$ {build. gen-src.dir}">
- <Include name = "**/*. HBM. xml"/>
- </Fileset>
- </Configuration>
- <Hbm2java jdk5 = "true"/>
- Lt;/hbm2java>
- </Target>
Hibernate2:
XML Code
- <Target name = "hbm2java" Description = "Generate. Java from. HBM Files.">
- <Taskdef
- Name = "hbm2java"
- Classname = "net. SF. hibernate. tool. hbm2java. hbm2javatask"
- Classpathref = "Lib. Class. path"
- />
- <Hbm2java output = "$ {build. gen-src.dir}">
- <Fileset dir = "$ {build. gen-src.dir}">
- <Include name = "**/*. HBM. xml"/>
- </Fileset>
- </Hbm2java>
- </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
- <? XML version = "1.0"?>
- <! Doctype hibernate-mapping public
- "-// Hibernate/hibernate mapping DTD 2.0 // en"
- Http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd>
After modification:
XML Code
- <? XML version = "1.0"?>
- <! Doctype hibernate-mapping public
- "-// Hibernate/hibernate mapping DTD 3.0 // en"
- 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
- <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