Is it possible to add mapping in code rather in hibernate.cfg.xml file??
I have one hibernate.cfg.xml file for several different servers and I would like to load the mapping dynamically and not from the cfg file.
Thank you!
Is it possible to add mapping in code rather in hibernate.cfg.xml file??
I have one hibernate.cfg.xml file for several different servers and I would like to load the mapping dynamically and not from the cfg file.
Thank you!
You can configure your entities using the JPA annotations. There are a lot of tutorials for this on the net, an example is Hibernate Annotations.
The answer that worked for me:
AnnotationConfiguration config = new AnnotationConfiguration().configure(hibernateCfgFileName); config.addAnnotatedClass(Myclass.class);