commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject cvs commit: jakarta-commons/beanutils/src/java/org/apache/commons/beanutils ResultSetDynaClass.java
Date Mon, 15 Jul 2002 15:40:37 GMT
craigmcc    2002/07/15 08:40:37

  Modified:    beanutils/src/java/org/apache/commons/beanutils
                        ResultSetDynaClass.java
  Log:
  Update usage documentation to note the restrictions that are due to the fact
  that the DynaBeans returned by iterator() are mapped directly to the current
  row of the result set.  If you want to use the data outside the context of
  what is supported, you need to copy it, so document one way to "clone" the
  data with standard BasicDynaBean beans.
  
  Revision  Changes    Path
  1.2       +38 -4     jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/ResultSetDynaClass.java
  
  Index: ResultSetDynaClass.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/ResultSetDynaClass.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ResultSetDynaClass.java	12 Jul 2002 22:38:21 -0000	1.1
  +++ ResultSetDynaClass.java	15 Jul 2002 15:40:37 -0000	1.2
  @@ -90,6 +90,40 @@
    * property of the corresponding name (forced to lower case for portability).
    * </p>
    *
  + * <p><strong>WARNING</strong> - Any {@link DynaBean} instance returned
by
  + * this class, or from the <code>Iterator</code> returned by the
  + * <code>iterator()</code> method, is directly linked to the row that the
  + * underlying result set is currently positioned at.  This has the following
  + * implications:</p>
  + * <ul>
  + * <li>Once you retrieve a different {@link DynaBean} instance, you should
  + *     no longer use any previous instance.</li>
  + * <li>Changing the position of the underlying result set will change the
  + *     data that the {@link DynaBean} references.</li>
  + * <li>Once the underlying result set is closed, the {@link DynaBean}
  + *     instance may no longer be used.</li>
  + * </ul>
  + *
  + * <p>Any database data that you wish to utilize outside the context of the
  + * current row of an open result set must be copied.  For example, you could
  + * use the following code to create standalone copies of the information in
  + * a result set:</p>
  + * <pre>
  + *   ArrayList results = new ArrayList(); // To hold copied list
  + *   ResultSetDynaClass rsdc = ...;
  + *   DynaProperty properties[] = rsdc.getDynaProperties();
  + *   BasicDynaClass bdc =
  + *     new BasicDynaClass("foo", BasicDynaBean.class,
  + *                        rsdc.getDynaProperties());
  + *   Iterator rows = rsdc.iterator();
  + *   while (rsdc.hasNext()) {
  + *     DynaBean oldRow = (DynaBean) rows.iterator();
  + *     DynaBean newRow = bdc.newInstance();
  + *     PropertyUtils.copyProperties(newRow, oldRow);
  + *     results.add(newRow);
  + *   }
  + * </pre>
  + *
    * @author Craig R. McClanahan
    * @version $Revision$ $Date$
    */
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message