1,javabean as follows:
public class User {
/**
* User Unique identification (ID)
*/
Private String uid;
/**
* Username (user's mobile phone number)
*/
Private String phone;
/**
* Get user Unique identification (ID)
*
* @return User Unique identification (ID)
*/
Public String Getuid () {
return UID;
}
/**
* Get username (user's mobile phone number)
*
* @return Username (user's mobile phone number)
*/
Public String Getphone () {
return phone;
}
/**
* Set username (user's mobile phone number)
*
* @param phone
* Username (user's mobile phone number)
*/
public void Setphone (String phone) {
This.phone = phone;
}
}
2, the query record is as follows:
String sql = "SELECT * from user where phone =?";
Queryrunner runner= New Queryrunner (Daoutils.getsource ());
@SuppressWarnings ("Rawtypes")
User query = (user) runner.query (SQL, New Beanhandler (User.class), phone);
You will find that the result of the query UID is null,phone value.
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Reason:
The UID field does not have a set method, so there is no value assigned. Thus the dbutils is assigned by the Set method reflection.
Workaround:
The set method of adding UID in JavaBean.
Java Dbutils cannot assign a value to a partial field when querying a database