Hibernate Configuration with No XML
Filed in archive Programming by jason on November 27, 2005

Click to enlargeThis is something I'm not sure everyone knows because I've searched a number of tutorials on the subject and not found anything. Additionally I'm not a big fan of XML configuration files unless they are absolutely required. Spring seems to be the exception to that rule for me since the drudgery involved in the XML configuration of it has such a large return on the time invested.
Anyway, Someone helped me with this the other day. I had been spending a lot of time getting my Hibernate configuration file working the way I wanted. After I finished an associate forwarded me a sample of some code they were working on and I thought it was pretty cool. I then rewrote my configuration file as properties in a Java class and like it with the hibernate
configuration in a Java class. With this configuration and XDoclet there is no need to write any XML when using Hibernate at all. I'm sure there are developers out there that like using XML instead but this is one more option. Changes would require a recompile... obviously. However, a change to an XML file would require an application to be restarted, which is much less severe but would affect the user experience as well. I guess it all depends on individual developers preferences and their like or dislike of XML configuration files.
Permalink: Hibernate Configuration with No XML
Tags:
Hibernate XML
Trackback: http://www.creative-weblogging.com/cgi-bin/mt-tb.pl/11523









