<class name="TblUser" optimistic-lock="version" table="TBL_USER" schema="dbo" catalog="zf" lazy="true">
        <id name="uid" type="java.lang.Integer">
            <column name="uid" />
            <generator class="native" />
        </id>
        <property name="uname" type="java.lang.String" lazy="true">
            <column name="uname" length="50" not-null="true" unique="true" />
        </property>
        <property name="upass" type="java.lang.String">
            <column name="upass" length="50" not-null="false" />
        </property>
    </class>

在WEB-INF/目录下创建build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="hibernate_lazy_test" default="lazy_test" basedir=".">
 <property name="lib.dir" value="./lib"></property>
 <property name="classes.dir" value="./classes"></property>
 <path id="lib.class.path">
  <fileset dir="${lib.dir}">
   <include name="**/*.jar" />
  </fileset>
 </path>
 <target name="lazy_test">
  <taskdef name="instrument"
   classname="org.hibernate.tool.instrument.cglib.InstrumentTask">
   <classpath path="${classes.dir}"></classpath>
   <classpath refid="lib.class.path"></classpath>
  </taskdef>
  <instrument verbose="true">
   <fileset dir="${classes.dir}/com/dao">
    <include name="TblUser.class" />
   </fileset>
  </instrument>
 </target>
</project>
运行ant编译
测试:

user=(TblUser) session.load(TblUser.class, 1);
  System.out.println(user.getUid());
 String name=user.getUname();
  System.out.println(name);