在使用dao.fetch(tableName, cnd)进行联表查询后 返回的record里面相同key的值会覆盖,有在不改表的情况下解决这个问题的办法么?
12 回复
@wendal 兽总我看新的1.r.60API中有个
Record fetch(java.lang.String tableName,
Condition cnd,
java.lang.String fields)
参数:
tableName - 表名
cnd - 条件
fields - 需要select的属性, 不可以是null!!!
返回:
Record 对象
这个里面的fields我按照 数据库 select后面
t_fraction.userId AS q,
t_fraction.teacherId AS t,
t_fraction.curriculumId AS `asc`,
t_fraction.fraction AS f
这样的字符串方式添加参数,但是返回的还是不行,是我用错方式了还是什么啊?
OK
Record record = dao
.fetch("t_fraction f left join t_user u on f.userId = u.id left join t_teacher on f.teacherId = t_teacher.id",
Cnd.where("u.id", "=", userId), "f.id AS fid,u.name AS name,u.id AS uid");
上面这个数据库访问的代码,下面的是日志和返回的数据我转json输出的
2017-3-21 11:15:36.232 DEBUG [http-bio-8080-exec-9] SELECT * FROM t_fraction f left join t_user u on f.userId = u.id left join t_teacher on f.teacherId = t_teacher.id WHERE u.id=? LIMIT 0, 1
| 1 |
|---|
| 1 |
For example:> "SELECT * FROM t_fraction f left join t_user u on f.userId = u.id left join t_teacher on f.teacherId = t_teacher.id WHERE u.id=1 LIMIT 0, 1 "
{
"id": 1,
"userid": 1,
"teacherid": 1,
"curriculumid": 1,
"fraction": 90.0000000000,
"name": "王同学",
"passwd": "123456",
"salt": "1",
"ct": "2017-03-07 16:55:56",
"ut": "2017-03-21 11:15:33",
"t_name": "张三",
"addr": "家",
"age": 50
}
@wendal 会不会是 版本问题啊,我看你更新有fildes这个接口是26天之前,而下我的 jar是 1月15号的哪个 1.r.60的
添加回复
请先登陆