db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: db-ojb/src/doc/forrest/src/documentation/content/xdocs/docu/guides query.xml
Date Sat, 09 Apr 2005 13:21:19 GMT
brj         2005/04/09 06:21:19

  Modified:    src/doc/forrest/src/documentation/content/xdocs/docu/guides
                        query.xml
  Log:
  short description of ReportQuery#setJdbcTypes
  
  Revision  Changes    Path
  1.5       +33 -9     db-ojb/src/doc/forrest/src/documentation/content/xdocs/docu/guides/query.xml
  
  Index: query.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/doc/forrest/src/documentation/content/xdocs/docu/guides/query.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- query.xml	9 Apr 2005 12:52:25 -0000	1.4
  +++ query.xml	9 Apr 2005 13:21:19 -0000	1.5
  @@ -188,9 +188,9 @@
                           Instead of using the primary keys of an object as a selection criterion,
<strong>addEqualToIdentity</strong>
                           supports the whole Identity. This feature leads to more readable
queries and is useful, when the object has multiple pk.
                       </p>
  -                    <p>    
  +                    <p>
                           The following sample looks for projects of a given person. When
querying for simple attributes we would use
  -                        crit.addEqualTo("persons.id", personId); where id is the primary
key of person. 
  +                        crit.addEqualTo("persons.id", personId); where id is the primary
key of person.
                           Criteria#addEqualToIdentity accepts the whole Identity and translates
it into an addEqualTo() for each primary key.
                       </p>
                           <source><![CDATA[
  @@ -666,8 +666,7 @@
                   Report queries are used to retrieve row data, not 'real' business objects.
A row is an array of Object.
                   With these queries you can define what attributes of an object you want
to have in the row.
                   The attribute names may also contain path expressions like 'owner.address.street'.
  -                To define the attributes use ReportQuery
  -                <strong>#setAttributes(String[] attributes)</strong>.
  +                To define the attributes use ReportQuery#<strong>setAttributes(String[]
attributes)</strong>.
                   </p>
                   <p>
                   The following ReportQuery retrieves the name of the ProductGroup, the name
of the Article etc. for all
  @@ -687,15 +686,40 @@
                   Object[4] ([String, Integer, String, Double]).
                   </p>
   
  +            	<section>
  +                	<title>Defining the type of the returned data</title>
  +                	<p>
  +                	In the above example the ReportQuery returned a Collection of [String,
Integer, String, Double]. The types of the returned
  +                	data are defined by the Metadata of the underlying Resultset. OJB lets
you control the type of the returned data of ReportQueries
  +                	with the method ReportQuery#<strong>setJdbcTypes</strong>(int[]
jdbcTypes). 
  +                	SetJdbcTypes expects a type for each selected attributes. 
  +                	</p>
  +				<source><![CDATA[
  +int types[] = new int[]{Types.DECIMAL, Types.VARCHAR, Types.BIGINT};
  +Criteria crit = new Criteria();
  +crit.addLike("firstname", "%o%");
  +
  +ReportQueryByCriteria q = ojb.getQueryFactory().newReportQuery(Person.class, crit);
  +q.setAttributes(new String[]{"id", "firstname", "count(*)"});
  +q.setJdbcTypes(types);
  +
  +Iterator iter = broker.getReportQueryIteratorByQuery(q);
  +]]></source>
  +
  +            	</section>
  +
                   <section>
   	                <title>Limitations of Report Queries</title>
   					<p>
  -    	            ReportQueries currently only support simple arithmetic expressions (ie.
price * 1.05).
  -    	            Expressions based on multiple attributes (ie. price - bonus) do not work.
  +    	            ReportQueries (OJB 1.0.x) only support simple arithmetic expressions (ie.
price * 1.05).
  +    	            In OJB 1.1 the support for expressions based on multiple attributes (ie.
price - bonus) has been extended,
  +    	            but they only work when all attributes belong to the same class. 
  +    	            This limitation applies to all QueryByCriteria.
       	            </p>
   					<p>
  -    	            ReportQueries should not be used with columns referencing classes with
extents. Assume we want to select all ProductGroups
  -    	            and summarize the amount and prize of items in stock per group. The class
Article referenced by <strong>allArticlesInGroup</strong>						 has the extents
Books and CDs.
  +    	            ReportQueries are <strong>not extent aware</strong> and should
therefore not be used with columns referencing classes with extents. 
  +    	            Assume we want to select all ProductGroups and summarize the amount and
prize of items in stock per group. 
  +    	            The class Article referenced by <strong>allArticlesInGroup</strong>has
the extents Books and CDs.
       	            </p>
                   <source><![CDATA[
   Criteria crit = new Criteria();
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message