-->
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.  [ 3 posts ] 
Author Message
 Post subject: Another Bug in HibernateTools Alpha4?
PostPosted: Thu Jul 28, 2005 9:45 am 
Senior
Senior

Joined: Fri May 14, 2004 9:37 am
Posts: 122
Location: Cologne, Germany
Hi there,

perhaps this is another Bug in HibernateTools 3.0 Alpha4.
If the hashCode() Method is generate it will not ensure that a mandantory field isn't null. So the following scenario will lead to a NPE:
A User creates a new Object by opening a dialog so the default Constructor will be used.
No Mandantory field is set so far if I now call the hashCode Method that will cause a NPE.

The code that will do the trick looks like:

buf.append(result)
.append(" = 37 * ")
.append(result)
.append(" + ")
// if ( property.isOptional() ) {
.append("( ")
.append( getGetterSignature(property) )
.append("() == null ? 0 : ")
// }
.append(cast)
.append(thisName)
.append(".")
.append( getGetterSignature(property) )
.append("()")
.append(hashCode)
// if ( property.isOptional() )
.append(" )");
}
return buf.toString();

Hmm might I get Points for finding bugs ? ;)

_________________
regards

Olaf

vote if it helped


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 28, 2005 1:01 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well - a start would be to do it in the right forum :)

but submit an issue for jira and even better with a patch.

AFAIK it should be null safe - but apparently it is not....

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 02, 2005 10:37 am 
Senior
Senior

Joined: Fri May 14, 2004 9:37 am
Posts: 122
Location: Cologne, Germany
I'll do so in the future ;)

_________________
regards

Olaf

vote if it helped


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