Skip to Content
avatar image
Former Member

Problem in placing hibernate.cfg.xml

Hi,

I have written one ejb project with hibernate in my net weaver.Now i have a problem in placing hibernate.cfg.xml.so tell me where to place it .Give some examples related to that and some related links.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Apr 07, 2006 at 09:11 AM

    Hi,

    you can place it into the root of the EJB project as your EJBs probably access Hibernate as persistence layer. In this case make sure that you pass the string "hibernate.cfg.xml" within the method invocation when retrieving a SessionFactory as follows:

    try
    {
    Configuration cfg = new Configuration();
    sessionFactory = cfg.configure  
         ("hibernate.cfg.xml").buildSessionFactory();
    }
    catch (Throwable ex)
    {
    ...	
    }
    

    Otherwise the Configuration file may not be found by the application class loader due to different path syntax.

    For further information you can refer to this https://www.sdn.sap.com/irj/sdn/developerareas/java?rid=/webcontent/uuid/e081a4b6-0801-0010-7fa4-c3c7a0454815#hibernate [original link is broken] [original link is broken], although the hibernate.cfg.xml file is placed in the Web-Project in this example.

    Hope this helps,

    Best regards,

    Robin

    Add comment
    10|10000 characters needed characters exceeded