|
XDoclet 2 for Hibernate 3Note: This document reflects releases: Hibernate 3.0.5 and XDoclet 2. See http://www.hibernate.org/72.html for examples of what your model classes look like with XDoclet 1.x tags (which by-and-large are the same as XDoclet 2's tags), and http://www.hibernate.org/284.html for another developer's build.xml snippet (which doesn't use globbing). This page could/should be merged into that page, but it's not marked editable by guests. OverviewXDoclet 2 was a rewrite of the XDoclet engine. It allows you to use Java5 language features in your model POJOs, and has substantially better error reporting than XDoclet 1. The XDoclet 2 developers unfortunately decided to make the collections tag names different from the XDoclet 1 tags, but the transition is an easy one-time recursive find/replace. build-time librariesMy buildlib/ directory (that globs into my class.path) has: ant-contrib-1.0b1.jar commons-beanutils-1.7.0.jar commons-collections-3.1.jar commons-jelly-20050813.225330.jar commons-jelly-tags-define-1.0.jar commons-jelly-tags-jsl-1.0.jar commons-jelly-tags-xml-20050823.222913.jar commons-jexl-1.0.jar commons-logging-1.0.4.jar dom4j-1.6.jar generama-1.2.1-SNAPSHOT.jar jaxen-1.1-beta-4.jar nanocontainer-1.0-beta-3.jar nanocontainer-ant-1.0-beta-3.jar picocontainer-1.0.jar qdox-1.6-SNAPSHOT.jar saxpath-1.0-FCS.jar velocity-1.4.jar xdoclet-2.0.3.jar xdoclet-plugin-hibernate-1.0.2.jar all which you will find in XDoclet 2's xdoclet2/distribution/lib/ (from following the download link at http://xdoclet.codehaus.org/ ) Build.xml setupThe documentation for XDoclet 2 is missing a fundamental issue--what to put into your ant buildfile. Note that you'll need to 1- define the class.path pathref 2- Make sure that "**model*.java" will find your model objects 3- decide where you want your .hbm files to go to (and set the hbm.dir property appropriately)
<target name="hibernatedoclet"
depends="init, compile"
description="Generate Persistence and form classes">
<taskdef
name="xdoclet"
classname="org.xdoclet.ant.XDocletTask"
classpathref="class.path"
/>
<xdoclet>
<!-- defines the file handled by xdoclet2 -->
<fileset dir="${src.java.dir}">
<include name="**/model/*.java"/>
</fileset>
<!-- defines the processing of a plugin -->
<component
classname="org.xdoclet.plugin.hibernate.HibernateMappingPlugin"
destdir="${hbm.dir}"
version="3.0"
/>
</xdoclet>
</target>
Tag migrationFor all your model classes, (non-regexp) replace "@hibernate.collection-" with "@hibernate." Here's an example diff: http://cvs.photostructure.com/photostructure/src/java/com/photostructure/model/Label.java.diff?r1=1.5&r2=1.6
|
||||||||||||||||||||||||||||||||||||||||||||||