-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: NullPointerException when retrieving collection
PostPosted: Fri Oct 24, 2003 9:38 pm 
Beginner
Beginner

Joined: Mon Sep 29, 2003 10:32 pm
Posts: 35
Location: Toronto, Ontario
I am using version 2.0.3.

I have a one-to-many association between a Vehicle and its Timetables using the following mapping

<class name="org.fsl.lmis.licensing.businessobjects.Vehicle"
table="VEHICLE"
schema="LICENSING">
<id name="vehicleNo" column="VEHICLE_NO" type="integer">
<generator class="assigned"/>
</id>

<set name="timetables"
table="TIME_TABLE_HDR"
schema="LICENSING"
lazy="false"
inverse="true">
<key column="VEHICLE_NO"/>
<one-to-many class="org.fsl.lmis.licensing.businessobjects.Timetable" />
</set>


<many-to-one name="lastLicenceApplication"
column="LAST_APPL_NO" class="org.fsl.lmis.licensing.businessobjects.LicenceApplication"/>


</class>


<class name="org.fsl.lmis.licensing.businessobjects.Timetable"
schema ="LICENSING"
table="TIME_TABLE_HDR">

<id name="id" column="TIME_TABLE_ID" type="long">
<generator class="sequence">
<param name="sequence">LICENSING.seq_time_table</param>
</generator>
</id>

<set name="timetablePoints"
schema="LICENSING"
lazy="false"
cascade="all"
inverse="true">

<key column="TIME_TABLE_ID"/>
<one-to-many class="org.fsl.lmis.licensing.businessobjects.TimetablePoint" />
</set>

<many-to-one name="vehicle" column="VEHICLE_NO" class="org.fsl.lmis.licensing.businessobjects.Vehicle"/>
<many-to-one name="application" column="APPL_NO" class="org.fsl.lmis.licensing.businessobjects.LicenceApplication" cascade="all"/>
</class>

As the mapping shows this relationship is non-lazy. The Vehicle class is itself mapped ad part of a set on a LicenceApplication

<set
name="vehicles"
inverse="true"
lazy="false"
cascade="all">

<key column="LAST_APPL_NO"/>
<one-to-many class="org.fsl.lmis.licensing.businessobjects.Vehicle" />
</set>


When the following query is issued

Code:
"select licApp from LicenceApplication licApp left outer join fetch licApp.routePoints " + " join licApp.customer where licApp.applicationNumber = ? ",               new Long(criteria.getApplicationNumber()),
                  Hibernate.LONG);


the code works as long as a Timetable is present. Where there is no timetable in the database I am getting a NullPointerException in Hibernate code

//----------------------------------------------------------------------------
R java.lang.NullPointerException
net.sf.hibernate.impl.SessionImpl.getLoadingCollection(SessionImpl.java:2759)
net.sf.hibernate.type.PersistentCollectionType.getCollection(PersistentCollectionType.java:58)
at net.sf.hibernate.type.PersistentCollectionType.resolveIdentifier(PersistentCollectionType.java:170)
net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1971)
at net.sf.hibernate.loader.Loader.doFind(Loader.java:196)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:588)
at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:102)
at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2844)
at net.sf.hibernate.collection.PersistentCollection.getInitialValue(PersistentCollection.java:128)
at net.sf.hibernate.type.PersistentCollectionType.getCollection(PersistentCollectionType.java:70)
at net.sf.hibernate.type.PersistentCollectionType.resolveIdentifier(PersistentCollectionType.java:170)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1971)
at net.sf.hibernate.loader.Loader.doFind(Loader.java:196)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:588)
at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:102)
at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2844)
at net.sf.hibernate.collection.PersistentCollection.getInitialValue(PersistentCollection.java:128)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 24, 2003 11:03 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Would you try this code against latest Hibernate 2.1, please?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 25, 2003 9:07 am 
Beginner
Beginner

Joined: Mon Sep 29, 2003 10:32 pm
Posts: 35
Location: Toronto, Ontario
We are using 2.0.3 as it is the recommended release, and 2.1 is still in 'beta'. Nevertheless I will try it with the 2.1.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 26, 2003 1:26 pm 
Beginner
Beginner

Joined: Mon Sep 29, 2003 10:32 pm
Posts: 35
Location: Toronto, Ontario
I reviewed the code and the getters and setters for the timetables was marked private NOT pubic. Because of this the reflection optimizer was disabled at startup for this property. The retrieval of the collection failed when the query was issued under certain circumstances. This happened under the 2.0.3 version.

I am currently porting to the 2.1b4 version to test. Currently I am getting an AbstractMethodError which I am trying to fix.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 26, 2003 4:24 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Quote:
Currently I am getting an AbstractMethodError which I am trying to fix.


This is in the FAQ. Recompile Hibernate on your JDK.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 27, 2003 9:56 am 
Beginner
Beginner

Joined: Mon Sep 29, 2003 10:32 pm
Posts: 35
Location: Toronto, Ontario
I was using the version recompiled for my JVM. Right now I am checking to see if somehow, something else went wrong on my part.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.