【发布时间】:2011-03-19 21:56:30
【问题描述】:
我正在尝试从 JBoss 网站上学习 Hibernate 教程。基本上它是一个非常简单的应用程序,可以将事件添加到数据库中。
有一个 org.hibernate.tutorial.domain.Event 和一个 Event.hbm.xml 文件。
问题是: 无论我在做什么,当我初始化配置对象时,我都会得到一个 org.hibernate.MappingNotFoundException 资源:Event.hbm.xml not fohund。 我将其初始化如下:
File hibernateCfgFile = new File("C:/Program Files/Development/IDE/workspace/Hibernate3.6/hibernate.cfg.xml");
try {
// Create the SessionFactory from hibernate.cfg.xml
return new Configuration().configure(hibernateCfgFile).buildSessionFactory();
}
我尝试在 hibernate.cfg.xml 文件中指定 hbm 文件的完整路径 但没有成功。
另一个奇怪的点是我必须指定 hibernate.cfg.xml 位置。没有,即使它在 src 文件夹中也找不到文件。
有什么想法吗??
【问题讨论】:
-
向我们展示了休眠 cfg 文件
标签: java hibernate hibernate-mapping hibernate.cfg.xml