I have pasted Hibernate 3 configuration file , SessionFactory class to configure this config.xml and a bean with JPA annotations. I want to know if I were using
File hibernate.cfg.xml is fine. It may look confusing that version is still 3.0 in hibernate-configuration-3.0.dtd, but thats how it is. DTD was not updated. Maybe you want to use names names prefixed with hibernate instead, for example hibernate.show_sql
instead of show_sql
. Names of properties can be found from documentation. Usually DTD_location used is http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd
(vs. ..sourceforge...), but both should work.
As you see from the API, buildSessionFactory is deprecated. This is how it is built in 4.x:
Configuration conf = new Configuration();
conf.configure();
serviceRegistry = new ServiceRegistryBuilder().applySettings(conf.getProperties()).buildServiceRegistry();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
In many places in documentation this is still not up to date.
In general no changes are needed to your mappings in bean class. Reason is that you are using normal JPA mappings and also Hibernate 3 is implementation of what is described in JPA specification.