1

For an ASP.Net project I'm using (Fluent) NHibernate for the persistence and JQGrid for displaying the data in a table. But when I want to use the AutoComplete feature of JQGrid I get an System.ArgumentException: Column 'HibernateLazyInitializer' does not belong with this table. while obtaining the data in an AJAX Request. But this error occurs only sporadically and when some kind of proxyclass is used in the list. Therefore I think it has something to with the lazyloading of NHibernate.

protected new void Page_Load(object sender, EventArgs e)
  {
     base.Page_Load(sender, e);
     _jqAutoComplete.DataSource = Session.CreateCriteria<Domain.Brand>()
            .List<Domain.Brand>();
     _jqAutoComplete.DataBind();
  }

Usually the lazyloading is a pretty cool feature. Only in this case it leads to an error and therefore I don't want to disable it in the whole project. So, is there a way of modifying the CreateCriteria for not using LazyLoading but EagerLoading in this one case? Or is there something else I'm missing? If there is a good tutorial for understanding LazyLoading I would be glad too.

Oleg
  • 220,925
  • 34
  • 403
  • 798
Kuepper
  • 992
  • 13
  • 39
  • Which "AutoComplete" feature you mean and how you use it? That is `_jqAutoComplete` object? Do you use probably commercial version of jqGrid from http://www.trirand.net/? – Oleg Mar 15 '11 at 18:39
  • Yes. I use the commerical version with the class called `Trirand.Web.UI.WebControls.JQAutoComplete`. – Kuepper Mar 15 '11 at 19:11
  • Do you tried to post the question in [the trirand.net forum](http://www.trirand.net/forum/)? – Oleg Mar 15 '11 at 19:21
  • Nein hab ich noch nicht. Ich denke, aber dass das ein Problem von meinem NHibernate-Code ist und nicht unbedingt von jqGrid. Außerdem hab ich nicht das Gefühl, dass ich beim trirand-forum brauchbare Hilfe bekommen könnte. – Kuepper Mar 15 '11 at 19:44
  • verstehe... Ich kann leider nur bei free open source jqGrid helfen. Weder NHibernate noch commercial version von jqGrid kenne ich. Mach's gut! – Oleg Mar 15 '11 at 20:50
  • Check this question: http://stackoverflow.com/questions/937388/eager-loading-child-collection-with-nhibernate – Mike Cole Mar 15 '11 at 18:43

1 Answers1

1

I solved the problem differently. Now I'm converting the Domain-Object into the corresponding object from the ViewModel. I'm using ValueInjecter for accomplishing the mapping.

protected new void Page_Load(object sender, EventArgs e)
  {
     base.Page_Load(sender, e);

     var objList = service.getList<Domain.Brand>();
     IList<V> list = new List<ViewModel.Brand>();

     foreach (var el in objList)
     {
        var brand = new ViewModel.Brand();
        list.Add(brand.InjectFrom<FlatLoopValueInjection>(el));
     }

     _jqAutoComplete.DataSource = list;
     _jqAutoComplete.DataBind();
  }

That solution works for me but I'm not totally happy with that.

Kuepper
  • 992
  • 13
  • 39