当所有映射定义被 org.hibernate.cfg.Configuration 解析后,应用程序必须获得一个用于构造 org.hibernate.Session 实例的工厂。这个工厂将被应用程序的所有线程共享:
org.hibernate.cfg.Configuration
org.hibernate.Session
SessionFactory sessions = cfg.buildSessionFactory();
Hibernate 允许你的应用程序创建多个 org.hibernate.SessionFactory 实例。这对 使用多个数据库的应用来说很有用。
org.hibernate.SessionFactory