Configuration cfg = new Configuration().configure();
Configuration
Configuration 类的作用是对Hibernate 进行配置,以及对它进行启动。在Hibernate 的启动过程中,Configuration 类的实例首先定位映射文档的位置,读取这些配置,然后创建一个SessionFactory对象。虽然Configuration 类在整个Hibernate 项目中只扮演着一个很小的角色,但它是启动hibernate 时所遇到的第一个对象。
■作用:加载核心配置文件
▲hibernate.properties
Configuration cfg = new Configuration();
▲hibernate.cfg.xml
■加载映射文件
//手动加载
configuration.addResource("com/test/customer.hbm.xml");
hibernate.cfg.xml 里配置
<mapping resource="com/test/customer.hbm.xml" />
SessionFactory:Session工厂
SessionFactory