您的位置:首页 > 移动开发

Rhyme/ Hibernate5.x SessionFactory创建方式 以及org.hibernate.MappingException: Unknown entity异常

2017-10-24 16:13 513 查看

org.hibernate.MappingException: Unknown entity异常处理

通常这个问题是hibernate 不同版本造成的原因,在hibernate5.x以后需要采用下面的sessionFactory创建方式

Hibernate5.x SessionFactory创建方式

Configuration cfg = new Configuration().configure();
ServiceRegistry sr = new StandardServiceRegistryBuilder()
.configure().build();
SessionFactory sf = new MetadataSources(sr)
.buildMetadata().buildSessionFactory();
Session session = sf.openSession();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  hibernate