Junit报错:org.hibernate.MappingException: Unknown entity: po.Students








求指教到底哪里错了








求指教到底哪里错了
2016-01-07

http://blog.csdn.net/u010150082/article/details/9527355
你采用的注册方法,被取消了。应该是这个问题。
目录结构没有错,那多半就是在初始化的时候搞错了,导致没有读到Students的配置文件。
StandardServiceRegistry standardRegistry = new StandardServiceRegistryBuilder() .configure() .build(); Metadata metadata = new MetadataSources( standardRegistry ) .getMetadataBuilder() .applyImplicitNamingStrategy( ImplicitNamingStrategyJpaCompliantImpl.INSTANCE ) .build(); sessionFactory = metadata.getSessionFactoryBuilder() .build();
从5.0.7 release的documentation里查找到的方法,实测可用。
具体信息在:hibernate-release-5.0.7.Final\documentation\userGuide\en-US\html\ch03.html中可用详细查看
StandardServiceRegistry standardRegistry = new StandardServiceRegistryBuilder() .configure() .build(); Metadata metadata = new MetadataSources( standardRegistry ) .getMetadataBuilder() .applyImplicitNamingStrategy( ImplicitNamingStrategyJpaCompliantImpl.INSTANCE ) .build(); sessionFactory = metadata.getSessionFactoryBuilder() .build();
这个是从5.0.7 release的documentation里查找到的方法,实测可用。
具体信息在:hibernate-release-5.0.7.Final\documentation\userGuide\en-US\html\ch03.html中可用详细查看
举报