淺析加速Hibernate應用程序開發
Hibernate還是比較常用的,于是我研究了一下加速Hibernate應用程序開發,在這里拿出來和大家分享一下,希望對大家有用。
在Eclipse中利用HibernateSynchronizer插件,進行數據庫表的映射,數據查詢和獲取數據,可以節省大量時間,加速Hibernate應用程序開發。
針對插件產生的hibernate.cfg.xml配置文件,在此有幾點需要注意的問題:
1.若沒有使用JTA來控制事務,需要將如下語句注釋掉!
- <property name="hibernate.transaction.factory_class">
- org.hibernate.transaction.JDBCTransactionFactory
- < SPAN>property>
2.為解決插入和讀取數據的中文亂碼問題,可以在上面添加如下語句:
- <property name="connection.useUnicode">true< SPAN>property>
- <property name="connection.characterEncoding">GBK< SPAN>property>
3.當單擊”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應用程序開發。
【編輯推薦】