snaker-hibernate/src/main/java/org/snaker/engine/access/hibernate/HibernateHelper.java
private static void initialize() {
		String driver = ConfigHelper.getProperty("jdbc.driver");
		String url = ConfigHelper.getProperty("jdbc.url");
		String username = ConfigHelper.getProperty("jdbc.username");
		String password = ConfigHelper.getProperty("jdbc.password");
		String dialect = ConfigHelper.getProperty("hibernate.dialect");
		AssertHelper.notNull(driver);
		AssertHelper.notNull(url);
		AssertHelper.notNull(username);
		AssertHelper.notNull(password);
		AssertHelper.notNull(dialect);
		String formatSql = ConfigHelper.getProperty("hibernate.format_sql");
		String showSql = ConfigHelper.getProperty("hibernate.show_sql");
		Configuration configuration = new Configuration();
		
		if(StringHelper.isNotEmpty(driver)) {
			configuration.setProperty("hibernate.connection.driver_class", driver);
		}
		if(StringHelper.isNotEmpty(url)) {
			configuration.setProperty("hibernate.connection.url", url);
		}
		if(StringHelper.isNotEmpty(username)) {
			configuration.setProperty("hibernate.connection.username", username);
		}
		if(StringHelper.isNotEmpty(password)) {
			configuration.setProperty("hibernate.connection.password", password);
		}
		if(StringHelper.isNotEmpty(dialect)) {
			configuration.setProperty("hibernate.dialect", dialect);
		}
		if(StringHelper.isNotEmpty(formatSql)) {
			configuration.setProperty("hibernate.format_sql", formatSql);
		}
		if(StringHelper.isNotEmpty(showSql)) {
			configuration.setProperty("hibernate.show_sql", showSql);
		}
		sessionFactory = configuration.configure().buildSessionFactory();
	}
private static void initialize() {
		String driver = ConfigHelper.getProperty("jdbc.driver");
		String url = ConfigHelper.getProperty("jdbc.url");
		String username = ConfigHelper.getProperty("jdbc.username");
		String password = ConfigHelper.getProperty("jdbc.password");
		String dialect = ConfigHelper.getProperty("hibernate.dialect");
		AssertHelper.notNull(driver);
		AssertHelper.notNull(url);
		AssertHelper.notNull(username);
		AssertHelper.notNull(password);
		AssertHelper.notNull(dialect);
		String formatSql = ConfigHelper.getProperty("hibernate.format_sql");
		String showSql = ConfigHelper.getProperty("hibernate.show_sql");
		Configuration configuration = new Configuration();
		
		if(StringHelper.isNotEmpty(driver)) {
			configuration.setProperty("hibernate.connection.driver_class", driver);
		}
		if(StringHelper.isNotEmpty(url)) {
			configuration.setProperty("hibernate.connection.url", url);
		}
		if(StringHelper.isNotEmpty(username)) {
			configuration.setProperty("hibernate.connection.username", username);
		}
		if(StringHelper.isNotEmpty(password)) {
			configuration.setProperty("hibernate.connection.password", password);
		}
		if(StringHelper.isNotEmpty(dialect)) {
			configuration.setProperty("hibernate.dialect", dialect);
		}
		if(StringHelper.isNotEmpty(formatSql)) {
			configuration.setProperty("hibernate.format_sql", formatSql);
		}
		if(StringHelper.isNotEmpty(showSql)) {
			configuration.setProperty("hibernate.show_sql", showSql);
		}
		sessionFactory = configuration.configure().buildSessionFactory();
	}
private static void initialize ( ) { String driver = ConfigHelper . getProperty ( "jdbc.driver" ) ; String url = ConfigHelper . getProperty ( "jdbc.url" ) ; String username = ConfigHelper . getProperty ( "jdbc.username" ) ; String password = ConfigHelper . getProperty ( "jdbc.password" ) ; String dialect = ConfigHelper . getProperty ( "hibernate.dialect" ) ; AssertHelper . notNull ( driver ) ; AssertHelper . notNull ( url ) ; AssertHelper . notNull ( username ) ; AssertHelper . notNull ( password ) ; AssertHelper . notNull ( dialect ) ; String formatSql = ConfigHelper . getProperty ( "hibernate.format_sql" ) ; String showSql = ConfigHelper . getProperty ( "hibernate.show_sql" ) ; Configuration configuration = new Configuration ( ) ; if ( StringHelper . isNotEmpty ( driver ) ) { configuration . setProperty ( "hibernate.connection.driver_class" , driver ) ; } if ( StringHelper . isNotEmpty ( url ) ) { configuration . setProperty ( "hibernate.connection.url" , url ) ; } if ( StringHelper . isNotEmpty ( username ) ) { configuration . setProperty ( "hibernate.connection.username" , username ) ; } if ( StringHelper . isNotEmpty ( password ) ) { configuration . setProperty ( "hibernate.connection.password" , password ) ; } if ( StringHelper . isNotEmpty ( dialect ) ) { configuration . setProperty ( "hibernate.dialect" , dialect ) ; } if ( StringHelper . isNotEmpty ( formatSql ) ) { configuration . setProperty ( "hibernate.format_sql" , formatSql ) ; } if ( StringHelper . isNotEmpty ( showSql ) ) { configuration . setProperty ( "hibernate.show_sql" , showSql ) ; } sessionFactory = configuration . configure ( ) . buildSessionFactory ( ) ; }
在没有任何SessionFactory注入的情况下，默认加载hibernate.cfg.xml初始化sessionFactory
这里只设置了常用的属性，建议调用Configuration.initAccessDBObject方法注入sessionfactory
或者使用ioc容器注入
在没有任何SessionFactory注入的情况下，默认加载hibernate . cfg . xml初始化sessionFactory 这里只设置了常用的属性，建议调用Configuration . initAccessDBObject方法注入sessionfactory 或者使用ioc容器注入