From: NHibernate J. <mik...@us...> - 2006-11-14 19:41:26
|
[ http://jira.nhibernate.org/browse/NH-793?page=comments#action_14401 ] dstefanov commented on NH-793: ------------------------------ I'm not very familiar with the whole NHibernate API. I'm only using NHybridDataReader and NDataReader in my application. The fix I'm proposing has been tested and is very easy to check. As seen from the repro if you Read() from the reader and the result set is empty then the Read() method returns false. In that case the _isMidstream should show if we are in the middle of reading the result set. In this specific case the dataset is empty and should not be considered in the midstream. If the ReadIntoMemory() is called at this moment it checks the _isMidstream and if true assumes it can safely Read() from the stream (and it will get true or false; both valid). In our case the code fails with exception since we are already at the end of the dataset and there is no more data to read. The fix sets the _isMidstream to false for this case so the ReadIntoMemory() won't Read() from the reader and won't fail. Bottom line is - we can't be in the middle of an empty dataset. > NHybridDataReader.ReadIntoMemory fails when the result is 0 records. "Invalid attempt to read when no data is present". > ----------------------------------------------------------------------------------------------------------------------- > > Key: NH-793 > URL: http://jira.nhibernate.org/browse/NH-793 > Project: NHibernate > Type: Bug > Components: Core > Versions: 1.0.2, 1.0.3 > Reporter: dstefanov > Priority: Critical > > public bool Read() > { > // DS 6/30/06 - If the result is 0 records the read will always return false > // and the _isMidstream should be false so we don't attempt to read from the > // reader when we do ReadIntoMemory. We were getting an error > // "Invalid attempt to read when no data is present" when trying to get data > // from the reader is such cases. > // > //_isMidstream = true; > //return _reader.Read(); > // > _isMidstream = _reader.Read(); > return _isMidstream; > } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |