我有一個應用程序,附帶在這個問題的最後映射類。我的流利nHibernate應用程序不是延遲加載
然而,當我檢索與此命令的類的實例:
// this is NOT a SQL query. This queries the NHibernate object structure, so object names, properties and so forth
// must track to the C# code, irrespective of the DB names
IQuery query = Session.CreateQuery(string.Format("from {0} c where c.Id = :id", table));
query.SetString("id", id.ToString());
IList list = query.List();
if (list.Count > 0)
return (WoWObject) query.List()[0];
else
return null;
應用程序掛起,因爲每個參考及其引用從數據庫中檢索。
我在做什麼錯?我一直在這個問題上停留了一個星期,谷歌上沒有人似乎遇到過這樣的問題。
類:
public sealed class creatureMap : ClassMap <creature>
{
public creatureMap()
{
Table("creature");
LazyLoad();
Id(x => x.Id, "Id");
Map(x => x.Name, "name_lang0");
Map(x => x.ArmorMulti, "acmulti");
Map(x => x.age, "age");
Map(x => x.alwaysitem0, "alwaysitem0");
Map(x => x.alwaysitem1, "alwaysitem1");
Map(x => x.alwaysitem2, "alwaysitem2");
Map(x => x.attackbasetime, "attackbasetime");
Map(x => x.attackcooldowntime, "attackcooldowntime");
Map(x => x.attributemulti0, "attributemulti0");
Map(x => x.attributemulti01, "attributemulti01");
Map(x => x.attributemulti02, "attributemulti02");
Map(x => x.attributemulti03, "attributemulti03");
Map(x => x.attributemulti04, "attributemulti04");
Map(x => x.auctionhouseid, "auctionhouseid");
Map(x => x.bankerid, "bankerid");
Map(x => x.basicammo, "basicammo");
Map(x => x.battlegroundmapid, "battlegroundmapid");
Map(x => x.battlemasterlistid, "battlemasterlistid");
Map(x => x.binderid, "binderid");
Map(x => x.caste, "caste");
Map(x => x.ClassId, "class");
Map(x => x.classification, "classification");
Map(x => x.creaturefamily, "creaturefamily");
References(x => x.creaturemovementinfoid, "creaturemovementinfoid").NotFound.Ignore().LazyLoad();
References(x => x.CreatureType, "creaturetype").NotFound.Ignore().LazyLoad();
Map(x => x.cursorname, "cursorname");
Map(x => x.damageclass, "damageclass");
Map(x => x.damageimmunity, "damageimmunity");
Map(x => x.DMGMulti, "damagemulti");
References(x => x.defaultlootid, "defaultlootid").NotFound.Ignore().LazyLoad();
References(x => x.defaultlootid1, "defaultlootid1").NotFound.Ignore().LazyLoad();
References(x => x.difficultycreatureid0, "difficultycreatureid0").NotFound.Ignore().LazyLoad();
References(x => x.difficultycreatureid1, "difficultycreatureid1").NotFound.Ignore().LazyLoad();
References(x => x.difficultycreatureid2, "difficultycreatureid2").NotFound.Ignore().LazyLoad();
References(x => x.difficultycreatureid3, "difficultycreatureid3").NotFound.Ignore().LazyLoad();
References(x => x.displayid, "displayid").NotFound.Ignore().LazyLoad();
References(x => x.displayid1, "displayid1").NotFound.Ignore().LazyLoad();
References(x => x.displayid2, "displayid2").NotFound.Ignore().LazyLoad();
References(x => x.displayid3, "displayid3").NotFound.Ignore().LazyLoad();
Map(x => x.displayprobability, "displayprobability");
Map(x => x.displayprobability1, "displayprobability1");
Map(x => x.displayprobability2, "displayprobability2");
Map(x => x.displayprobability3, "displayprobability3");
Map(x => x.dmgvariance, "dmgvariance");
References(x => x.Combat, "dungeonencounterid").NotFound.Ignore().LazyLoad();
Map(x => x.PowerMulti, "energymulti");
Map(x => x.expansionid, "expansionid");
References(x => x.factionid, "factionid").NotFound.Ignore().LazyLoad();
Map(x => x.fatalfalldist, "fatalfalldist");
Map(x => x.flags, "flags");
Map(x => x.flagsex, "flagsex");
Map(x => x.flagsexb, "flagsexb");
Map(x => x.flagsexc, "flagsexc");
Map(x => x.flagsexd, "flagsexd");
Map(x => x.gender, "gender");
References(x => x.gossipid, "gossipid").NotFound.Ignore().LazyLoad();
Map(x => x.healthmodifier, "healthmodifier");
Map(x => x.HPMulti, "hpmulti");
References(x => x.immunitiesid, "immunitiesid").NotFound.Ignore().LazyLoad();
References(x => x.interactconditionid, "interactconditionid").NotFound.Ignore().LazyLoad();
References(x => x.interactspellid, "interactspellid").NotFound.Ignore().LazyLoad();
Map(x => x.internalname_flag, "internalname_flag");
Map(x => x.InternalName, "internalname_lang0");
Map(x => x.killfactionadjustcap, "killfactionadjustcap");
References(x => x.killfactionadjustid, "killfactionadjustid").NotFound.Ignore().LazyLoad();
Map(x => x.killfactionadjustmulti, "killfactionadjustmulti");
Map(x => x.maxdamage, "maxdamage");
Map(x => x.MaxLevel, "maxlevel");
Map(x => x.maxrangeddamage, "maxrangeddamage");
References(x => x.meleeonlystringidnum0, "meleeonlystringidnum0").NotFound.Ignore().LazyLoad();
References(x => x.meleeonlystringidnum1, "meleeonlystringidnum1").NotFound.Ignore().LazyLoad();
Map(x => x.memo, "memo");
Map(x => x.mindamage, "mindamage");
Map(x => x.minimapblip, "minimapblip");
References(x => x.minimapblipconditionid, "minimapblipconditionid").NotFound.Ignore().LazyLoad();
Map(x => x.MinLevel, "minlevel");
Map(x => x.minrangeddamage, "minrangeddamage");
References(x => x.mountcreatureid, "mountcreatureid").NotFound.Ignore().LazyLoad();
Map(x => x.name_flag, "name_flag");
Map(x => x.name1_flag, "name1_flag");
Map(x => x.name1_lang0, "name1_lang0");
Map(x => x.name2_flag, "name2_flag");
Map(x => x.name2_lang0, "name2_lang0");
Map(x => x.name3_flag, "name3_flag");
Map(x => x.name3_lang0, "name3_lang0");
Map(x => x.npcinteractions, "npcinteractions");
Map(x => x.npcsoundid, "npcsoundid");
Map(x => x.numhelpfulauras, "numhelpfulauras");
References(x => x.onkillquestclear0, "onkillquestclear0").NotFound.Ignore().LazyLoad();
References(x => x.onkillquestclear1, "onkillquestclear1").NotFound.Ignore().LazyLoad();
References(x => x.onkillquestcomplete0, "onkillquestcomplete0").NotFound.Ignore().LazyLoad();
References(x => x.onkillquestcomplete1, "onkillquestcomplete1").NotFound.Ignore().LazyLoad();
Map(x => x.patch_id, "patch_id");
Map(x => x.petitionid, "petitionid");
Map(x => x.petitionitemlistid, "petitionitemlistid");
Map(x => x.petpersonality, "petpersonality");
Map(x => x.petspellsid, "petspellsid");
References(x => x.phasegroupid, "phasegroupid").NotFound.Ignore().LazyLoad();
References(x => x.phaseid, "phaseid").NotFound.Ignore().LazyLoad();
References(x => x.phaseshift, "phaseshift").NotFound.Ignore().LazyLoad();
Map(x => x.phaseuseflags, "phaseuseflags");
References(x => x.pickpocketlootid, "pickpocketlootid").NotFound.Ignore().LazyLoad();
Map(x => x.playerclass, "playerclass");
Map(x => x.preferredammo, "preferredammo");
References(x => x.proxycreatureid, "proxycreatureid").NotFound.Ignore().LazyLoad();
References(x => x.proxycreatureid1, "proxycreatureid1").NotFound.Ignore().LazyLoad();
Map(x => x.pvppoints, "pvppoints");
References(x => x.questgiverid, "questgiverid").NotFound.Ignore().LazyLoad();
References(x => x.radiid, "radiid").NotFound.Ignore().LazyLoad();
References(x => x.randomtext0, "randomtext0").NotFound.Ignore().LazyLoad();
References(x => x.randomtext1, "randomtext1").NotFound.Ignore().LazyLoad();
Map(x => x.randomtext2, "randomtext2");
Map(x => x.ranking, "ranking");
Map(x => x.recordlocked, "recordlocked");
Map(x => x.referenceflag, "referenceflag");
Map(x => x.required_expansion, "required_expansion");
Map(x => x.resistbonus0, "resistbonus0");
Map(x => x.resistbonus1, "resistbonus1");
Map(x => x.resistbonus2, "resistbonus2");
Map(x => x.resistbonus3, "resistbonus3");
Map(x => x.resistbonus4, "resistbonus4");
Map(x => x.resistbonus5, "resistbonus5");
Map(x => x.resistbonus6, "resistbonus6");
Map(x => x.resistscale0, "resistscale0");
Map(x => x.resistscale1, "resistscale1");
Map(x => x.resistscale2, "resistscale2");
Map(x => x.resistscale3, "resistscale3");
Map(x => x.resistscale4, "resistscale4");
Map(x => x.resistscale5, "resistscale5");
Map(x => x.resistscale6, "resistscale6");
Map(x => x.ridevehiclecreatureid, "ridevehiclecreatureid");
Map(x => x.runspeed, "runspeed");
Map(x => x.schoolimmunity, "schoolimmunity");
References(x => x.skinninglootid, "skinninglootid").NotFound.Ignore().LazyLoad();
References(x => x.spawnspellid, "spawnspellid").NotFound.Ignore().LazyLoad();
Map(x => x.spellimmunity0, "spellimmunity0");
Map(x => x.spellimmunity01, "spellimmunity01");
References(x => x.spellsid, "spellsid").NotFound.Ignore().LazyLoad();
Map(x => x.startanimstate, "startanimstate");
Map(x => x.stateimmunity0, "stateimmunity0");
Map(x => x.stateimmunity01, "stateimmunity01");
Map(x => x.stringid0, "stringid0");
Map(x => x.stringid1, "stringid1");
References(x => x.stringidnum0, "stringidnum0").NotFound.Ignore().LazyLoad();
References(x => x.stringidnum1, "stringidnum1").NotFound.Ignore().LazyLoad();
Map(x => x.targetframepriority, "targetframepriority");
Map(x => x.taxinodeid, "taxinodeid");
Map(x => x.template, "template");
Map(x => x.title_flag, "title_flag");
Map(x => x.title_lang0, "title_lang0");
References(x => x.trainerid, "trainerid").NotFound.Ignore().LazyLoad();
References(x => x.triggersid, "triggersid").NotFound.Ignore().LazyLoad();
References(x => x.VehicleRec, "vehicleid").NotFound.Ignore().LazyLoad();
References(x => x.vendoritemlist, "vendoritemlist").NotFound.Ignore().LazyLoad();
References(x => x.vendorlist0, "vendorlist0").NotFound.Ignore().LazyLoad();
References(x => x.vendorlist01, "vendorlist01").NotFound.Ignore().LazyLoad();
References(x => x.vendorlist02, "vendorlist02").NotFound.Ignore().LazyLoad();
References(x => x.vendorlist03, "vendorlist03").NotFound.Ignore().LazyLoad();
References(x => x.vendorlist04, "vendorlist04").NotFound.Ignore().LazyLoad();
References(x => x.vendorlist05, "vendorlist05").NotFound.Ignore().LazyLoad();
Map(x => x.walkspeed, "walkspeed");
Map(x => x.woweditlock, "woweditlock");
Map(x => x.woweditlockuser, "woweditlockuser");
Map(x => x.XpMulti, "xpmulti");
}
}
}
就是這樣一個可怕的映射...... – Phill 2010-12-03 00:33:38
的確。它反映了服務器上一個非常複雜的實體的狀態。 – 2010-12-04 11:36:43
我認爲數據庫設計是可怕的。 venedorlist0,01,02,03 ....應該在另一個表中。 3nF表示不重複專欄。 – fregas 2012-07-03 21:46:49