-->
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.  [ 2 posts ] 
Author Message
 Post subject: ant eg generates NPE at PrimitiveType.toString()
PostPosted: Mon Apr 24, 2006 12:05 pm 
Newbie

Joined: Mon Apr 24, 2006 11:45 am
Posts: 2
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.1.3 and 3.2cr

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
java.lang.NullPointerException
at org.hibernate.type.PrimitiveType.toString(PrimitiveType.java:15)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:87)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:65)
at org.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:261)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:1910)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:1887)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2117)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2503)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:51)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:988)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:337)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at org.hibernate.auction.Main.createTestAuctions(Main.java:349)
at org.hibernate.auction.Main.main(Main.java:370)
Exception in thread "main"

Name and version of the database you are using:
Oracle 9.0.2

The generated SQL (show_sql=true):
Hibernate:
insert
into
AuctionUser
(userName, "password", email, firstName, "initial", lastName, id)
values
(?, ?, ?, ?, ?, ?, ?)

Debug level Hibernate log excerpt:

Problem is that PrimitiveType breaks when attempting to log the RuntimeException.

From NullableType.java, line 87 ;-

catch ( RuntimeException re ) {
log().info( "could not bind value '" + toString( value ) + "' to parameter: " + index + "; " + re.getMessage() );
throw re;
}

The PrimitiveType.toString method is ;-

public String toString(Object value) {
return value.toString();
}

and will not break if amended to ;-

public String toString(Object value) {
return String.valueOf(value);
}

I have searched JIRA etc. and the closest that I could find was HHH-1366
(I am a Hibernate newbie ).

TIA


Top
 Profile  
 
 Post subject: RE: ant eg generates NPE at PrimitiveType.toString()
PostPosted: Tue Apr 25, 2006 9:24 am 
Newbie

Joined: Mon Apr 24, 2006 11:45 am
Posts: 2
Fixing the toString() methods in package org.hibernate.type produced the following trace ;-

13:28:33,268 INFO CharacterType:95 - could not bind value 'null' to parameter: 5; null
java.lang.NullPointerException
at oracle.jdbc.dbaccess.DBData.clearItem(DBData.java:431)
at oracle.jdbc.dbaccess.DBDataSetImpl.clearItem(DBDataSetImpl.java:3528)
at oracle.jdbc.driver.OraclePreparedStatement.checkBindTypes(OraclePreparedStatement.java:3271)
at oracle.jdbc.driver.OraclePreparedStatement.setNull(OraclePreparedStatement.java:1322)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:83)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:72)
at org.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:261)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:1910)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:1887)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2117)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2503)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:51)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:988)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:337)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at org.hibernate.auction.Main.createTestAuctions(Main.java:349)
at org.hibernate.auction.Main.main(Main.java:370)
Exception in thread "main"

Edit org.hibernate.auction.Main in folder eg ;-

User bidder2 = new User();
bidder2.setUserName("steve");
bidder2.setName( new Name("Steve", null, "Ebersole") );
bidder2.setEmail("steve@hibernate.org");
bidder2.setPassword("******");

Fix the problem by changing bidder2.setName to ;-

bidder2.setName( new Name("Steve", new Character(' '), "Ebersole") );


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