3.7将JDBC操作建模为Java对象
3.7.1 了解SqlQuery
3.7.2 使用MappingSqlQuery
public class ActorMappingQuery extends MappingSqlQuery<Actor> {
public ActorMappingQuery(DataSource ds) {
super(ds, "select id, first_name, last_name from t_actor where id = ?");
declareParameter(new SqlParameter("id", Types.INTEGER));
compile();
}
@Override
protected Actor mapRow(ResultSet rs, int rowNumber) throws SQLException {
Actor actor = new Actor();
actor.setId(rs.getLong("id"));
actor.setFirstName(rs.getString("first_name"));
actor.setLastName(rs.getString("last_name"));
return actor;
}
}3.7.3 使用SqlUpdate
3.7.4 使用StoredProcedure
最后更新于
这有帮助吗?