課程
/后端開發
/Java
/Hibernate初探之一對多映射
INFO: HHH000041: Configured SessionFactory: null
2016-07-10
源自:Hibernate初探之一對多映射 2-6
正在回答
public class HibernateUtil {
private static SessionFactory sessionFactory = null;
static {
sessionFactory = new Configuration().configure().buildSessionFactory();
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
public static Session getSession() {
return sessionFactory.openSession();
public static Session getSession(boolean flag) {
return flag ? sessionFactory.openSession() : sessionFactory
.getCurrentSession();
在應用類調用
private static SessionFactory sessionFactory = HibernateUtil
.getSessionFactory();
慕神2265354
舉報
Hibernate中一對多關聯映射配置,以及cascade和inverse屬性作用
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-07-11
public class HibernateUtil {
private static SessionFactory sessionFactory = null;
static {
sessionFactory = new Configuration().configure().buildSessionFactory();
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
public static Session getSession() {
return sessionFactory.openSession();
}
public static Session getSession(boolean flag) {
return flag ? sessionFactory.openSession() : sessionFactory
.getCurrentSession();
}
}
在應用類調用
private static SessionFactory sessionFactory = HibernateUtil
.getSessionFactory();