国产探花免费观看_亚洲丰满少妇自慰呻吟_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://www.survivalescaperooms.com)



發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 贺兰县| 永嘉县| 夏河县| 余姚市| 诸暨市| 喀喇沁旗| 长寿区| 昌图县| 聂拉木县| 横峰县| 洛浦县| 南昌市| 四会市| 临清市| 宜川县| 巍山| 双辽市| 辽源市| 万宁市| 射洪县| 邳州市| 景宁| 天台县| 米脂县| 万载县| 大竹县| 永昌县| 海兴县| 海盐县| 通州市| 开化县| 兴国县| 岱山县| 新平| 佛冈县| 金溪县| 隆化县| 田阳县| 建宁县| 芦溪县| 包头市|