c# - ActiveRecord / NHibernate: Update error on Query -


i have search feature on website fails. build in c# / asp.net / webforms , uses activerecord.

basically seams when many records returned view in database en update error.

string query = "s"; order[] orders = new order[] { order.asc("lastname") }; list<icriterion> crit = new list<icriterion>(); crit.add(expression.sql(string.format("lastname" '%{0}%' or firstname '%{0}%'", query))); var rv = activerecordbase.findall(typeof(vmyview), orders, crit.toarray()) 

the above part of code failes on findall command, when using 's' query search (where many results). using 'x' query works charm.

the error is:

view or function 'vallowedvessels' not updatable because modification affects multiple base tables.  description: unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code.   exception details: system.data.sqlclient.sqlexception: view or function 'vallowedvessels' not updatable because modification affects multiple base tables.  source error:   line 74:             list<icriterion> crit = new list<icriterion>(); line 75:             crit.add(expression.sql(string.format("lastname" '%{0}%' or firstname '%{0}%'", query))); line 75:             var rv = activerecordbase.findall(typeof(vmyview), orders, crit.toarray()) <--- highlighted in red!  stack trace: [genericadoexception: not update: [ovf.model.vallowedvessels#3843][sql: update vallowedvessels set fixtureid = ?, contractdate = ?, no = ?, contractform = ?, vesselname = ?, status = ?, createddate = ?, buyer = ?, buyername = ?, buyershortname = ?, buyprincipal = ?, buyprincipalname = ?, seller = ?, sellername = ?, selprincipal = ?, selprincipalname = ?, operator = ?, broker = ?, usrcode = ? vesselfolderid = ?]] nhibernate.persister.entity.abstractentitypersister.update(object id, object[] fields, object[] oldfields, object rowid, boolean[] includeproperty, int32 j, object oldversion, object obj, sqlcommandinfo sql, isessionimplementor session) +2474 nhibernate.persister.entity.abstractentitypersister.updateorinsert(object id, object[] fields, object[] oldfields, object rowid, boolean[] includeproperty, int32 j, object oldversion, object obj, sqlcommandinfo sql, isessionimplementor session) +335 nhibernate.persister.entity.abstractentitypersister.update(object id, object[] fields, int32[] dirtyfields, boolean hasdirtycollection, object[] oldfields, object oldversion, object obj, object rowid, isessionimplementor session) +1898 nhibernate.action.entityupdateaction.execute() +764 nhibernate.engine.actionqueue.execute(iexecutable executable) +48 nhibernate.engine.actionqueue.executeactions(ilist list) +128 nhibernate.engine.actionqueue.executeactions() +50 nhibernate.event.default.abstractflushingeventlistener.performexecutions(ieventsource session) +215 nhibernate.event.default.defaultautoflusheventlistener.onautoflush(autoflushevent event) +225 nhibernate.impl.sessionimpl.autoflushifrequired(iset`1 queryspaces) +288 nhibernate.impl.sessionimpl.list(criteriaimpl criteria, ilist results) +524 nhibernate.impl.criteriaimpl.list(ilist results) +76 nhibernate.impl.criteriaimpl.list() +71 castle.activerecord.activerecordbase.findall(type targettype, order[] orders, icriterion[] criteria) in c:\teamcity\buildagent\work\e41ee5ead2eba140\src\castle.activerecord\framework\activerecordbase.cs:1034  [activerecordexception: not perform findall vallowedvessels] castle.activerecord.activerecordbase.findall(type targettype, order[] orders, icriterion[] criteria) in c:\teamcity\buildagent\work\e41ee5ead2eba140\src\castle.activerecord\framework\activerecordbase.cs:1046 ovf.model.vallowedvessels.searchbytype(string query, string typename, string usrcode) in g:\dev\2012\ontrack\model\profile\vallowedvessels.cs:76 search_default.bindvesselfolders() in g:\dev\2012\ontrack\webapp\search\default.aspx.cs:155 search_default.changestatus(object sender, eventargs e) in g:\dev\2012\ontrack\webapp\search\default.aspx.cs:145 system.web.ui.webcontrols.listcontrol.onselectedindexchanged(eventargs e) +116 system.web.ui.webcontrols.dropdownlist.raisepostdatachangedevent() +133 system.web.ui.webcontrols.dropdownlist.system.web.ui.ipostbackdatahandler.raisepostdatachangedevent() +13 system.web.ui.page.raisechangedevents() +132 system.web.ui.page.processrequestmain(boolean includestagesbeforeasyncpoint, boolean includestagesafterasyncpoint) +1644 

it should noted not want update - query view.

apparently of data looks it's dirty nh , needs saved though haven't made changes. possibly property getters or custom user types transforming values, such no longer mach values came out of database. example - code problematic:

private string _lastname; public virtual string lastname {     { return _lastname.trim(); }     set { _lastname = value; } } 

even though never touch setter, value of property still looks changed. see if can remove these types of transformations - deal them way.

here's another, easier, way deal this: since cannot save changes through sql view, should add mutable="false" class mapping. see documentation:

changes immutable classes, mutable="false", not persisted.

in fluent nhibernate, use readonly() method control mutable flag.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -