Reputation: 103
I am having this lines of code from documentation
private void createAndStoreEvent(String title, Date theDate) {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Event theEvent = new Event();
theEvent.setTitle(title);
theEvent.setDate(theDate);
session.save(theEvent);
session.getTransaction().commit();
}
Here I am not giving path of Event.hbm.xml file to Hibernate and my doubt is which directory the hibernate refers to find Event.hbm.xml for mapping of Event.java entity class?. Now i am saving Event and Event.hbm.xml file in same package.
Upvotes: 1
Views: 3548
Reputation: 2297
In your hibernate-configuration xml, you should usually define your other hbm files as follows;
<mapping resource="com/domain/Event.hbm.xml"/>
Upvotes: 1
Reputation: 10679
Normally, Event.hbm.xml
should end up in the runtime classpath in the same package as the Event.class
file. Something like /WEB-INF/classes/foo/bar/
if it's a Web application. That being said, putting it in the src
folder might be ok since your IDE
should automatically put it in the /WEB-INF/classes/foo/bar
during the build.
Upvotes: 3