spring orm
public int add(T entity){
SqlParameterSource param = new BeanPropertySqlParameterSource(entity);
if(insertActor.getTableName()==null){
insertActor.setTableName(table);
}
return insertActor.execute(param);
}
public T getById(int id){
String sql = "select * from "+table+" where id = ?";
logger.info("{}",sql);
RowMapper<T> mapper = (RowMapper<T>) ParameterizedBeanPropertyRowMapper.newInstance(entityClass);
return 易做图JdbcTemplate.queryForObject(sql, mapper, id);
}
作者“liuguxing”
补充:软件开发 , Java ,