-->
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.  [ 1 post ] 
Author Message
 Post subject: null pointer exception after "resolving associations fo
PostPosted: Wed Apr 11, 2007 11:53 am 
Newbie

Joined: Wed Apr 11, 2007 11:42 am
Posts: 1
I'm having problems exercising the following code (details below). Interestingly this works in our Linux environment but does not run out of Eclipse on Windows.

Hibernate version:
3

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Apr 9, 2007 5:30:58 PM by Hibernate Tools 3.2.0.b9 -->
<hibernate-mapping>
<class name="com.transunion.ms.library.database.beans.MtrcTyp" table="MTRC_TYP">
<comment></comment>
<id name="mtrcTypId" type="int">
<column name="MTRC_TYP_ID" />
<generator class="assigned" />
</id>
<many-to-one name="mtrcDataTyp" class="com.transunion.ms.library.database.beans.MtrcDataTyp" fetch="select">
<column name="DATA_TYP_ID">
<comment></comment>
</column>
</many-to-one>
<!--
<many-to-one name="mtrcTyp" class="com.transunion.ms.library.database.beans.MtrcTyp" fetch="select">
<column name="SUPER_MTRC_TYP_ID">
<comment></comment>
</column>
</many-to-one>
-->
<property name="mtrcTypNme" type="string">
<column name="MTRC_TYP_NME" length="50" not-null="true" unique="true">
<comment></comment>
</column>
</property>
<property name="mtrcTypDsc" type="string">
<column name="MTRC_TYP_DSC" length="254" not-null="true">
<comment></comment>
</column>
</property>
<property name="cratUserId" type="string">
<column name="CRAT_USER_ID" length="8" not-null="true">
<comment></comment>
</column>
</property>
<property name="cratTsp" type="timestamp">
<column name="CRAT_TSP" length="26" not-null="true">
<comment></comment>
</column>
</property>
<property name="updUserId" type="string">
<column name="UPD_USER_ID" length="8" not-null="true">
<comment></comment>
</column>
</property>
<property name="updTsp" type="timestamp">
<column name="UPD_TSP" length="26" not-null="true">
<comment></comment>
</column>
</property>
<set name="mtrcTyps" inverse="true">
<key>
<column name="SUPER_MTRC_TYP_ID">
<comment></comment>
</column>
</key>
<one-to-many class="com.transunion.ms.library.database.beans.MtrcTyp" />
</set>
<set name="bfsVrsnMtrcs" inverse="true">
<key>
<column name="MTRC_TYP_ID" not-null="true">
<comment></comment>
</column>
</key>
<one-to-many class="com.transunion.ms.library.database.beans.BfsVrsnMtrc" />
</set>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
Call this function with key equal to a valid value within the database, in this case "RECORDS_IN".

public MtrcTyp findByKey( String key )
{
MtrcTyp keyValue = null;

Criteria crit = HibernateUtil_s.currentSession()
.createCriteria( MtrcTyp.class);

crit.add( Restrictions.eq( "mtrcTypNme", key ) );

List< MtrcTyp > results = crit.list();
if ( results.size() == 1 )
{
keyValue = results.get( 0 );
}



return keyValue;
}

Full stack trace of any exception that occurs:

Name and version of the database you are using:
DB2

The generated SQL (show_sql=true):
select this_.MTRC_TYP_ID as MTRC1_2_0_, this_.DATA_TYP_ID as DATA2_2_0_, this_.MTRC_TYP_NME as MTRC3_2_0_, this_.MTRC_TYP_DSC as MTRC4_2_0_, this_.CRAT_USER_ID as CRAT5_2_0_, this_.CRAT_TSP as CRAT6_2_0_, this_.UPD_USER_ID as UPD7_2_0_, this_.UPD_TSP as UPD8_2_0_ from TRG2DEVL.MTRC_TYP this_ where this_.MTRC_TYP_NME=?
Hibernate: select this_.MTRC_TYP_ID as MTRC1_2_0_, this_.DATA_TYP_ID as DATA2_2_0_, this_.MTRC_TYP_NME as MTRC3_2_0_, this_.MTRC_TYP_DSC as MTRC4_2_0_, this_.CRAT_USER_ID as CRAT5_2_0_, this_.CRAT_TSP as CRAT6_2_0_, this_.UPD_USER_ID as UPD7_2_0_, this_.UPD_TSP as UPD8_2_0_ from TRG2DEVL.MTRC_TYP this_ where this_.MTRC_TYP_NME=?

Debug level Hibernate log excerpt:
28375 [main] INFO main - A Hibernate session is created.
28375 [main] DEBUG org.hibernate.transaction.JDBCTransaction - begin
28375 [main] DEBUG org.hibernate.jdbc.ConnectionManager - opening JDBC connection
28375 [main] DEBUG org.hibernate.transaction.JDBCTransaction - current autocommit status: false
41406 [main] INFO main - A Hibernate session is created.
42265 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
42265 [main] DEBUG org.hibernate.SQL - select this_.MTRC_TYP_ID as MTRC1_2_0_, this_.DATA_TYP_ID as DATA2_2_0_, this_.MTRC_TYP_NME as MTRC3_2_0_, this_.MTRC_TYP_DSC as MTRC4_2_0_, this_.CRAT_USER_ID as CRAT5_2_0_, this_.CRAT_TSP as CRAT6_2_0_, this_.UPD_USER_ID as UPD7_2_0_, this_.UPD_TSP as UPD8_2_0_ from TRG2DEVL.MTRC_TYP this_ where this_.MTRC_TYP_NME=?
Hibernate: select this_.MTRC_TYP_ID as MTRC1_2_0_, this_.DATA_TYP_ID as DATA2_2_0_, this_.MTRC_TYP_NME as MTRC3_2_0_, this_.MTRC_TYP_DSC as MTRC4_2_0_, this_.CRAT_USER_ID as CRAT5_2_0_, this_.CRAT_TSP as CRAT6_2_0_, this_.UPD_USER_ID as UPD7_2_0_, this_.UPD_TSP as UPD8_2_0_ from TRG2DEVL.MTRC_TYP this_ where this_.MTRC_TYP_NME=?
43890 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
44015 [main] DEBUG org.hibernate.loader.Loader - result row: EntityKey[com.transunion.ms.library.database.beans.MtrcTyp#1]
44578 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1)
44656 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
44703 [main] DEBUG org.hibernate.engine.TwoPhaseLoad - resolving associations for [com.transunion.ms.library.database.beans.MtrcTyp#1]
44719 [main] ERROR main - java.lang.NullPointerException
44719 [main] DEBUG org.hibernate.transaction.JDBCTransaction - rollback
44765 [main] DEBUG org.hibernate.transaction.JDBCTransaction - rolled back JDBC Connection
44765 [main] DEBUG org.hibernate.jdbc.ConnectionManager - aggressively releasing JDBC connection
44765 [main] DEBUG org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


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

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.