hibernateutil.java

来自「主要是对hibernate数据库的一个简单例子」· Java 代码 · 共 24 行

JAVA
24
字号
package com;
import org.hibernate.SessionFactory;    
import org.hibernate.cfg.Configuration;  
	   public class HibernateUtil {   
		private static SessionFactory sf=null;;    
	   
	    static {    
	        try {    
	            // Create the SessionFactory from hibernate.cfg.xml    
	            	sf = new Configuration().configure()    
	                    .buildSessionFactory();    
	        } catch (Throwable ex) {    
	            // Make sure you log the exception, as it might be swallowed    
	            System.err.println("Initial SessionFactory creation failed." + ex);    
	            throw new ExceptionInInitializerError(ex);    
	        }    
	    }    
	   
	    public static SessionFactory getSessionFactory() {    
	        return sf;    
	    }    
	   
	}   

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?