-->
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.  [ 4 posts ] 
Author Message
 Post subject: java.lang.NullPoiterException at Session flush time
PostPosted: Tue Sep 02, 2003 6:22 am 
Newbie

Joined: Wed Aug 27, 2003 5:31 am
Posts: 10
Hi, Hibernate experts,
I came across a strange problem in hibernate2.0.2.
I have a java object Client with serveral properties.
The mapping is as follow(I omit the java source before I think there's little chance
of mapping error since the error occurred at Session flush phrase):
<class
name="com.erry.model.baseinfo.Client"
table="T_BI_CLIENT"
>
<meta attribute="extends">com.erry.framework.persistence.BaseModel</meta>
<id
name="id"
type="java.lang.Long"
column="ID"
unsaved-value="null"
>
<generator class="native"/>
</id>
<property
name="code"
type="java.lang.String"
column="CODE"
length="60"
/>
<property
name="name"
type="java.lang.String"
column="NAME"
length="30"
/>
<property
name="type"
type="int"
column="TYPE"
length="10"
/>
<property
name="customType"
type="java.lang.String"
column="CUSTOM_TYPE"
length="30"
/>
<property
name="maintainstopType"
type="java.lang.String"
column="MAINTAINSTOP_TYPE"
length="30"
/>
<property
name="priceRule"
type="int"
column="PRICE_RULE"
length="10"
/>
<property
name="delayTime"
type="int"
column="DELAY_TIME"
length="10"
/>
<property
name="isFrozen"
type="boolean"
column="IS_FROZEN"
length="10"
/>
<property
name="invoiceAddress"
type="java.lang.String"
column="INVOICE_ADDRESS"
length="255"
/>
<property
name="website"
type="java.lang.String"
column="WEBSITE"
length="30"
/>
<property
name="freightAgent"
type="int"
column="FREIGHT_AGENT"
length="50"
/>
<property
name="airFreightAgent"
type="int"
column="AIR_FREIGHT_AGENT"
length="50"
/>
<property
name="isUsed"
type="boolean"
column="IS_USED"
length="10"
/>
<property
name="isValid"
type="boolean"
column="IS_VALID"
length="10"
/>

<!-- associations -->

</class>

Here's the stacktrace:
testMapCreate(com.erry.model.baseinfo.TestClientHome)java.lang.NullPointerException
at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2141)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2017)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2004)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:57)
at com.erry.framework.persistence.TransactionManager.commitDatabase(TransactionManager.java:85)
at com.erry.TestBase.tearDown(TestBase.java:45)
at com.erry.model.baseinfo.TestClientHome.tearDown(TestClientHome.java:69)
......
Please give me some suggestion.
Thank you very much!

Justine


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 02, 2003 6:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Very, very wierd!

Quite bizarre in fact. The exception occurs on this line:

Code:
if ( !entry.id.equals(oid) ) throw new HibernateException(



So somehow your object has come to be registered with a null identifier !?

I don't even know how that can happen in the case of a synthetic id.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 02, 2003 6:47 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Well, I assume you must be doing something very wierd with your identifiers, but if thats not the case, then submit a simple test case to JIRA and I'll take a look. I don't have a hope in hell of being able to track this one down w/o a test.


Top
 Profile  
 
 Post subject: RE:NullPoiterException at Session flush time
PostPosted: Tue Sep 02, 2003 11:07 pm 
Newbie

Joined: Wed Aug 27, 2003 5:31 am
Posts: 10
Hi, Gavin
Thank you very much for your response.
After an hour's hunting I have found where the bug lies. :-)
It's basically something about mismatched data type between java class and mapping file. Say, I have so-called property 'airFreightAgent'. It was an int at first but I changed it to String in Java source. However, I forgot to change it in mapping file accordingly. So hibernate is fooled.

So we can make hibernate a little bit more robust by checking data types declared in java source and the one specified in mapping file. And it may make particular sense for beginner like I. :-)

Thank you for this wonderful O/R mapping!

Justine


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.