Re: EJBQL and parameters

From: Francois Eyl (fey..maeur.com)
Date: Wed Apr 08 2009 - 10:08:48 EDT

  • Next message: Joseph Schmidt: "Can't delete in Cayenne 3M5 :("

    oh, sorry it's my bad. I did a typing mistake I wanted to type :
    query.setParameter("SKDID", UserSchedule.SCHEDULE_ID_PROPERTY);

    Robert, you right, I'm trying to use paramters to specify Columns and so use
    available constants coming from Cayenne. This way, even if columns name
    change, nothing to change into the query. But, parameters sounds work only
    for values :(

    No working solution please ?

    Thanks,
    Francois

    2009/4/8 Robert Zeigler <robert.zeigle..oxanemy.com>

    > Hm. I've never thought about specifying the columns and table via
    > parameters.
    > Event supposing that this works (not convinced it does/will), do you
    > actually have a property named 1 in the UserSchedule entity
    > (select us.:SKDID...setParameter("SKDID",1) => select us.1)?
    >
    > Try specifying the entity and property names directly. Parameters are
    > generally used for parameterized values, like:
    >
    > EJQLQuery query = new EJBQLQuery("select us.sku from UserSchedule us where
    > us.userId=:id");
    > query.setParameter("id",1);
    >
    > Robert
    >
    >
    > On Apr 8, 2009, at 4/84:48 AM , Francois Eyl wrote:
    >
    > Howdy guys,
    >>
    >> I'm trying to use EJBQL query and parameters, but I can't get it to work.
    >> Is
    >> there something special for ?
    >> Bellow is a quick sample of what I'm doing :
    >>
    >> String queryString = "SELECT us.:SKDID FROM :USCHED us WHERE
    >> us.:UID=1";
    >> EJBQLQuery query = new EJBQLQuery(queryString);
    >>
    >> query.setParameter("SKDID", 1);
    >> query.setParameter("USCHED",
    >> UserSchedule.class.getSimpleName());
    >> query.setParameter("UID", UserSchedule.USER_ID_PROPERTY);
    >>
    >> try {
    >> ctx.getContext().performQuery(query);
    >> } catch (CayenneRuntimeException e) {
    >> System.err.println(e.getMessage());
    >> }
    >>
    >> I'm getting the following message : "[v.3.0M5 Dec 09 2008 00:42:23] Error
    >> parsing EJB QL statement".
    >>
    >> Can somebody tell me where I'm wrong ?
    >>
    >> Thanks,
    >> Francois.
    >>
    >
    >



    This archive was generated by hypermail 2.0.0 : Wed Apr 08 2009 - 10:09:20 EDT