淺析加速Hibernate應(yīng)用程序開發(fā)
Hibernate還是比較常用的,于是我研究了一下加速Hibernate應(yīng)用程序開發(fā),在這里拿出來和大家分享一下,希望對大家有用。
在Eclipse中利用HibernateSynchronizer插件,進(jìn)行數(shù)據(jù)庫表的映射,數(shù)據(jù)查詢和獲取數(shù)據(jù),可以節(jié)省大量時間,加速Hibernate應(yīng)用程序開發(fā)。
針對插件產(chǎn)生的hibernate.cfg.xml配置文件,在此有幾點(diǎn)需要注意的問題:
1.若沒有使用JTA來控制事務(wù),需要將如下語句注釋掉!
- <property name="hibernate.transaction.factory_class">
- org.hibernate.transaction.JDBCTransactionFactory
- < SPAN>property>
2.為解決插入和讀取數(shù)據(jù)的中文亂碼問題,可以在上面添加如下語句:
- <property name="connection.useUnicode">true< SPAN>property>
- <property name="connection.characterEncoding">GBK< SPAN>property>
3.當(dāng)單擊”Add Mapping Referance”時,hibernate.cfg.xml文件頭部信息將丟失,此為HibernateSynchronizer插件BUG,需將如下語句添加文件首部:
- xml version="1.0" encoding="utf-8"?>
- PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
以上介紹加速Hibernate應(yīng)用程序開發(fā)。
【編輯推薦】