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 Fri, 23 Sep 2005 15:28:05 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

------------------------------------------------------------------------------
  == SQL Queries ==
  
  || '''Assertion''' || '''JDOQL''' || '''Testclass''' || '''Comment''' ||
- ||'''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.  ||
+ ||'''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 PERSONID FROM persons` || `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. ||
+ ||<|5> '''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 PERSONID FROM persons` ||<|5>
`sql.`[[BR]]`AllowedAPIMethods` ||<|5> Positive and negative test.[[BR]]New result class
required. ||
- || '''`setUnique:`'''[[BR]]`SELECT * FROM company.Company` ||
- || '''`setResultClass:`'''[[BR]]`SELECT firstname, lastname INTO ...FullName FROM company.Person`
||
+ || '''`setUnique(true):`'''[[BR]]`SELECT PERSONID FROM persons` `WHERE FIRSTNAME = 'emp1First'`
||
+ || '''`setResultClass(...FullName):`'''[[BR]]`SELECT FIRSTNAME AS firstName,` `lastname
AS lastName` `FROM persons` ||
  || '''`invalid:`'''[[BR]]''`for all other query api methods`'' ||
+ || '''`parameter binding:`'''[[BR]]`SELECT PERSONID FROM persons` `WHERE FIRSTNAME = ?`
||
- ||<|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.
||
+ ||<|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
PERSONID FROM persons` ||<|2> `sql.`[[BR]]`CandidateClass` ||<|2> Positive test.[[BR]]Add
JDO metadata for named SQL queries. ||
- || '''`non-named query:`'''[[BR]]`Select * from company.Person` ||
+ || '''`non-named query:`'''[[BR]]`SELECT PERSONID from persons` ||
- || '''A14.7-4:''' Table 7: Shape of Result of SQL Query || `...` || `sql.`[[BR]]`ShapeOfResult`
|| Positive test. ||
+ ||<|12> '''A14.7-4:''' Table 7: Shape of Result of SQL Query || '''`valid, candidate
class, unique is false:`'''[[BR]]`SELECT PERSONID FROM persons` ||<|12> `sql.`[[BR]]`ShapeOfResult`
||<|12> Positive test and negative test. ||
+ || '''`valid, candidate class, unique is true:`'''[[BR]]`SELECT PERSONID FROM persons` `WHERE
FIRSTNAME = 'emp1First'` ||
+ || '''`invalid, candidate class, unique is true:`'''[[BR]]`SELECT PERSONID FROM persons`
||
+ || '''`valid, single column, unique is false:`'''[[BR]]`SELECT FIRSTNAME FROM persons` ||
+ || '''`valid, multiple columns, unique is false:`'''[[BR]]`SELECT FIRSTNAME, LASTNAME FROM
persons` ||
+ || '''`valid, multiple columns, unique is true:`'''[[BR]]`SELECT FIRSTNAME, LASTNAME FROM
persons` `WHERE FIRSTNAME = 'emp1First'` ||
+ || '''`valid, candidate class, result class,` `unique is false:`'''[[BR]]`SELECT FIRSTNAME
AS firstName,` `LASTNAME AS lastName` `FROM persons` ||
+ || '''`valid, candidate class, result class,` `unique is true:`'''[[BR]]`SELECT FIRSTNAME
AS firstName,` `LASTNAME AS lastName` `FROM persons` `WHERE FIRSTNAME = 'emp1First'` ||
+ || '''`valid, result class,` `unique is false:`'''[[BR]]`SELECT FIRSTNAME AS firstName,`
`LASTNAME AS lastName` `FROM persons` ||
+ || '''`valid, result class,` `unique is true:`'''[[BR]]`SELECT FIRSTNAME AS firstName,`
`LASTNAME AS lastName` `FROM persons` `WHERE FIRSTNAME = 'emp1First'` ||
+ || '''`valid, result class (binding using put method),` `unique is false:`'''[[BR]]`SELECT
FIRSTNAME, LASTNAME FROM persons` ||
+ || '''`valid, result class (binding using put method),` `unique is true:`'''[[BR]]`SELECT
FIRSTNAME, LASTNAME FROM persons` `WHERE FIRSTNAME = 'emp1First'` ||
+ 
  
  [[Anchor(DeletionByQuery)]]
  == Deletion by Query ==

Mime
View raw message