hibernate 5.2.2如何获得session
没有用视频的老版本,请问5.2.2,如何获取session,还要通过服务注册码?
没有用视频的老版本,请问5.2.2,如何获取session,还要通过服务注册码?
2016-09-03
protected void setUp() throws Exception { // A SessionFactory is set up once for an application! final StandardServiceRegistry registry = new StandardServiceRegistryBuilder() .configure() // configures settings from hibernate.cfg.xml .build(); try { sessionFactory = new MetadataSources( registry ).buildMetadata().buildSessionFactory(); } catch (Exception e) { // The registry would be destroyed by the SessionFactory, but we had trouble building the SessionFactory // so destroy it manually. StandardServiceRegistryBuilder.destroy( registry ); } }
查看文档:hibernate-release-5.2.2.Final/documentation/quickstart
举报