Can I use a different filename than hibernate.cfg.xml in my application

Can I use a different hibernate filename than hibernate.cfg.xml in my application where I am using Hibernate as the ORM Framework?

configuration = new Configuration();
sessionFactory = configuration.configure("MyFileName.cfg.xml")
        .buildSessionFactory();

      

I want to use a different filename in my application?

+3


source to share


1 answer


Yes, you can. In this case, it must be explicitly specified, as you do in the above code. If the file is on the classpath, you don't need to have a forward slash in front of the file name.

configuration = new Configuration();
sessionFactory = configuration.configure("MyFileName.cfg.xml")
    .buildSessionFactory();

      



Here MyFileName.cfg.xml must be present on the classpath.

+5


source







All Articles