//查询表的库存宠物
public List<Pet> se1() throws Exception {
List<Pet> list=new ArrayList<Pet>();
String sql="SELECT pet.id,pet.typeName,pet.`name`,account.price FROM pet inner join account on pet.id = account.pet_id and pet.store_id is not null";
//String sql="SELECT pet.id,pet.typeName,pet.`name`,account.price FROM pet inner join account on pet.id = account.pet_id and pet.store_id is not null";
ResultSet rs=this.executeQuery(sql);
if(rs!=null){
while(rs.next()){
Pet owner=new Pet();
owner.setId(rs.getInt("id"));
owner.setName(rs.getString("name"));
owner.setTypename(rs.getString("typeName"));
int int1=rs.getInt("price");
Account account = new Account();
account.setPrice(int1);
owner.setAccount(account);
list.add(owner);
}
}
return list;
}
对象实体类的多表联合的使用
最新推荐文章于 2022-10-20 10:42:26 发布