不知道怎么插入图片,只能用语言描述了。
我用query方法,条件是1=1,返回的数据集合其他字段都没有问题,但是在主键那一列的数值都是0(我的主键生成方式是自增)。
然后我从数据查询的时候是没问题的,这是为什么呢?
8 回复
@IocBean(fields = "dao", name = "resourceService")
public class ResourceService extends IdNameEntityService<Resource>{
//查询所有菜单资源
public List<Resource> findAllResouce(){
List<Resource> lists = this.dao().query(Resource.class, Cnd.where("1", "=", "1").orderBy("resourceid", "asc"));
return lists;
}
public void addData(){
Resource resource = new Resource();
resource.setResourceName("添加单位");//菜单名称
resource.setUrl("");//URL
resource.setDescription("sys.manager.unit.add");//权限标识
resource.setSubtype(1);//0是菜单,1是数据按钮
resource.setState(1);//0是禁用,1是启用
resource.setParentId(2);//设置父级菜单
this.dao().insert(resource);
}
}
@Table("t_resource")
public class Resource {
@Id
private int resouceId;
@Name
private String resourceName;
@Column("url")
private String url;
@Column("description")
private String description;//权限标识
@Column("state")
private int state;//是否启用
@Column("subtype")
private int subtype;//权限类型
@Column("parentid")
private int parentId;//上级菜单
public int getResouceId() {
return resouceId;
}
public void setResouceId(int resouceId) {
this.resouceId = resouceId;
}
public String getResourceName() {
return resourceName;
}
public void setResourceName(String resourceName) {
this.resourceName = resourceName;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public int getSubtype() {
return subtype;
}
public void setSubtype(int subtype) {
this.subtype = subtype;
}
public int getParentId() {
return parentId;
}
public void setParentId(int parentId) {
this.parentId = parentId;
}
添加回复
请先登陆