I have a method that will return a list of suggested orders. If the user passes a null that criteria is ignored.
public IList<SuggestedOrderItem> GetSuggestedOrderItemByCriteria
(
int? itemNumber,
int? deptNumber
)
{
try
{
NHibernate.ICriteria criteria = NHibernateSession.CreateCriteria(typeof(Core.SuggestedOrderItem));
if (itemNumber.HasValue)
criteria.CreateCriteria("Item", "Item").Add(Expression.Eq("Item.ItemNumber", itemNumber.Value));
if (deptNumber.HasValue)
criteria.CreateCriteria("Item.Department", "Department").Add(Expression.Eq("Department.DepartmentNumber", deptNumber.Value));
return criteria.List<Core.SuggestedOrderItem>();
}
catch (NHibernate.HibernateException he)
{
DataAccessException dae = new DataAccessException("NHibernate Exception", he);
throw dae;
}
}
If I provide a criteria, everything works fine. By fine I mean it retrieves the correct suggested orders and they all have different version numbers. If all the criteria are null it retrieves all suggested orders as it should, however the version numbers are all the same. Another developer is working on the UI and he's calling the above method to populate a screen with all orders so the user can select one to modify. When I get his update request though I am refusing it as the version number does not match the actual version for the object. This is how the version column looks in the mapping file:
<version name="Version" type="Int64" generated="always" column="ORA_ROWSCN" access="property" unsaved-value="0"/>
Thank you very much for any assistance!
UPDATE:
I downloaded nhprof to see if the sql query being generated in each case was different. Regardless of if I pass no criteria or I do provide a criteria they are exactly the same except for a where clause. When I ran each of the queries in a db editor, I got the same results I was seeing from my service. Is this some kind of strange oracle issue? If I include a where clause I get different ora_rowscn numbers, otherwise they are all the same.