国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

hibernate源碼淺析(net.sf.hibernate.cfg)

2019-11-18 16:18:54
字體:
供稿:網(wǎng)友

  剛剛無聊,看了些源代碼,寫了些記錄。
發(fā)表出來,希望初學(xué)者有用。如有不對的地方,請指正。

Setting類:數(shù)據(jù)庫,連接池設(shè)置的Bean,主要是各種參數(shù)的set&get方法。

Environment類:環(huán)境參數(shù)定義。(常量)

NamingStratgy:命名規(guī)則定義的接口。

DefaultNamingStrategy:默認命名規(guī)則。(實現(xiàn)NamingStratgy接口)

ImPRovedNamingStrategy:改善命名規(guī)則。(實現(xiàn)NamingStratgy接口)
就是加下劃線。其中有個addUnderscores()方法。
private        String addUnderscores(String name) {
StringBuffer buf = new StringBuffer( name.replace('.', '_')        );
for        (int i=1; i<buf.length()-1;        i++) {
if (
'_'!=buf.charAt(i-1) &&
Character.isUpperCase( buf.charAt(i) ) &&
!Character.isUpperCase(        buf.charAt(i+1)        )
) {
buf.insert(i++,        '_');
}
}
return buf.toString().toLowerCase();
}
按大寫分開,加上"_",然后返回小寫的toString();

SettingFactory類:設(shè)置屬性類。
其中有buildSettings(Properties        properties)方法,設(shè)置自定義屬性。

Mapping類:有點不清楚。
設(shè)置類和表之間的映射。class 進去,table出來。:)(了解不清晰。)

Binding類:PO和數(shù)據(jù)庫中表及其之間的映射的綁定。
Configuration類,配置類
Configuration()構(gòu)建器,調(diào)用reset(),重置參數(shù)。
還有addClass(),addFile(),add(Document        doc) ,addDirectory(),addJar(),addInputString(),addResoure()等一系列方法,通過不同的資源進行配置。

還有通過不同參數(shù)重構(gòu)了許多configure()方法。
configure()通過hibernate.cfg.xml配置。
/**
* Use the mappings and properties specified        in an application
* resource named <tt>hibernate.cfg.xml</tt>.
*/
public Configuration configure() throws        HibernateException {
configure("/hibernate.cfg.xml");
return this;
}
然后比較重要的是生成sessionFactory;
public SessionFactory buildSessionFactory()        throws HibernateException {
secondPassCompile();
validate();
Environment.verifyProperties(properties);
Properties copy        = new Properties();
copy.putAll(properties);
Settings settings =        buildSettings();
configureCaches(settings);
return new SessionFactoryImpl(this,        settings);
}

其他的一些就是通過配置文件設(shè)置各種屬性。比如數(shù)據(jù)庫方言Dialect等。
------------------------------------------------------------------------------             
   

(出處:http://m.survivalescaperooms.com)



發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 邻水| 临泉县| 焉耆| 绍兴县| 泌阳县| 桐乡市| 清原| 冀州市| 拉萨市| 西丰县| 金秀| 霞浦县| 黄浦区| 萨迦县| 黄冈市| 周宁县| 中方县| 景谷| 岑巩县| 文山县| 榕江县| 军事| 闵行区| 娱乐| 黑水县| 远安县| 焉耆| 双峰县| 蒙城县| 河池市| 象州县| 凤台县| 沙湾县| 黎川县| 崇州市| 永胜县| 天柱县| 广昌县| 子洲县| 五常市| 霸州市|