Apostrophe escaping in select

From: Mark Fraser (mar..ark100.net)
Date: Wed Feb 11 2009 - 23:45:20 EST

  • Next message: Robert Zeigler: "Re: Apostrophe escaping in select"

    hello,

    I am using Cayenne 2.0.4 in a standalone application with Derby embedded.

    The following code breaks for obvious reasons when there is an
    apostrophe ("'") in the person's name.

    ---------

    SQLTemplate template = new SQLTemplate(Person.class, "SELECT * FROM
    people where country_id=" + String.valueOf(country.getId()) + " and
    name='" + name + "'");

    List res = dataContext().performQuery(template);
    ---------

    What is the best (Cayenne specific or otherwise) approach to dealing
    with this problem?

    Thanks



    This archive was generated by hypermail 2.0.0 : Wed Feb 11 2009 - 23:46:01 EST