HIBERNATE3中可以针对对象属性的了。

解决方案 »

  1.   

    hibernate3提供了对属性的延迟加载啊!
      

  2.   

    教你个简单方法 通过 select new 延迟加载
    在你的dto 中建一个 构造方法 String hql ="select new " + attachFile +
            " (t1.docAttachFileOID,t1.fileName,t1.extName,t1.fileType,t1.extOID,t1.fileSize) from " + attachFile+" as t1 where t1.theExchangeDoc.exchangeDocOID = ?";
            List list= hibernateOperations.find(hql, exchangeDocOID);
      

  3.   

    <target name="instrument" depends="compile">
        <taskdef name="instrument" classname="org.hibernate.tool.instrument.InstrumentTask">
            <classpath refid="project.class.path" />
        </taskdef>    <instrument verbose="true">
             <fileset dir="${class.root}">
                  <include name="*.class" />
             </fileset>
        </instrument>
    </target>
      

  4.   

    <target name="compile">
      <javac srcdir="${source.root}" destdir="${class.root}" debug="on" optimize="off" deprecation="on">
           <classpath refid="project.class.path" />
      </javac>
    </target>
    如果对持久化类的属性使用延迟加载策略,必须通过ANT的instrument任务来增强持久化类的字节码,从而使得程序访问持久化类的特定属性时,能触发Hibernate到数据库中检索相应数据的行为。