Code example for AnnotationConfiguration

Methods: configurebuildSessionFactory

0
					.setProperty("myeclipse.connection.profile", "mysql"); 
			extraProperties.setProperty("connection.driver_class", 
					"com.mysql.jdbc.Driver");*/ 
			// final Configuration cfg = new Configuration(); 
			// //这是读com/login/system/dao/impl/Users.hbm.xml 
			final AnnotationConfiguration cfg = new AnnotationConfiguration(); // 这里读com.login.system.bean.Users
			//cfg.addProperties(extraProperties); 
			cfg.configure();//("/hibernate.cfg.xml"); // 路径可以改变
			sessionFactory = cfg.buildSessionFactory();
		/*} catch (final UnsupportedEncodingException e) { 
			// 不支持字符编码。 
			e.printStackTrace(); 
		} catch (final FileNotFoundException e) { 
			// jdbc.properties文件没找到 
			e.printStackTrace(); 
		} catch (final HibernateException e) { 
			// cfg.configure("hibernate.cfg.xml");时异常 
			e.printStackTrace();*/ 
		} catch (final Exception e) {
			// 创建SessionFactory 异常