In the
Type-safe querying and results code that you show, you never describe how the actual binding happens.
How does the system decide that when it runs the query defined in the annotation that it is going to create a DataSet of
User objects? How does it know that each row of the query is going to be mapped into a User object and what fields on the database are to be mapped to each field on the object?
The fields may be associated by naming convention, but there seems to be something missing from the example that binds the User object to the user table.
interface MyQueries extends BaseQuery {
@Query(sql="select * from user")
DataSet getAllUsers();
}
.
.
.
Connection c = myDataSource.getConnection();
MyQueries myQueries = c.createQueryObject(MyQuery.class);
DataSet users = myQueries.getAllUsers();
for (User u: users) {
System.out.println("User's name is: " + user.name;
}