Hello Friends,
I am a first time hibernate user. I imported data from a CSV file into an SQL Server 2000 table named 'MachineDetails'. i then used hibernate to read this table using the code given below. I found that it returns null objects and the size of the List returned is exactly same as the no. of rows in the table. On examining I found out that the table has <NULL> values. If I I remove those null values then data is returned as needed. But even one <NULL> value in the row causes it to return a null object for that row.
Since I am new I am unable to enable logging. Is it correct that I only need to put log4j.properties and log4j.jar in the classpath to enable logging?
Hibernate version: 3.0
Mapping documents:
<?xml version="1.0"?>
<!--<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >-->
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class
name="com.boa.gcmit.messagebus.services.mqmwebapp.hibernate.MachineDetailsDTO"
table="MachineDetails"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="MachineDetails"
</meta>
<composite-id>
<meta attribute="field-description" inherit="false">
@hibernate.id
generator-class="assigned"
</meta>
<key-property
name="name"
column="Name"
type="java.lang.String"
length="50"
>
<meta attribute="field-description">
@hibernate.property
column="Name"
</meta>
</key-property>
<key-property
name="IPAddress"
column="IPAddress"
type="java.lang.String"
length="50"
>
<meta attribute="field-description">
@hibernate.property
column="IPAddress"
</meta>
</key-property>
<key-property
name="purpose"
column="Purpose"
type="java.lang.String"
length="50"
>
<meta attribute="field-description">
@hibernate.property
column="Purpose"
</meta>
</key-property>
<key-property
name="owner"
column="Owner"
type="java.lang.String"
length="50"
>
<meta attribute="field-description">
@hibernate.property
column="Owner"
</meta>
</key-property>
<key-property
name="env"
column="Env"
type="java.lang.String"
length="50"
>
<meta attribute="field-description">
@hibernate.property
column="Env"
</meta>
</key-property>
<key-property
name="TCOAServerRole"
column="TCOAServerRole"
type="java.lang.String"
length="50"
>
<meta attribute="field-description">
@hibernate.property
column="TCOAServerRole"
</meta>
</key-property>
<key-property
name="operatingSystem"
column="OperatingSystem"
type="java.lang.String"
length="50"
>
<meta attribute="field-description">
@hibernate.property
column="OperatingSystem"
</meta>
</key-property>
<key-property
name="operatingSysVer"
column="OperatingSysVer"
type="java.lang.String"
length="50"
>
<meta attribute="field-description">
@hibernate.property
column="OperatingSysVer"
</meta>
</key-property>
<key-property
name="model"
column="Model"
type="java.lang.String"
length="50"
>
<meta attribute="field-description">
@hibernate.property
column="Model"
</meta>
</key-property>
<key-property
name="cpu"
column="CPU"
type="java.lang.String"
length="50"
>
<meta attribute="field-description">
@hibernate.property
column="CPU"
</meta>
</key-property>
<key-property
name="memory"
column="Memory"
type="java.lang.String"
length="50"
>
<meta attribute="field-description">
@hibernate.property
column="Memory"
</meta>
</key-property>
<key-property
name="location"
column="Location"
type="java.lang.String"
length="50"
>
<meta attribute="field-description">
@hibernate.property
column="Location"
</meta>
</key-property>
<key-property
name="queueManagers"
column="QueueManagers"
type="java.lang.String"
length="50"
>
<meta attribute="field-description">
@hibernate.property
column="QueueManagers"
</meta>
</key-property>
<key-property
name="initiatives"
column="Initiatives"
type="java.lang.String"
length="50"
>
<meta attribute="field-description">
@hibernate.property
column="Initiatives"
</meta>
</key-property>
<key-property
name="software"
column="Software"
type="java.lang.String"
length="50"
>
<meta attribute="field-description">
@hibernate.property
column="Software"
</meta>
</key-property>
</composite-id>
<!-- Associations -->
<!-- derived association(s) for compound key -->
<!-- end of derived association(s) -->
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
SessionFactory factory = HibernateUtil.getSessionFactory();
Session session = factory.getCurrentSession();
session.beginTransaction();
List resultSet = session.createQuery("from MachineDetailsDTO").list();
session.getTransaction().commit();
return resultSet;
Full stack trace of any exception that occurs:
[/MQMWebAppWeb] Unhandled exception caught in Global.app:
java.lang.NullPointerException
at EnvConfig.EnvConfigController.displayBasicInfo(EnvConfigController.jp
f:143)
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:324)
at com.bea.wlw.netui.pageflow.FlowController.invokeActionMethod(FlowCont
roller.java:1512)
at com.bea.wlw.netui.pageflow.FlowController.getActionMethodForward(Flow
Controller.java:1447)
at com.bea.wlw.netui.pageflow.FlowController.internalExecute(FlowControl
ler.java:778)
at com.bea.wlw.netui.pageflow.PageFlowController.internalExecute(PageFlo
wController.java:211)
at com.bea.wlw.netui.pageflow.FlowController.execute(FlowController.java
:608)
at org.apache.struts.action.RequestProcessor.processActionPerform(Reques
tProcessor.java:484)
at com.bea.wlw.netui.pageflow.PageFlowRequestProcessor.processActionPerf
orm(PageFlowRequestProcessor.java:1492)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:274)
at com.bea.wlw.netui.pageflow.PageFlowRequestProcessor.process(PageFlowR
equestProcessor.java:691)
at com.bea.wlw.netui.pageflow.AutoRegisterActionServlet.process(AutoRegi
sterActionServlet.java:527)
at com.bea.wlw.netui.pageflow.PageFlowActionServlet.process(PageFlowActi
onServlet.java:152)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:1077)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:465)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:348)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:7051)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
dSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:
121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:3902)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2773)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
Name and version of the database you are using:
SQL Server 2000
The generated SQL (show_sql=true):
Hibernate: select machinedet0_.Name as Name0_, machinedet0_.IPAddress as IPAddre
ss0_, machinedet0_.Purpose as Purpose0_, machinedet0_.Owner as Owner0_, machined
et0_.Env as Env0_, machinedet0_.TCOAServerRole as TCOAServ6_0_, machinedet0_.Ope
ratingSystem as Operatin7_0_, machinedet0_.OperatingSysVer as Operatin8_0_, mach
inedet0_.Model as Model0_, machinedet0_.CPU as CPU0_, machinedet0_.Memory as Mem
ory0_, machinedet0_.Location as Location0_, machinedet0_.QueueManagers as QueueM
a13_0_, machinedet0_.Initiatives as Initiat14_0_, machinedet0_.Software as Softw
are0_ from MachineDetails machinedet0_
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html