Index: examples.xml =================================================================== RCS file: /home/cvspublic/jakarta-commons/dbutils/xdocs/examples.xml,v retrieving revision 1.6 diff -u -r1.6 examples.xml --- examples.xml 19 Mar 2004 00:25:39 -0000 1.6 +++ examples.xml 27 Nov 2004 20:22:43 -0000 @@ -149,6 +149,39 @@ your application. The provided implementation delegates datatype conversion to the JDBC driver.
+ +Using the BeanHandler potentially adds a new requirement - it +requires that the names of the column in the database match the +property names defined of the JavaBean. In the above example, that +means that if the columns in the database table "Person" were +"PERSON_ID", "NAME", "FIRST_NAME", and "LAST_NAME", then the +properties of the JavaBean Person.java must be "person_id", +"name", "first_name", and "last_name". (Note that the case does +not have to match.) Such a situation is a real world reality in +that many DBAs, er, encourage a naming schema that contains +only capital letters and where each word is separated by the +underscore character.
+ +There are at least three potential solutions to this issue: +
AS SQL keywordThe first two options presented are usually not feasible. The
+third option has you change the SQL statement. So, given a JavaBean
+with properties "person_id", "name", "first_name", and "last_name",
+the SELECT statement would need to be changed to SELECT
+PERSON_ID AS personId, NAME, FIRST_NAME AS firstName, LAST_NAME
+AS lastName FROM Person WHERE name=?. (Note that the AS
+keyword is not used with the column named NAME since it matches the
+JavaBean property name.)
A fourth option, as mentioned above, would involve implementing
+a customized RowProcessor