Re: Getting complex queries in cayenne

From: Cris Daniluk (cris.danilu..mail.com)
Date: Fri May 06 2005 - 10:18:35 EDT

  • Next message: tnaki..ofthome.net: "Re: Getting complex queries in cayenne"

    >
    > You said this in you email.
    > If you tried creating SQLTemplates in the Modeler, you may have noticed
    > that each such query allows alternative SQL syntax to be stored under
    > different adapter
    > keys. So each target database can have its own SQL "flavor" without any
    > dependencies in the Java code.
    >
    > Can you tell me how I can create SQLTemplate in modeler? Or anybody has some
    > example for SQLTemaplate?
    >

    The docs are pretty good on SQLTemplates. Check out:

    http://objectstyle.org/cayenne/userguide/fetch/sqltemplate.html

    and...

    http://objectstyle.org/cayenne/userguide/fetch/sqltemplate-scripting.html

    You really have a lot of flexibility to "generate" SQL. For example,
    you may have a set of criteria that changes at runtime. The scripting
    gives you a lot of flexibility in how you 'bind' these criteria.

    I'd start by building your SQLTemplates in code to get the hang of it,
    then move them to the modeler. To add a SQLTEmplate to the modeler,
    create a new Query and select "Raw SQL" as the type. Note that you
    have the option to fetch into DataObjects, or return as a DataRow.

    Under the "SQL Scripts" tab, you can paste your SQL, including any
    bindings or other directives. You can even specify alternate SQL for
    different JDBC drivers if necessary.

    Accessing this query via the application is the same as accessing any
    other named query. See:

    http://objectstyle.org/cayenne/userguide/fetch/datamap-queries.html

    > I am really sorry if I am being annoying here.
    >
    This list is for questions, and this question is as good as any... :)

    Cris



    This archive was generated by hypermail 2.0.0 : Fri May 06 2005 - 10:18:37 EDT