code_junkie

How to stop Hibernate from eagerly fetching many-to-one associated object

Nov 11th, 2011
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. <many-to-one name="propertyName" class="propertyClass" fetch="select" not-found="ignore" lazy="proxy" />
  2.  
  3. <property name="src" value="/your/src/directory"/><!-- path of the source files -->
  4. <property name="libs" value="/your/libs/directory"/><!-- path of your libraries -->
  5. <property name="destination" value="/your/build/directory"/><!-- path of your build directory -->
  6.  
  7. <fileset id="applibs" dir="${libs}">
  8. <include name="hibernate3.jar" />
  9. <!-- include any other libraries you'll need here -->
  10. </fileset>
  11.  
  12. <target name="compile">
  13. <javac srcdir="${src}" destdir="${destination}" debug="yes">
  14. <classpath>
  15. <fileset refid="applibs"/>
  16. </classpath>
  17. </javac>
  18. </target>
  19.  
  20. <target name="instrument" depends="compile">
  21. <taskdef name="instrument" classname="org.hibernate.tool.instrument.javassist.InstrumentTask">
  22. <classpath>
  23. <fileset refid="applibs"/>
  24. </classpath>
  25. </taskdef>
  26.  
  27. <instrument verbose="true">
  28. <fileset dir="${destination}">
  29. <!-- substitute the package where you keep your domain objs -->
  30. <include name="/com/mycompany/domainobjects/*.class"/>
  31. </fileset>
  32. </instrument>
  33. </target>
Add Comment
Please, Sign In to add comment