c# - NHibernate stored procedure returns data from previous query -


i use 2 stored procedures return data same structure (list of records of same type).

i call method execute(isession session) twice. first time first stored procedure (it returns correct list of 6 rows). second time - second stored procedure (it returns list of 11 rows, first 6 rows first request overwrite correct rows).

i found impact on nhibernate caching searches results including calculated value mapped formula (e.g. rank)

but can't use iquery

any ideas or links how can fixed ?

public dynamic execute(isession session) {     var query = session.getnamedquery(queryname)         .setcacheable(false)         .setcachemode(cachemode.ignore)         .setreadonly(true);     var results = query.list<t>();     return results; } 

i'm going take stab @ answering this, because think have hunch of what's going on, , want set on right track. i've made lot of assumptions here, please don't harsh on me if wrong guesses.

it feels you're trying use nhibernate tool translate rows objects. instead nhibernate tool translates between object oriented domain model , relational database domain model. lot more turn rows objects. in particular, nhibernate feature you're tripping on here how nhibernate ensures within single nhibernate session, single row in database represents single entity correspond single instance of object. uses first-level cache accomplish this.

let's have 2 queries, querya , queryb. these queries have been constructed each pull separate tables, tablea , tableb, represent separate entities. however, queries have somehow been built result nhibernate same entity. if querya , queryb happen return of same ids, nhibernate combine them same instance, see of results querya repeated when run queryb.

so how fix it?

the quick , dirty fix use different sessions each of 2 queries, or throw session.clear() in-between them. more appropriate fix change these named queries return 2 different entities.


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. ? -