我在这里关注有关 hibernate 的有趣教程:http://www.tutorialspoint.com/hibernate/hibernate_native_sql.htm
但是,本教程忽略了将这些文件放在何处。我正在使用基本Maven项目的文件夹结构。
文件夹结构如下:
foo
└───src
└───main
├───java
│ └───org
│ └───me
│ └───bar
│ └───[all my java source-files here]
└───resources
├───hibernate.cfg.xml
└───hiber
└───Employee.hbm.xml
如果ASCII技术不明显,文件夹
main
的java
和resources
处于同一级别。 (编辑:现在是。)映射文件(Employee.hbm.xml)应该放在哪里?该文件在配置文件(hibernate.cfg.xml)中引用。
谢谢您阅读此篇。
问候,
最佳答案
您应该将“ hibernate.cfg.xml ”放在“/src/main/resources ”下
您应该将所有模型映射文件放在定义POJO模型类的目录下。
根据您提供的目录结构,它应该像;
foo
└───src
└───main
├───java
│ └───org
│ └───me
│ └───bar
│ └───[all your java Model source-files here]
| Employee.java
| Employee.hbm.xml
| Customer.java
| Customer.hbm.xml
└───resources
└───hibernate.cfg.xml
并且您应该在 hibernate.cfg.xml 文件中引用/映射所有模型文件,如下所示;
<mapping resource="org/me/bar/Employee.hbm.xml"/>
<mapping resource="org/me/bar/Customer.hbm.xml"/>
您也可以检查一下,捕获我的项目文件夹;