Hi,
I am into the process of upgrading Hibernate from version 2.1.6 to 3.0.5. Due to certain problems in new Hibernate tools (hibernate-tools-3.1.0.alpha5) I decided to continue making use of old tools to convert all the *.hbm.xml files to Java source files.
I changed the DTD from 2.0 to 3.0 across all *.hbm.xml files as the Hibernate 3 Migration guide says following regarding DTD change:
Quote:
DTD
Update the DTD reference in your hbm XML files. Change
http://hibernate.sourceforge.net/hibern ... ng-2.0.dtdto
http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in the DOCTYPE.
If your application took 5 seconds to startup and now takes 50 with Hibernate3,
you forgot to change the DTD. Hibernate will then try to lookup (and timeout) the
DTD on the Internet for every mapping file instead of its JAR file.
But change in DTD from version 2.0 to 3.0 causes following side effects:
1. Slow conversion from *.hbm.xml to java files (As it tries to look for the 3.0 DTD in hibernate2.jar and doesn't find it there so goes over internet)
2. Following kind of id member is being generated as long primitive type rather than java.lang.Long class type.(Which is generating java.lang.Long data type if the DTD is 2.0)
Code:
<id name="guid" type="long">
<meta attribute="scope-set">protected</meta>
<column name="guid"/>
<generator class="com.quinstreet.persistence.GuidGenerator"/>
</id>
To overcome the problem 1 , I just added the 3.0 DTD to hibernate2.jar and it gave the fast performance :).
To overcome the problem 2, I need to either change the type to java.lang.Long or add a <meta ..> tag (Specifying the property-type atttribute as java.lang.Long).
Now problem 2 really surprises me. If I keep 2.0 DTD across all *.hbm.xml files then it generates the datatype as java.lang.Long and not the primitive type long for the above mentioned code. The thing that I don't understand is how come change of DTD from 2.0 to 3.0 affect the conversion process when I am continuing the use of old hibernate tools?