-->
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: Session.load(class, id) with invalid id doesn't return null
PostPosted: Mon Nov 21, 2005 3:09 pm 
Beginner
Beginner

Joined: Thu Aug 04, 2005 2:24 pm
Posts: 45
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0

Mapping documents:

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

Full stack trace of any exception that occurs:

Name and version of the database you are using: Oracle 9i

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

I'm have this:
Code:
paramSupplier = (Supplier) s.load(Supplier.class, request.getParameter("supplierId"));


supplierId field is always greater than 0 in the database. That's why when i have that piece of code trying to load a supplierId = 0, i expect paramSupplier to be null, but that doesn't happen. Something is returned, but it's not null. If i try to read any of the properties os the non-null object, an exception is thrown.

Why is it no null? Is this the way Hibernate is reallly supposed to work?

Thanks to all
Eduardo

_________________
Eduardo Mylonas


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 21, 2005 3:28 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
load nonexisting object throw exception - return value is undefined

you can use get for behavior what you want


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.