facebook

Error handling strategy of generated HibernateSessionFactory

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #241993 Reply

    dtbullock
    Member

    … is broken!

    specifically:

        
        public static Session currentSession() throws HibernateException {
            Session session = (Session) threadLocal.get();
    
            if (session == null) {
                if (sessionFactory == null) {
                    try {
                        cfg.configure(CONFIG_FILE_LOCATION);
                        sessionFactory = cfg.buildSessionFactory();
                    }
                    catch (Exception e) {
                        System.err.println("%%%% Error Creating SessionFactory %%%%");
                        e.printStackTrace();
                    }
                }
                session = sessionFactory.openSession();
                threadLocal.set(session);
            }
    
            return session;
        }
    

    … eats up an exception and logs it, only to cause a NullPointerException next statement after the handler has executed. Might as well throw e after you’ve printStackTraced()’d it.

    #242160 Reply

    Riyad Kalla
    Member

    I will bring this to the attention of the proper team, thank you for pointing it out.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Error handling strategy of generated HibernateSessionFactory

You must be logged in to post in the forum log in