1

I have an application with the mapping class attached at the end of this question.

However, when I retrieve an instance of the class with this command:

        // 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;       

The application hangs as every reference AND its references are retrieved from the database.

What am I doing wrong? I've been stuck on this problem for a week and no one on google appears to have run into an issue like this.

Class:

    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");
        }
    }
}
3
  • 3
    That is such a scary mapping... Commented Dec 3, 2010 at 0:33
  • 2
    Indeed. It reflects the state of a very complex entity on the server. Commented Dec 4, 2010 at 11:36
  • i think the db design is scary. venedorlist0, 01, 02, 03....those should be in another table. 3nF says not repeating columns. Commented Jul 3, 2012 at 21:46

2 Answers 2

2

You really, really need to refactor your class and therefore your map. It is far too big. Single Responsibility Principle - a class should have only one reason to change. Yours has way too many.

Good luck..

Sign up to request clarification or add additional context in comments.

1 Comment

It's a legacy database and the class format is just a thin interface to it.
0

Apparently, NotFound.Ignore() causes NHibernate to eager-fetch the referenced entity. Can you restructure your code to eliminate the need for NotFound.Ignore().

Here are a couple of links that shed some light on this:

Hope this helps,
Ben

2 Comments

I can try to remove it, but the issue is that there's 2 situations: key value = 0 -> no object. Situation #2 - the database is ancient - there could be dead keys.
Regarding the #2nd situation, can you just let it throw the NotFound exception and catch it at runtime, ignoring it at the calling method/DAO layer instead?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.