課程
/后端開發
/Java
/Hibernate初探之單表映射
求指教到底哪里錯了
2016-01-07
源自:Hibernate初探之單表映射 1-11
正在回答
http://blog.csdn.net/u010150082/article/details/9527355
你采用的注冊方法,被取消了。應該是這個問題。
目錄結構沒有錯,那多半就是在初始化的時候搞錯了,導致沒有讀到Students的配置文件。
聽雨2015 提問者
Its_forever 回復 聽雨2015 提問者
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里查找到的方法,實測可用。
你的映射文件(Student.hbm.xml) 沒有被映射
換個目錄嘛,把Student.hbm.xml放到hibernate.cfg.xml的目錄下試一試。
舉報
Java持久化框架Hibernate入門教程,掌握Hibernate基本概念
4 回答junit測試出錯org.hibernate.MappingException: Unknown entity: com.entity.Student
4 回答 org.hibernate.MappingException: Unknown entity
2 回答org.hibernate.MappingException: Unknown entity: com.entity.Student
4 回答org.hibernate.MappingException: Unknown entity: Students
2 回答org.hibernate.MappingException: Unknown entity: com.imooc.hibernate.Students測試錯誤
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-01-07
http://blog.csdn.net/u010150082/article/details/9527355
你采用的注冊方法,被取消了。應該是這個問題。
目錄結構沒有錯,那多半就是在初始化的時候搞錯了,導致沒有讀到Students的配置文件。
2016-01-17
從5.0.7 release的documentation里查找到的方法,實測可用。
具體信息在:hibernate-release-5.0.7.Final\documentation\userGuide\en-US\html\ch03.html中可用詳細查看
2016-01-17
這個是從5.0.7 release的documentation里查找到的方法,實測可用。
具體信息在:hibernate-release-5.0.7.Final\documentation\userGuide\en-US\html\ch03.html中可用詳細查看
2016-01-07
你的映射文件(Student.hbm.xml) 沒有被映射
換個目錄嘛,把Student.hbm.xml放到hibernate.cfg.xml的目錄下試一試。