Hi all,
I am using Hibernate for ORM.
Right now i am monitoring my application using  JProfiler.
Here, i run my application and monitoring instances which are not garbage collected.
In one flow of my application, i have found that hibernate is instantiating objects on the basis of available records in
corrosponding table.
 
For example, I have tried to load BaseListing class which is child of UserDtls and when i load
BaseListing like as given below (DAO layer code snippet).
 
baseListing = (BaseListing)getHibernateTemplate().load(BaseListing.
class, listingId);
 
Here, it loads baselisting with all its containing objects including UserDtls where returned UserDtls object is one
but in jprofiler it shows 32 UserDtls allocations (Instance Allocations, here UserDtls table has 32 records) whereas
in baseListing it has loaded only one instance.
 
So JProfiler shows me this 32 as a non-GCed objects.
 
Can anybody tell me that why hibernate is loading (creating instances of) UserDtls on the basis of available records into the UserDtls
even in baseListing it is assigning one instance of UserDtls.
 
(The mapping files are as given below)
i.e
I have two classes BaseListing and UserDtls.
Following is a configuration snippet of both
BaseListing.hbm.xml
<class name="test.BaseListing" table="base_listing" lazy="false">
.........................
<many-to-one name="userDtls" class="test.UserDtls" lazy="false">
<column name="USER_ID" />
</many-to-one
....................
</class>
</hibernate-mapping>

UserDtls.hbm.xml

<class name="test.UserDtls" table="user_dtls" lazy="false" >
...........................
<set name="baseListings" inverse="true" fetch="select">
<key>
<column name="USER_ID" />
</key>
<one-to-many class="test.BaseListing" />
</set<key>
....................
</class>
</hibernate-mapping>
 
Here,can any body tell me how can i make hibernate to load only required 1 instance
 rather than unnecessary 32 instances of UserDtls.
 
Regards,
Manish