Re: bug or code mistage?

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue Aug 31 2004 - 09:42:07 EDT

  • Next message: Andrus Adamchik: "Re: Fixing fragile mapping with Ashwood"

    The code looks ok, so this may be something in the query. You should
    first resolve your issues with SQL logging. Otherwise it is hard to
    tell what is really going on. Twan correctly pointed you to the logging
    configuration instructions, I am not sure why you still don't see SQL
    output. As long as
    "log4j.logger.org.objectstyle.cayenne.access.QueryLogger = INFO" is
    setup (which happens to be the default in the logging config file
    shipped with Cayenne), you should see SQL output in the appropriate log
    file or STDOUT. Are you deploying in a web container? There maybe some
    container-specific issues.

    >        DataContext dataContext = …
    > SelectQuery storedQuery =  (SelectQuery)
    > dataContext.getEntityResolver().lookupQuery("TryQuery");
    >         Map parameters = new HashMap();
    >         parameters.put("vorname", name);
    >         storedQuery = storedQuery.queryWithParameters(parameters);
    >         List objects = dataContext.performQuery(storedQuery);

    BTW, if you are using one of the latest betas, you can simplify this
    code by doing this instead:

    Map parameters = new HashMap();
    parameters.put("vorname", name);
    List objects = dataContext.performQuery("TryQuery", parameters, false);

    Andrus

    On Aug 31, 2004, at 8:07 AM, Sako! wrote:
    > hello,
    >
    > the Fetch is limited to 1
    >
    > ----------------------------------------------
    >
    > code
    >
    >     private void readFromQuery(String name)   
    >
    >    {
    >
    >         DataContext dataContext = …
    > SelectQuery storedQuery =  (SelectQuery)
    > dataContext.getEntityResolver().lookupQuery("TryQuery");
    >         Map parameters = new HashMap();
    >         parameters.put("vorname", name);
    >         storedQuery = storedQuery.queryWithParameters(parameters);
    >         List objects = dataContext.performQuery(storedQuery);
    >         Adressen gallery = (Adressen) objects.get(0);
    >        }
    > ----------------------------------------------
    >  
    >
    >
    > i thought when i use performQuery ( query with parameters)
    >
    > i will get a row with the correct query.
    >
    >  
    >
    >  
    >
    > in line >>  parameters.put("vorname", name);
    >
    > if name = "asdfskfjsfjlsöafjsalöfsöldfj" // mean a name which doesnt
    > exist. i get the first row in the table
    >
    >  
    >
    > the same result when i use a wrong parameter name like
    >
    >
    > in line >>  parameters.put("vornaaaame", name); // in Cayenne the
    > param is $vorname
    >
    >  
    >
    > thanks
    >
    >
    > Sako.



    This archive was generated by hypermail 2.0.0 : Tue Aug 31 2004 - 09:42:12 EDT