首页 > 代码库 > 关于datagrid查询时,封装了pojo对象,该对象必须要有一个带参数的构造器,否则会报错Unable to locate appropriate constructor on class
关于datagrid查询时,封装了pojo对象,该对象必须要有一个带参数的构造器,否则会报错Unable to locate appropriate constructor on class
----------------------------------------------------------
实体类中
public CategoryBeanPojo(Integer id, String type, Boolean hot, String login,
String name, String pass, Integer aid) {
super();
this.id = id;
this.type = type;
this.hot = hot;
this.login = login;
this.name = name;
this.pass = pass;
this.aid = aid;
}
--------------------------------------------------------------------------
dao中
public List<CategoryBeanPojo> queryJoinAccount(CategoryBeanPojo category,
PageBean pageBean) throws Exception{
// TODO Auto-generated method stub
StringBuffer sub=new StringBuffer();
//sub.append("select ");
sub.append("select new cn.it.shop.pojo.CategoryBeanPojo(c.id as id,");
sub.append("c.type as type,");
sub.append("c.hot as hot,");
sub.append("(select a.login from Account as a where a.id=c.aid ) as login,");
sub.append("(select a.name from Account as a where c.aid=a.id) as name, ");
sub.append("(select a.pass from Account as a where c.aid=a.id) as pass,");
sub.append("c.aid ");
sub.append(" ) from Category as c where 1=1");
sub.append(" and c.type like ‘%");
if (category.getType()!=null) {
sub.append(category.getType());
}
sub.append("%‘");
System.out.println(sub.toString());
return pageQuery(sub.toString(), pageBean);
}
关于datagrid查询时,封装了pojo对象,该对象必须要有一个带参数的构造器,否则会报错Unable to locate appropriate constructor on class