michael wrote:
Are you doing the necessary compile-time enhancement?
Sorry, forgot to mention it. Yes, I'm running this Ant task:
<target name="instrument" depends="compile">
<taskdef name="instrument" classname="org.hibernate.tool.instrument.InstrumentTask">
<classpath path="${classes.dir}"/>
<classpath refid="class.path"/>
</taskdef>
<instrument verbose="true">
<fileset dir="${classes.dir}/db/hibernateSimple">
<include name="*.class"/>
</fileset>
</instrument>
</target>
I get the following output:
instrument:
[instrument] Enhancing class db.hibernateSimple.User
[instrument] Enhancing class db.hibernateSimple.CopayDetails
[instrument] Enhancing class db.hibernateSimple.Copay
[instrument] Enhancing class db.hibernateSimple.HibernateTestDAO
[instrument] Enhancing class db.hibernateSimple.DataContext
[instrument] Enhancing class db.hibernateSimple.HibernateTest
I've tried changing the lazy loading of components and it doesn't seem to work either. Has anyone tried lazy loading with instrumentation?
Another workaround would be to just create two classes that are mapped to the same table, for instance UserSummary and UserDetails. UserSummary will have a one-to-one association with UserDetails. The idea is that when we need to display a table of users we don't want to load all of their information. When we need to display the full information on a user, we have to load all columns (hence the use of UserDetails object). Is there a better way of doing it? I'm not particularly keen on bytecode instrumentation anyway.