The main purpose is to familiarize yourself with the differences between hibernate2 and hibernate3 and provide a little extra space for the current project.
1. Replace hibernate2.jar with hibernate3.jar (hibernate-3.0.5)
The hibernate-tools.jar is also replaced with a new one (found from the hibernate-tools-3.0.0.alpha4a)
2. replace net. SF. hibernate in all programs with org. hibernate.
3. Exceptions
Net. SF. hibernate. expression. expression to org. hibernate. criterion. Expression
If eclipse is used, pressing CTRL + Shift + O can speed up the process.
4. When using hql to query
Createsqlquery (hql, "C", ezcampaigndto. Class); changed to createsqlquery (hql). addentity ("C", ezcampaigndto. Class );
5. During batch insert
Convert the original int size = (sessionfactoryimpl) (session. getsessionfactory (). getjdbcbatchsize ()
Change to int size = (sessionfactoryimpl) (session. getsessionfactory (). getsettings (). getjdbcbatchsize ();
6. When calculating count
Convert the original int size = (integer) Session. iterate (hql). Next (). intvalue ();
Changed to int size = (integer) Session. createquery (hql). iterate (). Next (). intvalue ();
Hql = "select count (*) from" + daovar. contactclass;
7. There is replacing the hibernate-mapping-2.0.dtd in. HBM with the hibernate-mapping-3.0.dtd.
Replace hibernate mapping DTD 2.0 with hibernate mapping DTD 3.0
8. In hibernate. cfg. xml
Replace hibernate mapping DTD 2.0 with hibernate mapping DTD 3.0
<Property name = "hibernate. dialect"> org. hibernate. dialect. sqlserverdialect </property>
9. Similar
10. In cache-config.xml
<Provider classname = "net. SF. hibernate. cache. oscacheprovider"/>
<Provider classname = "org. hibernate. cache. oscacheprovider"/>
11. classeshib.pdf. Properties
Hibernate. cache. provider_class = org. hibernate. cache. ehcacheprovider
Hibernate. dialect = org. hibernate. dialect. sqlserverdialect
12. In the automatic external module, a function is to automatically generate the. HBM File Based on the template and load the file. HBM has a problem:
The generated <composite-ID unsaved-value = "any" mapped = "false"> mapped = "false" has an error. Found for half a day before the online hibernate-mapping-3.0.dtd file has support mapped = "false" This attribute. The hibernate-mapping-3.0.dtd file in the local hebernate3.0.5 does not have this property. Dizzy, Hibernate is too irresponsible. Solution: copy the hibernate-mapping-3.0.dtd to the JBoss/bin directory and then, in the template file <! Doctype hibernate-mapping public "-// hibernate/hibernate mapping DTD // en" "hibernate-mapping-3.0.dtd">, then he will read the file under the JBoss/bin directory.
13. re-test, or just ignore. An exception is thrown when the child class reads the parent class data:
"Org. hibernate. lazyinitializationexception: cocould not initialize proxy"
The error of delayed retrieval. HB3's default processing for slave-to-one is lazy = "proxy". If you don't understand what is going on, take all slave-to-one, after one-to-one is added with lazy = "false", the test is successful.