package com.elvish.oda.busin.pojo;
import java.util.Date;
import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Id;
import org.nutz.dao.entity.annotation.Table;
import org.nutz.json.Json;
@Table("t_user")
public class User {
@Id
private Integer id;
@Column
private String username;
@Column
private String password;
@Column
private String name;
@Column("login_time")
private Date loginTime;
@Column
private Integer delflag;
@Column
private Integer status;
@Column
private String remark;
@Column("create_time")
private Date createTime;
@Column("update_time")
private Date updateTime;
@Column("create_user")
private Date createUser;
@Column("update_user")
private Date updateUser;
private String roleName;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getLoginTime() {
return loginTime;
}
public void setLoginTime(Date loginTime) {
this.loginTime = loginTime;
}
public Integer getDelflag() {
return delflag;
}
public void setDelflag(Integer delflag) {
this.delflag = delflag;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Date getCreateUser() {
return createUser;
}
public void setCreateUser(Date createUser) {
this.createUser = createUser;
}
public Date getUpdateUser() {
return updateUser;
}
public void setUpdateUser(Date updateUser) {
this.updateUser = updateUser;
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
@Override
public String toString() {
return Json.toJson(this);
}
}
public List<User> findAllUserRole() {
String querySql = "SELECT t1.*, t2.role_name roleName FROM t_user_role t0 LEFT JOIN t_user t1 ON t0.user_id = t1.id LEFT JOIN t_role t2 ON t0.role_id = t2.id";
Sql sql = Sqls.fetchString(querySql);
return NutzSqlUtil.getEntities(sql, dao, User.class);
}
public static <T> List<T> getEntities(Sql sql, Dao dao, Class<T> clz) {
sql.setCallback(Sqls.callback.entities());
sql.setEntity(dao.getEntity(clz));
dao.execute(sql);
return sql.getList(clz);
}
sql
SELECT
t1.*, t2.role_name roleName
FROM
t_user_role t0
LEFT JOIN t_user t1 ON t0.user_id = t1.id
LEFT JOIN t_role t2 ON t0.role_id = t2.id
进行数据库查询,想带出非User表中的roleName信息。
我在User实体中定义了roleName属性,settter/getter。
问题
执行dao操作后,User中roleName不能被赋值? why??