我该如何在JDO(Google App Engine)中转义查询参数?
例如,如果变量名称可能包含不安全字符,如单引号('),那么如何使下面的代码片段更安全?
PersistenceManager pm = ...;
String query = "select from Person where name='"+name+"'";
List<Shortened> shortened = (List<Shortened>) pm.newQuery(query).execute();
我该如何在JDO(Google App Engine)中转义查询参数?
例如,如果变量名称可能包含不安全字符,如单引号('),那么如何使下面的代码片段更安全?
PersistenceManager pm = ...;
String query = "select from Person where name='"+name+"'";
List<Shortened> shortened = (List<Shortened>) pm.newQuery(query).execute();
Query query = pm.newQuery("select from Employee " +
"where lastName == lastNameParam " +
"order by hireDate desc " +
"parameters String lastNameParam");
List<Employee> results = (List<Employee>) query.execute("Smith");