-->
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: get/ load not raising HibernateException when rec not found
PostPosted: Fri Mar 27, 2015 1:35 pm 
Newbie

Joined: Fri Mar 27, 2015 1:26 pm
Posts: 2
I am trying to do:
Code:
       
        public static Tprogram findProgramByKey( Long key) throws DataAccessException
       {
            Tprogram program = null;
          try
          {
             program = (Tprogram)HibernateSessionConfig.getCurrentSession().load(Tprogram.class, key);
          }
          catch( HibernateException e )
          {
             LOGGER.error( "Unable to find program for key = "+ key, e);
             throw new DataAccessException( e);
          }
          return program;
       }

I am deliberately passing a key that should result in a "not found", or something like that.
When I use get(Tprogram.class, key);, program=null, when I use load(Tprogram.class, key), the result is
all program class variables are null.
No error is raised.

Using Hibernate-2.1


Top
 Profile  
 
 Post subject: Re: get/ load not raising HibernateException when rec not found
PostPosted: Sat Mar 28, 2015 6:34 pm 
Newbie

Joined: Fri Mar 27, 2015 1:26 pm
Posts: 2
solved it. get returns null is normal behaviour


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.