Hibernate version: 3.1
Mapping documents:
Snippet of mapping:
<many-to-one name="location" class="data.bean.Location" fetch="select">
<column name="LOCATION2PARENTLOCATION" precision="22" scale="0" />
</many-to-one>
Code between sessionFactory.openSession() and session.close():
Yes...
Full stack trace of any exception that occurs:
java.lang.OutOfMemoryError: Java heap space
Name and version of the database you are using:
Oracle 10g
The problem arises when retrieving a location for a network node. This location has a parentLocation which then has a parentLocation etc reference in the Location table.
I need to retrieve the all parent locations upward i.e. a complete list of parents grandparents etc.
Which is then used to determine the folders that these locations belong to and such the folders the network node belongs to.
I have enabled these hibernate properties which seems to have speeded up the querying:
<property name="jdbc.batch_size">50</property>
<property name="hibernate.max_fetch_depth">7</property>
The session is obtained through a HibernateBaseDAO:
public class BaseHibernateDAO implements IBaseHibernateDAO {
public Session getSession() {
return HibernateSessionFactory.getSession();
}
public static void flushSession(){
HibernateSessionFactory.getSession().flush();
HibernateSessionFactory.getSession().clear();
}
public static void closeSession(){
HibernateSessionFactory.getSession().close();
}
}
The LocationDAO retrieves a Location data bean:
public Location findById( java.lang.Long id) {
log.debug("getting Location instance with id: " + id);
try {
Location instance = (Location) getSession()
.get("data.bean.Location", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
The classes using the DAO methods flush and close the session after:
public List<NetworkNode> getNodeLocations(List<NetworkNode> nodesList){
Iterator nodesIter = nodesList.iterator();
while(nodesIter.hasNext()){
NetworkNode temp = (NetworkNode)nodesIter.next();
LocationDAO locationDAO = new LocationDAO();
Location location = locationDAO.findById(new Long(temp.getLocationID()).longValue());
temp.setParentLocationList(this.getParentLocationList(location));
temp.setLocationName(location.getName());
}
BaseHibernateDAO.flushSession();
BaseHibernateDAO.closeSession();
return nodesList;
}
I have bumped up the JVM memory:
-Xms1024m -Xmx1280m -XX:PermSize=64M -XX:MaxPermSize=256M
There are approx 1202 nodes which have a location and then 6 levels of parent locations.
I read in all the nodes but then process for parent locations 10 nodes at a time. Still I seem to run 0ut of memory. If I dont scan for all locations for each node then the app is fine.
I cant seem to think that so much memory is required?
Any help would be much appreciated...
Regards,
AT
atheba@gmail.com