I'm using an Oracle database with NHibernate and am getting a very odd exception when I perform an HQL query. The code in question is as follows:
Code:
private static List<ParticipantHdo> GetParticipantsByName(ISession p_nHibSession, string p_name1, string p_name2) {
List<ParticipantHdo> hdoList = new List<ParticipantHdo>();
if (!String.IsNullOrEmpty(p_name1)) {
StringBuilder sql = new StringBuilder();
sql.AppendFormat(" from ParticipantHdo as p where p.Name1 = '{0}' ", p_name1.Replace("\'", "\'\'"));
if (!String.IsNullOrEmpty(p_name2)) {
sql.AppendFormat(" and p.Name2 = '{0}' ", p_name2.Replace("\'", "\'\'"));
}
IList<ParticipantHdo> rawResults = p_nHibSession.CreateQuery(sql.ToString()).List<ParticipantHdo>();
foreach (ParticipantHdo hdo in rawResults)
hdoList.Add(hdo);
}
return hdoList;
}
The problem only occurs when the "p_name1" parameter contains a string that has a comma, followed by a dot, followed by a comma, followed by another dot, with any number of characters between them. For example, some problematic strings would be:
Code:
",.,."
", . , ."
"This, is. also a, problem."
These seems to be an NHibernate bug.
Code: