November 12, 2008 (Wednesday) 20:26 Author: Sweet Potato Mood: general
Today, while writing a program, I found a problem with dbutils, since dbutils requires that the column name and the object's property name must be consistent in the mapping of the table to the object, such as the column name is UserID, the property name must also be userid, but many times, when we write the class, I would like to change the name of the property, such as user instead of UserID, when we write SQL statements like this:
SELECT userid as user from osc_users
Then you will find that you can't read the value of the UserID field at all, find the source code of the dbutils and find that it uses getColumnName to get the column name of the table, and this method is not valid for the SQL statement to modify the column name through as. There is one way to do this in the JDK documentation: Getcolumnlabel, which is described in the JDK documentation as follows:
Gets the designated column ' s suggested title for use in printouts and displays. The suggested title is usually specified by the SQL as clause. If a SQL as is isn't specified, the value returned from Getcolumnlabel'll be the Mahouve as the value returned by the Getcolu Mnname method.
So we need to change all the places in the Dbutils to getColumnName to Getcolumnlabel.
I have modified and packaged, download the address is: http://www.oschina.net/project/284
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.