Hibernate version:2.1.17
Name and version of the database you are using: mySql
I have created two classes where the one is an extension of the other.
I have mapped both classes to the same database-file.
The first class is a 'lightweight'-class with fewer properties than the child.
Code:
public class PortationLight extends Observable {
// just a few properties
}
public class Portation extends PortationLight{
//a lot of extra properties
}
<hibernate-mapping>
<class name="....PortationLight" table="polka_portation">
<!-- the same few properties -->
</class>
<class name="....Portation" table="polka_portation">
<!-- the same few properties plus the extra properties -->
</class>
public class PortationDao extends HibernateDaoSupport { //using Spring
public List findActiveLightPortations() {
return getHibernateTemplate().find("from PortationLight p where p.active = ?", new String[]{"T"});
}
}
I am logging the instanciating of both classes in my log, and this shows me :
When calling the 'findActiveLightPortations'-method my framework does ;
Creates a full set of the heavy-weight objects, then creates a full set of the light-weight objects, then returns a set of the lightweight-objects , and THEN creates another full set of the heavy-weight objects.
A total of 3 times the objects I need.
Sometimes the creation of the last full set of heavy-weight objects occurs before the method returns it list, and sometimes even before the creation of the light-weight objects. But always 3 complete sets.
The only reason for ever coding the lightweight-object, was to save memory during instanciation. The creation of the heavy-objects was something i wanted to do on a single basis whenever I needed it.
Is this a Hibernate issue, or a spring-issue (spring 1.1.3) ?
Frode Halvorsen