Hello,
I have an object that needs to be viewed in a tree and in a details panel. The tree view only requires the name of the object, the ID, and one association (the children of each object) where the details panel requires all the items associated with the object, which includes two additional associations that contain the names of items from a different table linked to this object. When I make the call to populate the tree I capture all of the variables required for that object(s) but not the additional associations required for the detail panel. When I then goto view the additional associations in the detail panel I get the exception below. I assume this is due to the lazy = true default condition. I set lazy = false and this exception goes away but now all of the associations are loaded each time the detail is called which has a major effect on latency. What I am trying to track down is how to have the details panel only call the additional associations and not the entire object (including all associations) for each detail.
Thank you
Hibernate version:
Version 3.2
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.zeltech.data.entity">
<class name="Visit" table="visits" lazy="false">
<id name="id" column="visitID">
<generator class="native"/>
</id>
<property name="name" column="name" not-null="true" type="string" length="30"/>
<property name="date" column="date" type="string"/>
<property name="time" column="time" type="string"/>
<property name="status" column="status" type="string" length="255"/>
<many-to-one
name="parent"
column="parentID"
class="Visit"
foreign-key="fk_visit_parent"
cascade="none"
lazy="false"/>
<many-to-one
name="organization"
column="organizationID"
class="Organization"
foreign-key="fk_visit_organization"
lazy="false"/>
<many-to-one
name="record"
column="recordID"
class="Record"
foreign-key="fk_visit_record"
lazy="false"/>
<bag name="meds" lazy="false" table="link_visit_meds">
<key column="visitID" foreign-key="fk_visit_meds_link"/>
<many-to-many class="Meds" column="medsID" foreign-key="fk_meds_visit_link"/>
</bag>
<bag name="tests" lazy="false" table="link_visit_ts">
<key column="visitID" foreign-key="fk_visits_ts_link"/>
<many-to-many class="Tests" column="tsID" foreign-key="fk_ts_visit_link"/>
</bag>
<bag name="subVisits" lazy="false" inverse="true" cascade="all-delete-orphan">
<key column="parentID"/>
<one-to-many class="Visit"/>
</bag>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
DAO getSession
returns
Code:
session = sessionFactory.openSession();
Code:
Session hSession = DAO.getSession();
Transaction tx = null;
try
{
tx = hSession.beginTransaction();
Criteria crit = hSession.createCriteria(Visit.class);
crit.add(Restrictions.isNull("parent"));
crit.add(Restrictions.eq("record", record));
List<Visit> results = crit.list();
Full stack trace of any exception that occurs:Code:
Aug 14, 2008 1:07:06 PM org.hibernate.LazyInitializationException <init>
SEVERE: could not initialize proxy - the owning Session was closed
org.hibernate.LazyInitializationException: could not initialize proxy -
the owni
ng Session was closed
at
org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyIn
itializer.java:60)
at
org.hibernate.proxy.AbstractLazyInitializer.getImplementation(Abstrac
tLazyInitializer.java:111)
at
org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyI
nitializer.java:140)
at
com.zeltech.data.entity.IPIBSession$$EnhancerByCGLIB$$c22774b1.getNam
e(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
flex.messaging.io.BeanProxy$BeanProperty.get(BeanProxy.java:623)
at flex.messaging.io.BeanProxy.getBeanValue(BeanProxy.java:199)
at flex.messaging.io.BeanProxy.getValue(BeanProxy.java:176)
at
flex.messaging.io.amf.Amf3Output.writePropertyProxy(Amf3Output.java:5
48)
at
flex.messaging.io.amf.Amf3Output.writeCustomObject(Amf3Output.java:51
8)
at
flex.messaging.io.amf.Amf3Output.writeObject(Amf3Output.java:193)
at
flex.messaging.io.amf.Amf3Output.writeObjectProperty(Amf3Output.java:
243)
at
flex.messaging.io.amf.Amf3Output.writePropertyProxy(Amf3Output.java:5
49)
at
flex.messaging.io.amf.Amf3Output.writeCustomObject(Amf3Output.java:51
8)
at
flex.messaging.io.amf.Amf3Output.writeObject(Amf3Output.java:193)
at
flex.messaging.io.amf.Amf3Output.writeObjectArray(Amf3Output.java:800
)
at
flex.messaging.io.amf.Amf3Output.writeAMFArray(Amf3Output.java:431)
at
flex.messaging.io.amf.Amf3Output.writeObject(Amf3Output.java:179)
at
flex.messaging.io.ArrayCollection.writeExternal(ArrayCollection.java:
97)
at
flex.messaging.io.amf.Amf3Output.writePropertyProxy(Amf3Output.java:5
39)
at
flex.messaging.io.amf.Amf3Output.writeArrayCollection(Amf3Output.java
:462)
at
flex.messaging.io.amf.Amf3Output.writeObject(Amf3Output.java:175)
at
flex.messaging.io.amf.Amf3Output.writeObjectProperty(Amf3Output.java:
243)
at
flex.messaging.io.amf.Amf3Output.writePropertyProxy(Amf3Output.java:5
49)
at
flex.messaging.io.amf.Amf3Output.writeCustomObject(Amf3Output.java:51
8)
at
flex.messaging.io.amf.Amf3Output.writeObject(Amf3Output.java:193)
at
flex.messaging.io.amf.Amf0Output.writeObject(Amf0Output.java:181)
at
flex.messaging.io.amf.AmfMessageSerializer.writeBody(AmfMessageSerial
izer.java:195)
at
flex.messaging.io.amf.AmfMessageSerializer.writeMessage(AmfMessageSer
ializer.java:149)
at
flex.messaging.endpoints.amf.SerializationFilter.invoke(Serialization
Filter.java:180)
at
flex.messaging.endpoints.AMFEndpoint.service(AMFEndpoint.java:122)
at
flex.messaging.MessageBrokerServlet.service(MessageBrokerServlet.java
:424)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:269)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:188)
at
org.springframework.security.util.FilterChainProxy$VirtualFilterChain
.doFilter(FilterChainProxy.java:359)
at
org.springframework.security.intercept.web.FilterSecurityInterceptor.
invoke(FilterSecurityInterceptor.java:109)
at
org.springframework.security.intercept.web.FilterSecurityInterceptor.
doFilter(FilterSecurityInterceptor.java:83)
at
org.springframework.security.util.FilterChainProxy$VirtualFilterChain
.doFilter(FilterChainProxy.java:371)
at
org.springframework.security.ui.SessionFixationProtectionFilter.doFil
terHttp(SessionFixationProtectionFilter.java:67)
at
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringS
ecurityFilter.java:53)
at
org.springframework.security.util.FilterChainProxy$VirtualFilterChain
.doFilter(FilterChainProxy.java:371)
at
org.springframework.security.ui.ExceptionTranslationFilter.doFilterHt
tp(ExceptionTranslationFilter.java:101)
at
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringS
ecurityFilter.java:53)
at
org.springframework.security.util.FilterChainProxy$VirtualFilterChain
.doFilter(FilterChainProxy.java:371)
at
org.springframework.security.providers.anonymous.AnonymousProcessingF
ilter.doFilterHttp(AnonymousProcessingFilter.java:105)
at
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringS
ecurityFilter.java:53)
at
org.springframework.security.util.FilterChainProxy$VirtualFilterChain
.doFilter(FilterChainProxy.java:371)
at
org.springframework.security.ui.rememberme.RememberMeProcessingFilter
.doFilterHttp(RememberMeProcessingFilter.java:116)
at
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringS
ecurityFilter.java:53)
at
org.springframework.security.util.FilterChainProxy$VirtualFilterChain
.doFilter(FilterChainProxy.java:371)
at
org.springframework.security.wrapper.SecurityContextHolderAwareReques
tFilter.doFilterHttp(SecurityContextHolderAwareRequestFilter.java:91)
at
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringS
ecurityFilter.java:53)
at
org.springframework.security.util.FilterChainProxy$VirtualFilterChain
.doFilter(FilterChainProxy.java:371)
at
org.springframework.security.ui.basicauth.BasicProcessingFilter.doFil
terHttp(BasicProcessingFilter.java:173)
at
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringS
ecurityFilter.java:53)
at
org.springframework.security.util.FilterChainProxy$VirtualFilterChain
.doFilter(FilterChainProxy.java:371)
at
org.springframework.security.ui.webapp.DefaultLoginPageGeneratingFilt
er.doFilterHttp(DefaultLoginPageGeneratingFilter.java:86)
at
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringS
ecurityFilter.java:53)
at
org.springframework.security.util.FilterChainProxy$VirtualFilterChain
.doFilter(FilterChainProxy.java:371)
at
org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp
(AbstractProcessingFilter.java:271)
at
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringS
ecurityFilter.java:53)
at
org.springframework.security.util.FilterChainProxy$VirtualFilterChain
.doFilter(FilterChainProxy.java:371)
at
org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp
(AbstractProcessingFilter.java:271)
at
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringS
ecurityFilter.java:53)
at
org.springframework.security.util.FilterChainProxy$VirtualFilterChain
.doFilter(FilterChainProxy.java:371)
at
org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(Logo
utFilter.java:89)
at
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringS
ecurityFilter.java:53)
at
org.springframework.security.util.FilterChainProxy$VirtualFilterChain
.doFilter(FilterChainProxy.java:371)
at
org.springframework.security.context.HttpSessionContextIntegrationFil
ter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)
at
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringS
ecurityFilter.java:53)
at
org.springframework.security.util.FilterChainProxy$VirtualFilterChain
.doFilter(FilterChainProxy.java:371)
at
org.springframework.security.util.FilterChainProxy.doFilter(FilterCha
inProxy.java:174)
at
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(D
elegatingFilterProxy.java:236)
at
org.springframework.web.filter.DelegatingFilterProxy.doFilter(Delegat
ingFilterProxy.java:167)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:215)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:188)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:210)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:174)
at
flex.messaging.security.TomcatValve.invoke(TomcatValve.java:143)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:117)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:108)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:151)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:870)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p
rocessConnection(Http11BaseProtocol.java:665)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:528)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol
lowerWorkerThread.java:81)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:685)
at java.lang.Thread.run(Thread.java:595)
Name and version of the database you are using:Frontbase Version 4.2
The generated SQL (show_sql=true):Debug level Hibernate log excerpt:Code:
Aug 14, 2008 1:07:06 PM org.hibernate.LazyInitializationException <init>
SEVERE: could not initialize proxy - no Session
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150)
at com.zeltech.data.entity.Mission$$EnhancerByCGLIB$$cfed8eaa.toString(<generated>)
at com.zeltech.ipib2.visits.VisitEditor.setRecord(VisitEditor.java:175)
at com.zeltech.ipib2.visits.Visit.viewVisit(Visit.java:66)
at com.zeltech.ipib2.visits.Visit.valueChanged(Visit.java:264)
at javax.swing.JTree.fireValueChanged(JTree.java:2399)
at javax.swing.JTree$TreeSelectionRedirector.valueChanged(JTree.java:2770)
at javax.swing.tree.DefaultTreeSelectionModel.fireValueChanged(DefaultTreeSelectionModel.java:629)
at javax.swing.tree.DefaultTreeSelectionModel.notifyPathChange(DefaultTreeSelectionModel.java:1078)
at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPaths(DefaultTreeSelectionModel.java:287)
at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPath(DefaultTreeSelectionModel.java:170)
at javax.swing.JTree.setSelectionPath(JTree.java:1174)
at javax.swing.plaf.basic.BasicTreeUI.selectPathForEvent(BasicTreeUI.java:2296)
at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelectionImpl(BasicTreeUI.java:3509)
at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelection(BasicTreeUI.java:3484)
at javax.swing.plaf.basic.BasicTreeUI$Handler.mousePressed(BasicTreeUI.java:3465)
at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:222)
at java.awt.Component.processMouseEvent(Component.java:5599)