314 APPENDIX D n (Web hosting contract) UPGRADING FROM HIBERNATE 2
314 APPENDIX D n UPGRADING FROM HIBERNATE 2 APPENDIX D n UPGRADING FROM HIBERNATE 2 This is not a coincidence in addition to the package name, there are now two versions of the DTDs for the XML configuration files. Unchanged Hibernate 2 code should use the usual mapping DTD reference of http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd And for your new Hibernate 3 code, you will use http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd Similarly, for the Hibernate configuration file, your version 2 code will use http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd And your version 3 code will use http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd nCaution If you do not update your mapping configuration from the Hibernate 2 form to the Hibernate 3 form, the time it takes to create a configuration and session factory will increase from around 20 seconds to a matter of minutes. Obviously, it will not be possible for you to have two configuration files with the same (default) name of hibernate.cfg.xml, but either version of Hibernate permits you to construct a Configuration object and then specify an explicit location for the configuration file using the configure() methods (as shown in Listing D-1). If you are using both versions of Hibernate simultaneously, you must make sure that POJOs are not passed from one version s Session object to another s. If you need to persist your old POJOs using the new version, you must update the older code to use Hibernate 3. For an explanation of how this sort of upgrade is supported by Hibernate 3, see the description of the classic API in the following section, New Features and Support for Old Ones. Listing D-1. Using an Explicitly Named Configuration File in Hibernate 3 File configFile = new File(”hibernate3.cfg.xml”); Configuration v3Config = new Configuration(); v3Config.configure(configFile); SessionFactory sessionFactory = v3Config.buildSessionFactory(); Session session = sessionFactory.openSession(); // … You should be aware that in your Hibernate 3 logic, some of the defaults for entries in the mapping file have changed. If you have logic that relies upon implicit settings, you should review your converted mapping files against the version 3 DTD to check that they will behave as expected. The most significant change is that all mappings now default to lazy loading.
From our experience, we can recommend PHP Web Hosting services, if you need affordable webhost to host and run your web application.