I am having problems with a query that has an ampersand in a named parameter value. My parameter string is 'R&D', but the debug log only shows binding 'R' to parameter: 2. I therefore do not get back the record that is in my database.
Code:
Code:
String queryStr1 = "FROM Projectdetail pd" +
" WHERE pd.employeeId = :emp" +
" AND pd.activity = :act ";
Query query = session.createQuery(queryStr1)
.setString("emp", employeeId)
.setString("act", activity);
List results = query.list();
I call the function with
Code:
employeeId = "C11"
and
Code:
activity = "R&D"
The log shows:
Code:
2005-07-25 16:31:33,312 DEBUG [org.hibernate.type.StringType] - binding 'R' to parameter: 2
2005-07-25 16:31:33,359 DEBUG [org.hibernate.type.StringType] - binding 'C11' to parameter: 1
Everything works fine if I do not have the ampersand in the activity variable.
Setup details:
Win XP
mySQL 4.1.10
JDBC connector: 3.1.10 (Also downgraded to 3.1.7 with no change)
Hibernate 3.0.5
I would appreciate suggestions on how to fix this problem.