I am very new to Hibernate. I am trying to follow the first tutorial for 4.1.6 Final. Following is the
http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#tutorial-firstapp-setup
I setup the project using maven and use the same codes from the tutorial. When I tried to run the EventManager, I got following exceptions.
Code:
Initial SessionFactory creation failed.org.hibernate.InvalidMappingException: Could not parse mapping document from resource org/hibernate/tutorial/domain/Event.hbm.xml
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.hibernate.tutorial.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:31)
at org.hibernate.tutorial.util.HibernateUtil.<clinit>(HibernateUtil.java:14)
at org.hibernate.tutorial.EventManager.createAndStoreEvent(EventManager.java:35)
at org.hibernate.tutorial.EventManager.main(EventManager.java:17)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource org/hibernate/tutorial/domain/Event.hbm.xml
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:3411)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXmlQueue(Configuration.java:3400)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3388)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1341)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1733)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1784)
at org.hibernate.tutorial.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:25)
... 3 more
Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping org.hibernate.tutorial.domain.Event
at org.hibernate.cfg.Configuration$MappingsImpl.addClass(Configuration.java:2576)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:173)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:3408)
... 9 more
Could anyone help me on this?
The other problem I have is that the way to create a service SessionFactory in tutorial is actually using a deprecated method.
conf.configure().buildSessionFactory()
I wonder if there is better way to create the factory.