Reputation: 1020
In my application I am using nhibernate 2.2. I have a table named ReportMaster. In this table it has a field named JOB_NUM. This filed has data as follows
JOB_NUM
CT-2012-0072
GEN-2012-0003
UKNDT-2012-0001
CT-2012-0076-EN
In my property class this was mapped to JobNumber filed. My problem is when I used the query as {JobNumber in (CT-2012-0072)} or {JobNumber in (UKNDT-2012-0001)} it gives me the record. But when I used the query as {JobNumber in (GEN-2012-0003)} it does not return the record.
Anybody have an idea about this misbehave? Is "GEN" is a nhibernate keyword? I tried {JobNumber in ("GEN-2012-0003")} as well. it also does not return the record I used the code as follows:
ArrayList searchValues = new ArrayList();
string jobNumber = "CT-2012-0072";
searchValues.Add(jobNumber);
ArrayList reportColumns = new ArrayList();
reportColumns.Add("JobNumber");
IList reports = connection.LoadListByColumnFilter<OutageReport>("JobNumber", searchValues);
public IList LoadListByColumnFilter<T>(string column, ArrayList values)
{
if (session == null)
{
return null;
}
else
{
IList list = null;
ICriteria criteria = session.CreateCriteria(typeof(T));
criteria.Add(Expression.In(column, values));
list = criteria.List();
return list;
}
}
Upvotes: 1
Views: 96
Reputation: 3490
If the code is working for some value then it seems to be correct. My guess would be that the GEN-2012-0003 record is not returned because the database contents is not what it looks like. For example:
I would suggest to switch on hibernate SQL logging and check the generated SQL statements. Then copy the statement in your SQL tool and try to execute it there and see if it returns the record. If not, then this is not a hibernate problem.
Upvotes: 2