浣嗘槸璇諱唬鐮佷篃鏈夎瘈紿嶏紝灝辨槸灝藉彲鑳界殑鎶撲綇鍜屼綘鏈夊叧鐨勯偅閮ㄥ垎錛屼笉瑕佸湪涓澶у爢浠g爜閲屾氮璐規椂闂淬?br />
絎竴涓寫鍑簅rg.hibernate.cfg.Configuration銆傚洜涓鴻繖涓笢瑗跨敤寰楁渶澶氥?br />
渚嬪addXXXX鏂規硶鏈鍚庨兘璋冪敤鍒癮dd鏂規硶錛屼竴涓嬪瓙灝卞彲浠ヨ煩榪嘚澶氭浠g爜鐩存帴鐪媋dd鏂規硶
protected void add(org.dom4j.Document doc) throws MappingException {
HbmBinder.bindRoot( doc, createMappings(), CollectionHelper.EMPTY_MAP );
}
bindRoot鏂規硶紼嶅井鐪嬩簡涓涓嬶紝涓鐪嬪埌鏄В鏋恱ml鐨勶紝灝卞彲浠ヨ煩榪囦笉鐪嬨傚叾瀹炵寽涔熻兘鐚滃埌鏄В鏋恏bm.xml鐨勩?br />
鏈夋剰鎬濈殑鏄?.hbm.xml"鍦ㄩ噷闈㈡槸鍥哄畾鍐欐鐨勶紝榪炰釜constant 鍙橀噺閮芥病鏈夊仛錛岀湅鏉ヤ綔鑰呬互鍚庢槸涓嶆墦綆楁敼浜?br />
涓旂湅addDirectory鏂規硶
/**
* Read all mapping documents from a directory tree.
* <p/>
* Assumes that any file named <tt>*.hbm.xml</tt> is a mapping document.
*
* @param dir The directory
* @return this (for method chaining purposes)
* @throws MappingException Indicates problems reading the jar file or
* processing the contained mapping documents.
*/
public Configuration addDirectory(File dir) throws MappingException {
File[] files = dir.listFiles();
for ( int i = 0; i < files.length ; i++ ) {
if ( files[i].isDirectory() ) {
addDirectory( files[i] );
}
else if ( files[i].getName().endsWith( ".hbm.xml" ) ) {
addFile( files[i] );
}
}
return this;
}
榪欐浠g爜鍛婅瘔鎴戜滑浠涔堬紵鍛婅瘔鎴戜滑".hbm.xml"绱犲尯鍒嗗ぇ灝忓啓鐨勩傘傘傘?HBM.XML榪欐牱鐨勫悗緙鍚嶄綔鑰呬笉鎵撶畻鎺ュ彈銆傘傘?br />

]]>