java - Hibernate Tutorial - Where to put Mapping File? -
i following interesting tutorial on hibernate here: http://www.tutorialspoint.com/hibernate/hibernate_native_sql.htm
this tutorial, however, neglects mention put these files. using folder structure of basic maven project.
the folder structure follows:
foo | |-> src | |-> main | | | |-> java | | | |-> org | | | |-> me | | | |-> bar | | | [all java source-files here] | |-> resources | | | |-> hiber | | | employee.hbm.xml | hibernate.cfg.xml
the folder main
has java
, resources
@ same level if not obvious ascii art.
where should mapping file (employee.hbm.xml) go? file referenced in configuration file (hibernate.cfg.xml).
thank-you reading this.
regards,
you should put "hibernate.cfg.xml" under "/src/main/resources" should put model-mapping files under same directory define pojo model classes.
according directory structure you've provided, should like;
foo | |-> src | |-> main | | | |-> java | | | |-> org | | | |-> me | | | |-> bar | | | [all yourjava model source-files here] | employee.java | employee.hbm.xml | customer.java | customer.hbm.xml | | |-> resources | | | | | hibernate.cfg.xml
and should reference/map model files in hibernate.cfg.xml file below;
<mapping resource="org/me/bar/employee.hbm.xml"/> <mapping resource="org/me/bar/customer.hbm.xml"/>
you can check out, capture of project folder;
Comments
Post a Comment