demo.Address
*/
public Address getAddress() {
return address;
}
/**
* @param address
*/
public void setAddress(Address address) {
this.address = address;
}
}
使用Hibernate进行对象的关系映射(4)
时间:2011-08-11
4.4 Ant and XDoclet
如果你仔细看了上边的代码,你会发现它有一点和我们以前的"不太一样",它javadoc中多了许多特定的javadoc,是的,那是Hibernatedoclet。它和Xdoclet是"姊妹篇",Xdoclet是这样一种工具:它通过和Apache Ant一起来产生应用程序的部署描述符。因此除非你乐意书写xml映射文件,否要就会用到xdoclet(但是我还是建议初学者还是要给自己些机会手写**.hbm.xml)。 进入查看hibernatedoclet的详细信息,下面我们看看,这里是如果利用对象来产生映射文件的,下面,看看build.xml:
<!-- this file uses Apache Ant 1.5.3 beta 1 -->
<project name="Hibernate Example" default="about" basedir=".">
<!-- The location where your xdoclet jar files reside -->
<property name="xdoclet.lib.home" value="c:/java_api/xdoclet-1.2b3/lib"/>
<target name="clean" depends="init" description="removes all directories related to this build">
<delete dir="${dist}"/>
</target>
<target name="init" description="Initializes properties that are used by other targets.">
<property name="dist" value="dist"/>
</target>
<target name="prepare" depends="init,clean" description="creates dist directory">
<echo message="Creating required directories..."/>
<mkdir dir="${dist}"/>
</target>
<target name="hibernate" depends="prepare"
description="Generates Hibernate class descriptor files.">
<taskdef name="hibernatedoclet" classname="xdoclet.modules.hibernate.HibernateDocletTask"> <classpath>
<fileset dir="${xdoclet.lib.home}">
<include name="*.jar"/>
</fileset>
</classpath>
</taskdef>
<!-- Execute the hibernatedoclet task -->
<hibernatedoclet
destdir="."
excludedtags="@version,@author,@todo"
force="true"
verbose="true"
mergedir="${dist}">
<fileset dir=".">
<include name="**/dbdemo/*.java"/>
</fileset>
<hibernate version="2.0"/>
</hibernatedoclet>
</target>
<target name="about" description="about this build file" depends="init">
<echo message=" Use this format for the arguments:"/>
<echo message=" ant hibernate"/>
<echo message=""/>
</target>
</project>
使用Hibernate进行对象的关系映射(5)
时间:2011-08-11
下面试运行时模拟的一个结果:
C:\eclipse\workspace\HibernateExample>ant hibernate
Buildfile: build.xml
init:
clean:
[delete] Deleting directory C:\eclipse\workspace\
|