I have an hibernate query that queries a view that i have created by combining 2 tables. So my view will get 2 columns from tableA and 1 column from tableB. The coulmn from tableB could be null for some case and have value for some case. For example
tableA will have serialNumber and connectionType. (and some other columns. see below). tableB will have proxyId as one coulmn (with serial number as the link coulmn between tableA and tableB. (See below))
Only if the connectionType of tableA value is "P" i will have a value in the proxyId coudmn of tableB. If the connectionType of tableA value is "D" then the proxyId will be empt(Null).
When i run my program, it works fine as long as the proxyId value is NOT NULL. Once if the proxyId value is NULL, it throws
"LazyInitializationException".
Here is my view that i have created.
create or replace view dev_info_proxy_dev_list_view as select d.serial_number, d.connection_type, p.proxy_id from device_info d, proxy_device_list p where p.serial_number (+) = d.serial_number;
Here is my map created out ot oracle view
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!--
Created by Middlegen Hibernate plugin
http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class
name="com.xerox.hc.model.common.device.DevInfoProxyDevListView"
table="DEV_INFO_PROXY_DEV_LIST_VIEW"
>
<composite-id>
<key-property
name="serialNumber"
column="SERIAL_NUMBER"
type="java.lang.String"
length="20"
/>
<key-property
name="connectionType"
column="CONNECTION_TYPE"
type="java.lang.String"
length="1"
/>
<key-property
name="proxyId"
column="PROXY_ID"
type="java.lang.String"
length="64"
/>
</composite-id>
<!-- associations -->
</class>
</hibernate-mapping>
Here is my query:
Query query = session1.createQuery("from com.xerox.hc.model.common.device.DevInfoProxyDevListView as d where d.serialNumber in ("+sb.toString()+")");
Here are the 2 tables
Table Name : Proxy_device_list
Name Null? Type
----------------------------------------- -------- ----------------------------
PROXY_ID NOT NULL VARCHAR2(64)
SERIAL_NUMBER NOT NULL VARCHAR2(15)
Table Name : device_info
Name Null? Type
----------------------------------------- -------- ----------------------------
SERIAL_NUMBER NOT NULL VARCHAR2(20)
PRODUCT_CODE VARCHAR2(10)
SITE_ID NUMBER
CONNECTION_TYPE CHAR(1)
basically I have to get serial_number, connection_type,(from device_info table) proxy_id (from proxy_device_list) table even if the serial number in device_info table is not in proxy_device_list table, i want to return a null proxy_id. I had failed in all my attempts to do joins and that's the reason i have careted a view.
It works fine if the proxy_id value is not null. It throws errors only when the proxy_id is null.
Here is the stack trace:
net.sf.hibernate.LazyInitializationException: Hibernate lazy instantiation problem
at net.sf.hibernate.impl.IteratorImpl.next(IteratorImpl.java:98)
at com.xerox.hc.reg2.configuration.session.ConfigurationManagerSessionBean.getDeviceInfo(ConfigurationManagerSessionBean.java:248)
at com.xerox.hc.reg2.configuration.session.ConfigurationManagerSessionBean.isDeviceDCSRegistered(ConfigurationManagerSessionBean.java:160)
at com.xerox.hc.reg2.configuration.session.ConfigurationManagerSessionBean_n2y8kg_EOImpl.isDeviceDCSRegistered(ConfigurationManagerSessionBean_n2y8kg_EOImpl.java:534)
at com.xerox.hc.reg2.configuration.session.ConfigurationManagerSessionBean_n2y8kg_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:166)
at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:138)
at com.xerox.hc.reg2.configuration.session.ConfigurationManagerSessionBean_n2y8kg_EOImpl_812_WLStub.isDeviceDCSRegistered(Unknown Source)
at com.xerox.hc.webservices.provisionrequest.session.ProvisionRequestSessionBean.isDeviceDCSRegistered(ProvisionRequestSessionBean.java:183)
at com.xerox.hc.webservices.provisionrequest.session.ProvisionRequestSessionBean_ja994w_EOImpl.isDeviceDCSRegistered(ProvisionRequestSessionBean_ja994w_EOImpl.java:998)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at weblogic.webservice.component.slsb.SLSBInvocationHandler.invoke(SLSBInvocationHandler.java:88)
at weblogic.webservice.core.handler.InvokeHandler.handleRequest(InvokeHandler.java:104)
at weblogic.webservice.core.HandlerChainImpl.handleRequest(HandlerChainImpl.java:143)
at weblogic.webservice.core.DefaultOperation.process(DefaultOperation.java:531)
at weblogic.webservice.server.Dispatcher.process(Dispatcher.java:204)
at weblogic.webservice.server.Dispatcher.doDispatch(Dispatcher.java:176)
at weblogic.webservice.server.Dispatcher.dispatch(Dispatcher.java:96)
at weblogic.webservice.server.WebServiceManager.dispatch(WebServiceManager.java:98)
at weblogic.webservice.server.servlet.WebServiceServlet.serverSideInvoke(WebServiceServlet.java:298)
at weblogic.webservice.server.servlet.ServletBase.doPost(ServletBase.java:485)
at weblogic.webservice.server.servlet.WebServiceServlet.doPost(WebServiceServlet.java:268)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at com.xerox.hc.weblogic.LogFilter.doFilter(LogFilter.java:70)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6356)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
Caused by: net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: com.xerox.hc.model.common.device.DevInfoProxyDevListView@1f1b072[serialNumber=2UP000001,connectionType=D,proxyId=<null>], of class: com.xerox.hc.model.common.device.DevInfoProxyDevListView
at net.sf.hibernate.UnresolvableObjectException.throwIfNull(UnresolvableObjectException.java:37)
at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1876)
at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:68)
at net.sf.hibernate.type.EntityType.resolveIdentifier(EntityType.java:215)
at net.sf.hibernate.type.EntityType.nullSafeGet(EntityType.java:154)
at net.sf.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:72)
at net.sf.hibernate.impl.IteratorImpl.next(IteratorImpl.java:92)
... 39 more
BTW, i am using hibernate 2.0 and my IDE is Intellij with jdk 1.4.5_05 and oracle 8.1.7.4
Anyhelp would be really appreciated