hello Kerr,
what is getDataContext() here?
>>List objects = getDataContext().performQuery(query);
thanks.
Sako.
----- Original Message -----
From: "Matt Kerr" <mat..entralparksoftware.com>
To: "Sako!" <webobject..tcc.datos.de>
Cc: "Cayenne" <cayenne-use..bjectstyle.org>
Sent: Friday, June 25, 2004 3:34 PM
Subject: Re: Use Query in Cayenne
> hey webobjects -)
>
> > i face difficulties do find the correct Documentation explinantion
> > about how
> > to use the Query in Cayenne.
> > i mean in the GUI in Cayenne. how to set the Gerner, Orderings,
> > Prefetches.
> > and how to use it in the java code!
>
> i think it goes something like ...
> please note - i did touch this up w/out recompile or anything
> so, if there are syntax errors, missing steps, etc. .. add salt.
> cheers- matt
>
>
> in the modeler:
> ~~~~~~~~~~~~~~~
> 1) Project -> Create Queary
>
> 2) SelectQuery: General panel ...
> * Query Name (eg. "MyMedicalOfficeQuery")
> * Query Root (entity you are fetching, eg. MedicalOffice)
> * Qualifier
> (doctor.lastName likeIgnoreCase $LastNameParam) and (db:doctorNumber =
> $DoctorNumberParam) and (db:groupNumber = $GroupNumberParam)
> [note: the use of "db:" for db attributes]
>
> * these other flavor as needed ... but i see here: Distinct=(No),
> Result Caching=(No), Fetch Data Rows=(No), Refresh Objects=(Yes), Fetch
> Limit=(0), Page Size=(0)
>
> 3) SelectQuery: Orderings panel
> * i see just doctor.lastName (and the first box checked; second box
> not checked -- haha ... yeah ... what does that mean?) ... add/remove
> as needed
>
> 4) SelectQuery: Prefetches panel
> * this one here is empty ... but yeah, add/remove as needed (based on
> your performance needs, etc.)
>
>
> in the .java:
> ~~~~~~~~~~~~~
> 1) create your map (from like FORM values)
> * note the keys here match the query arg keys above
> Map map = new HashMap();
> if (!StringUtils.isEmpty(getGroupNumber())) {
> map.put("GroupNumberParam", getGroupNumber());
> }
> if (!StringUtils.isEmpty(getDoctorNumber())) {
> map.put("DoctorNumberParam", getDoctorNumber());
> }
> if (!StringUtils.isEmpty(getLastName())) {
> map.put("LastNameParam", getLastName() + "%");
> }
>
>
> 2) grab query, and perform fetch ...
> SelectQuery query =
> ModelUtils.queryWithNameAndMap("MyMedicalOfficeQuery", map);
> List objects = getDataContext().performQuery(query);
>
>
> 3) here are straightforward conveniences ...
> ModelUtils.java:
> import org.objectstyle.cayenne.conf.Configuration;
> static public SelectQuery queryWithNameAndMap(String name, Map map) {
> if ( (name == null) || (map == null) ) { // WANNA: assert these
> probably
> return null;
> }
> SelectQuery query = (SelectQuery)
> getEntityResolver().lookupQuery(name);
> return query.queryWithParameters(map);
> }
> static public EntityResolver getEntityResolver() {
> return
> Configuration.getSharedConfiguration().getDomain().getEntityResolver();
> }
>
>
This archive was generated by hypermail 2.0.0 : Mon Jun 28 2004 - 06:31:03 EDT