Hibernate configuration and startup
The regular way of initializing Hibernate is to build a SessionFactory object from a Configuration object. If you like, you can think of the Configuration as an object representation of a configuration file (or a properties file) for Hibernate. Let’s look at some variations before we wrap it up in the HibernateUtil class. Building a SessionFactory This is an example of a typical Hibernate startup procedure, in one line of code, using automatic configuration file detection: SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); Wait—how did Hibernate know where the configuration file was located and which one to load? When new Configuration() is called, Hibernate searches for a file named hibernate.properties in the root of the classpath. If it’s found, all hibernate.* properties are loaded and added to the Configuration object. When configure() is called, Hibernate searches for a file named hibernate. c...