Issue Details (XML | Word | Printable)

Key: HHH-2250
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Trivial Trivial
Assignee: Steve Ebersole
Reporter: Jonas Maurus
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Hibernate Core

Create an appropriate error message if Query.setEntity is passed a NULL value

Created: 17/Nov/06 10:28 AM   Updated: 21/Nov/06 06:05 PM
Component/s: query-hql
Affects Version/s: 3.2.0.ga, 3.2.1
Fix Version/s: 3.2.2

Time Tracking:
Not Specified


 Description  « Hide
setEntity(xyz, null) ends in a NPE in SessionImpl.guessEntityName(). This previously came up as HHH-675. I just spent hours tracking this NPE in our application, then upgrading Hibernate because I thought it might be a Hibernate bug :-/. The offending line read:

.setEntity("customer", user.getCustomer())

"user" being an entity managed by Hibernate with user.customer being a nullable ManyToOne-relation. The current mode of "crash-and-burn" really looks like a Hibernate bug and not like expected behavior. I'd like to recommend that setEntity() should explicitly check for null-values.

 All   Comments   Work Log   Change History   FishEye      Sort Order: Ascending order - Click to sort in descending order
Steve Ebersole added a comment - 21/Nov/06 03:53 PM
You spent hours tracking something that is fairly obvious from the stack trace? ouch!

I really dont understand the whole NPE is evil trip y'all are on here. I mean think about the gist of the problem... You passed a NULL POINTER... How about IllegalArgumentException, does that somehow make it easier?

Steve Ebersole added a comment - 21/Nov/06 03:56 PM
Changed to the much more meaningful IllegalArgumentException ;)

Steve Ebersole added a comment - 21/Nov/06 06:05 PM
trunk / 3.2