NutzCN Logo
问答 自定义sql 如何返回list <Map> 的数据
发布于 2393天前 作者 yy321973351 3390 次浏览 复制 上一个帖子 下一个帖子
标签:
[DEBUG] 10:35:24.956 org.nutz.dao.impl.interceptor.DaoTimeInterceptor.filter(DaoTimeInterceptor.java:28) - time=494ms, sql=INSERT INTO results(sid,cid,score) VALUES(1,1,80) 
[DEBUG] 10:35:24.957 org.nutz.ioc.impl.ScopeContext.remove(ScopeContext.java:85) - Remove object 'mainLauncher' from [app] 
[ERROR] 10:35:24.957 org.nutz.boot.NbApp.execute(NbApp.java:218) - something happen!!
org.nutz.ioc.IocException: IocBean[mainLauncher] throw Exception when creating
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:152)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:241)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:271)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:161)
	at org.nutz.boot.NbApp.execute(NbApp.java:208)
	at org.nutz.boot.NbApp.run(NbApp.java:177)
	at io.nutz.demo.MainLauncher.main(MainLauncher.java:62)
Caused by: org.nutz.dao.DaoException: Need non-arg constructor : interface java.util.Map
	at org.nutz.dao.impl.entity.NutEntity.<init>(NutEntity.java:190)
	at org.nutz.dao.impl.entity.AnnotationEntityMaker._createNutEntity(AnnotationEntityMaker.java:623)
	at org.nutz.dao.impl.entity.AnnotationEntityMaker.make(AnnotationEntityMaker.java:90)
	at org.nutz.dao.impl.EntityHolder.getEntity(EntityHolder.java:72)
	at org.nutz.dao.impl.NutDao.getEntity(NutDao.java:683)
	at io.nutz.demo.MainLauncher.init(MainLauncher.java:51)
	at io.nutz.demo.MainLauncher$FM$init$cff301be46c87e2fbea60f4ef344bacb.invoke(MainLauncher.java)
	at org.nutz.ioc.impl.ObjectMakerImpl$2.trigger(ObjectMakerImpl.java:180)
	at org.nutz.ioc.weaver.DefaultWeaver.onCreate(DefaultWeaver.java:89)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:141)
	... 6 more
/*1. 查询" 01 "课程比" 02 "课程成绩高的学生的信息及课程分数*/
/* select.01 */

select * from  (select * from  results  where cid=1) as r  inner join (select * from  results  where cid=2) as r1 on
r.score>r1.score and r.sid=r1.sid left join student as s on s.id =r.sid

如何将查询结果返回一个list<Map<String.String>> 的数据

2 回复

现在只能做到

[DEBUG] 10:45:24.133 org.nutz.dao.impl.interceptor.DaoTimeInterceptor.filter(DaoTimeInterceptor.java:28) - time=6ms, sql=select * from  (select * from  results  where cid=1) as r  inner join (select * from  results  where cid=2) as r1 on
r.score>r1.score and r.sid=r1.sid left join student as s on s.id =r.sid
[{
   "id": 2,
   "sid": 2,
   "cid": 2,
   "score": 60,
   "sname": "钱电",
   "age": "1990-12-21 00:00:00",
   "sex": "男"
}, {
   "id": 4,
   "sid": 4,
   "cid": 2,
   "score": 30,
   "sname": "李云",
   "age": "1990-08-06 00:00:00",
   "sex": "男"
}]

sql语句查询结果

id    sid   cid   score id   sid  cid     score  id  sname  age                               sex
4	2	1	70	5	2	2	60	  2	钱电	    1990-12-21 00:00:00	男
10	4	1	50	11	4	2	30	  4	李云	   1990-08-06 00:00:00	男

Sqls.callback.maps()回调就可以啦

添加回复
请先登陆
回到顶部