package dao;
import java.util.List;
import javabeans.Bproduct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.stereotype.Repository;
@Repository
public class Basedao{
@Autowired
protected SimpleJdbcTemplate simpleJdbcTemplate;
@Qualifier("simpleJdbcTemplate")
public void setSimpleJdbcTemplate(SimpleJdbcTemplate simpleJdbcTemplate) {
this.simpleJdbcTemplate = simpleJdbcTemplate;
}
public List findAll(){
List list=null;
String sql="select * from b_product";
list=simpleJdbcTemplate.getJdbcOperations().query(sql,new BeanPropertyRowMapper(Bproduct.class));
System.out.println(list.size());
return list;
}
}
评论15
最新资源