dgraham     2004/12/18 17:15:33

  Modified:    dbutils/xdocs examples.xml
  Log:
  Added tips for mapping strange column names to bean properties.
  PR: 32414
  
  Revision  Changes    Path
  1.7       +20 -0     jakarta-commons/dbutils/xdocs/examples.xml
  
  Index: examples.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbutils/xdocs/examples.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- examples.xml      19 Mar 2004 00:25:39 -0000      1.6
  +++ examples.xml      19 Dec 2004 01:15:33 -0000      1.7
  @@ -149,6 +149,26 @@
   your application.  The provided implementation delegates datatype conversion 
to 
   the JDBC driver.
   </p>
  +<p>
  +BeanProcessor maps columns to bean properties as documented in the 
  +<a 
href="apidocs/org/apache/commons/dbutils/BeanProcessor.html#toBean(java.sql.ResultSet,%20java.lang.Class)">BeanProcessor.toBean()</a>
 javadoc.  
  +Column names must match the bean's property names case insensitively.  
  +For example, the <code>firstname</code> column would be stored in the bean 
  +by calling its <code>setFirstName()</code> method.  However, many database 
  +column names include characters that either can't be used or are not 
typically 
  +used in Java method names.  You can do one of the following to map 
  +these columns to bean properties:
  +<ol>
  +    <li>
  +        Alias the column names in the SQL so they match the Java names:  
  +        <code>select social_sec# as socialSecurityNumber from person</code>
  +    </li>
  +    <li>
  +        Subclass BeanProcessor and override the <a 
href="apidocs/org/apache/commons/dbutils/BeanProcessor.html#mapColumnsToProperties(java.sql.ResultSetMetaData,%20java.beans.PropertyDescriptor[])">mapColumnsToProperties()</a>
 
  +        method to strip out the offending characters.
  +    </li>
  +</ol>
  +</p>
   </section>
   
   </body>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to