-->
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.  [ 1 post ] 
Author Message
 Post subject: New in Hibernate and problems
PostPosted: Thu Mar 31, 2011 11:14 pm 
Newbie

Joined: Thu Mar 31, 2011 10:59 pm
Posts: 1
Hello, sorry for use this forum for some simple question, but i don't know what to do...

I create the hibernate.cfg.xml file, with the connection to the database and the mapping resources, and all the hbm.xml files for every table...

But i still having problems..

I have a Session var that is
Code:
private Session sesion;
sesion = HibernateUtil.getSessionFactory().openSession();


And the class HibernateUtil
Code:
public class HibernateUtil

    private static final SessionFactory sessionFactory;   

    static
    {
        try
        {
            sessionFactory = new Configuration().configure().buildSessionFactory();
        } catch (HibernateException he)
        {
           System.err.println("OcurriĆ³ un error en la inicializaciĆ³n de la SessionFactory: " + he);
           throw new ExceptionInInitializerError(he);
        }
    } 

    public static SessionFactory getSessionFactory()
    {
        return sessionFactory;
    }
}


The thing is that the system fails on the sentence
Code:
sessionFactory = new Configuration().configure().buildSessionFactory();

and gives the following errors
Code:
Exception in thread "main" java.lang.NullPointerException
   at datos.IvaFechaDAO.getIvaFecha(IvaFechaDAO.java:44)
   at negocio.IvaFecha.getIvaFecha(IvaFecha.java:7)
   at presentacion.Inicio.main(Inicio.java:15)


I think that the problems is in the connection, but a problem is that i don't know if it is reading okey the hibernate.cfg.xml or not or where is the problem.

I appreciate any thing you could do to help me, i'm new in java! Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.