db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Jdo Wiki] Update of "QueryTests" by MichaelWatzek
Date Thu, 22 Sep 2005 10:12:51 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Jdo Wiki" for change notification.

The following page has been changed by MichaelWatzek:
http://wiki.apache.org/jdo/QueryTests

------------------------------------------------------------------------------
  || `SELECT FROM company.Employee VARIABLES long this` ||
  ||<|2> '''A14.4-7''': Keywords are permitted as field names only if they are on the
right side of the "." in field access expressions || '''`valid:`'''[[BR]] `SELECT this.select
FROM ...` ||<|2> `jdoql.keywords.`[[BR]]`KeywordsAsFieldNames` ||<|2> Positive
and negative test.[[BR]]New  pc class required. ||
  || '''`invalid:`'''[[BR]] `SELECT select FROM ...` ||
- ||'''A14.6.13-1:''' The String version of Query represents all query elements using a single
string. The string contains the following structure: || `SELECT firstname INTO ...FullName
AS firstName,` `lastname INTO ...FullName AS lastName` `FROM company.FullTimeEmployee` `WHERE
salary > 1000` `& projects.contains(project)` `& project.budget > limit` `VARIABLES
Project project` `PARAMETERS BigDecimal limit` `ORDER BY salary` `GROUP BY firstname, lastname`
`HAVING lastname.startsWith('R')` `RANGE 1 TO 10` || `jdoql.keywords.`[[BR]]`SingleString`
|| Positive test.[[BR]]New result class required. ||
+ ||'''A14.6.13-1:''' The String version of Query represents all query elements using a single
string. The string contains the following structure: || `SELECT firstname AS firstName,` `lastname
AS lastName` `INTO ...FullName` `FROM company.FullTimeEmployee` `WHERE salary > 1000` `&
projects.contains(project)` `& project.budget > limit` `VARIABLES Project project`
`PARAMETERS BigDecimal limit` `ORDER BY salary` `GROUP BY firstname, lastname` `HAVING lastname.startsWith('R')`
`RANGE 1 TO 10` || `jdoql.keywords.`[[BR]]`SingleString` || Positive test.[[BR]]New result
class required. ||
  ||<|3> '''A14.6.13-2:''' Keywords, identified above in '''bold''', are either all
upper-case or all lower-case. Keywords cannot be mixed case. || '''`valid:`'''[[BR]] `SELECT
FROM company.Person` ||<|3> `jdoql.keywords.`[[BR]]`UppercaseLowercase` ||<|3>
Positive and negative test. ||
  || '''`valid:`'''[[BR]] `select from company.Person` ||
  || '''`invalid:`'''[[BR]] `SeLeCt FrOm company.Person` ||
@@ -166, +166 @@

  ||'''`invalid:`'''[[BR]]`SELECT noname FROM company.Person` ||
  || '''A14.6-17:''' `void setGrouping (String grouping);` Specify the grouping of results
for aggregates. || `SELECT lastname FROM company.Person GROUP BY lastname` || `api.`[[BR]]`SetGrouping`
|| Positive test. ||
  || '''A14.6-18:''' `void setUnique (boolean unique);` Specify that there is a single result
of the query. || `SELECT UNIQUE firstname` `FROM company.Person` `WHERE lastname == emp1Last'`
|| `api.`[[BR]]`SetUnique` || Positive test. ||
- || '''A14.6-19:''' `void setResultClass (Class resultClass);` Specify the class to be used
to return result instances. || `SELECT firstname INTO ...FullName, lastname INTO ...FullName`
`FROM company.Person` || `api.`[[BR]]`SetResultClass` || Positive test.[[BR]]New result class
required. ||
+ || '''A14.6-19:''' `void setResultClass (Class resultClass);` Specify the class to be used
to return result instances. || `SELECT firstname, lastname INTO ...FullName` `FROM company.Person`
|| `api.`[[BR]]`SetResultClass` || Positive test.[[BR]]New result class required. ||
  || '''A14.6-20:''' `setRange(int fromIncl, int toExcl);` Specify the number of instances
to skip over and the maximum number of result instances to return. || `SELECT FROM company.Person
RANGE 1 TO 10` || `api.`[[BR]]`SetRange` || Positive test. ||
  || '''A14.6-22:''' The `Unmodifiable` option, when set to `true`, disallows further modification
of the query, except for specifying the range and result class and `ignoreCache` option. ||
`SELECT FROM company.Person` || `api.`[[BR]]`UnmodifiableQuery` || Negative test. ||
- || '''A14.6-23:''' The single string query is first parsed to yield the result, result class,
filter, variable list, parameter list, import list, grouping, ordering, and range. Then, the
values specified in APIs `setResult`, `setResultClass`, `setFilter`, `declareVariables`, `declareParamters`,
`declareImports`, `setGrouping`, `setOrdering`, and `setRange` override the corresponding
settings from the single string query. || `SELECT firstname INTO ...FullName AS firstName,`
`lastname INTO ...FullName AS lastName` `FROM company.FullTimeEmployee` `WHERE salary >
1000` `& projects.contains(project)` `& project.budget > limit` `VARIABLES Project
project` `PARAMETERS BigDecimal limit` `ORDER BY salary` `GROUP BY firstname, lastname` `HAVING
lastname.startsWith('R')` `RANGE 1 TO 10` || `api.`[[BR]]`SingleStringQuery` || Positive test.[[BR]]New
result class required. ||
+ || '''A14.6-23:''' The single string query is first parsed to yield the result, result class,
filter, variable list, parameter list, import list, grouping, ordering, and range. Then, the
values specified in APIs `setResult`, `setResultClass`, `setFilter`, `declareVariables`, `declareParamters`,
`declareImports`, `setGrouping`, `setOrdering`, and `setRange` override the corresponding
settings from the single string query. || `SELECT firstname AS firstName,` `lastname AS lastName`
`INTO ...FullName` `FROM company.FullTimeEmployee` `WHERE salary > 1000` `& projects.contains(project)`
`& project.budget > limit` `VARIABLES Project project` `PARAMETERS BigDecimal limit`
`ORDER BY salary` `GROUP BY firstname, lastname` `HAVING lastname.startsWith('R')` `RANGE
1 TO 10` || `api.`[[BR]]`SingleStringQuery` || Positive test.[[BR]]New result class required.
||
  || '''A14.9-1:''' Some JDO vendors provide extensions to the query, and these extensions
must be set in the query instance prior to execution. || `SELECT FROM company.Person` || `api.`[[BR]]`QueryExtentions`
|| Positive test. ||
  
  [[Anchor(ResultHandling)]]
@@ -202, +202 @@

  ||<|3> '''A14.6.11-2:''' The default Unique setting is `true` for aggregate results
without a grouping expression, and `false` otherwise. || '''`true:`'''[[BR]]`SELECT COUNT(THIS)
FROM company.Person` ||<|3> `result.`[[BR]]`DefaultUnique` ||<|3> Positive test.
||
  || '''`false grouping:`'''[[BR]]`SELECT FROM company.Person` `GROUP BY lastname` ||
  || '''`false:`'''[[BR]]`SELECT FROM company.Person` ||
- || '''A14.6.12-1:''' The result class may be one of ... ... Portable result classes do not
invoke any persistence behavior during their no-args constructor or set methods. || `SELECT
firstname INTO ...FullName, lastname INTO ...FullName FROM company.Person` || `result.`[[BR]]`ResultClassRequirements`
|| Positive test.[[BR]]New result class required. ||
+ || '''A14.6.12-1:''' The result class may be one of ... ... Portable result classes do not
invoke any persistence behavior during their no-args constructor or set methods. || `SELECT
firstname, lastname INTO ...FullName FROM company.Person` || `result.`[[BR]]`ResultClassRequirements`
|| Positive test.[[BR]]New result class required. ||
  || '''A14.6.12-2:''' Table 6: Shape of Result (C is the candidate class) || `...` || `result.`[[BR]]`ShapeOfResult`
|| Positive test. ||
  
  [[Anchor(SQLQueries)]]
@@ -212, +212 @@

  ||'''A14.7-1:''' In this case, the factory method that takes the language string and Object
is used: `newQuery (String language, Object query)`. The language parameter is `javax.jdo.query.SQL`
and the query parameter is the SQL query string. || `SELECT * FROM company.Person` || `sql.`[[BR]]`NewQuery`
|| Positive test.  ||
  ||<|4> '''A14.7-2:''' The only methods that can be used are `setClass` to establish
the candidate class, `setUnique` to declare that there is only one result row, and `setResultClass`
to establish the result class. || '''`setClass:`'''[[BR]]`SELECT * FROM company.Person` ||<|4>
`sql.`[[BR]]`AllowedAPIMethods` ||<|4> Positive and negative test.[[BR]]New result class
required. ||
  || '''`setUnique:`'''[[BR]]`SELECT * FROM company.Company` ||
- || '''`setResultClass:`'''[[BR]]`SELECT firstname INTO ...FullName, lastname INTO ...FullName
FROM company.Person` ||
+ || '''`setResultClass:`'''[[BR]]`SELECT firstname, lastname INTO ...FullName FROM company.Person`
||
  || '''`invalid:`'''[[BR]]''`for all other query api methods`'' ||
  ||<|2> '''A14.7-3:''' SQL queries can be defined without a candidate class. These
queries can be found by name using the factory method `newNamedQuery`, specifying the class
as `null`, or can be constructed without a candidate class. || '''`named query:`'''[[BR]]`Select
* from company.Person` ||<|2> `sql.`[[BR]]`CandidateClass` ||<|2> Positive test.
||
  || '''`non-named query:`'''[[BR]]`Select * from company.Person` ||
@@ -225, +225 @@

  || '''A14.8-1:''' These methods delete the instances of affected classes that pass the filter,
and all dependent instances. Affected classes are the candidate class and its persistence-capable
subclasses. || `SELECT * FROM company.Person` || `delete.`[[BR]]`DeletePersistentAll` || Positive
test. ||
  || '''A14.8-2:''' The number of instances of affected classes that were deleted is returned.
Embedded instances and dependent instances are not counted in the return value. || `SELECT
* FROM company.Person` || `delete.`[[BR]]`NoOfDeletedInstances` || Positive test. ||
  ||<|6> '''A14.8-3:''' Query elements `filter`, `parameters`, `imports`, `variables`,
and `unique` are valid in queries used for delete. Elements `result`, `result class`, `range`,
`grouping`, and `ordering` are invalid. If any of these elements is set to its non-default
value when one of the `deletePersistentAll` methods is called, a `JDOUserException` is thrown
and no instances are deleted. || '''`valid:`'''[[BR]]`SELECT UNIQUE FROM company.FullTimeEmployee`
`WHERE salary > 1000` `& projects.contains(project)` `& project.budget > limit`
`VARIABLES Project project` `PARAMETERS BigDecimal limit` ||<|6> `delete.`[[BR]]`DeleteQueryElements`
||<|6> Positive and negative test.[[BR]]New result class required. ||
- || '''`invalid result:`'''[[BR]]`SELECT firstname INTO ...FullName AS firstName` `FROM company.FullTimeEmployee`
||
+ || '''`invalid result:`'''[[BR]]`SELECT firstname AS firstName INTO ...FullName` `FROM company.FullTimeEmployee`
||
  || '''`invalid order by:`'''[[BR]]`SELECT FROM company.FullTimeEmployee` `ORDER BY salary`
||
  || '''`invalid group by:`'''[[BR]]`SELECT FROM company.FullTimeEmployee` `GROUP BY lastname`
||
  || '''`invalid having:`'''[[BR]]`SELECT FROM company.FullTimeEmployee` `GROUP BY lastname`
`HAVING lastname.startsWith('R')` ||

Mime
View raw message