Fetch the repository succeeded.
功能描述如下:
Object[] qry=
[
"select * from users where age>?", par(10),
[key("order"), //key可任意取名
"select * from orders where price>0 ",
"and userId in ", pid("id")," order by id", pagin(1, 10),
[key("comments "),
"select * from comments where star>=5 and orderId in ", pid("id")
]
],
[key("address"),
"select * from addresses",
" where userId in ", pid("id"),
]
];
实际执行SQL:
select * from users where age>10 // 返回user的id=1, 3, 5, 9
select * from orders where price>0 and userId in (1, 3, 5, 9) order by id limit 1, 10
select * from comments where sar>=5 and orderId in (2,4,6)
select * from addresses where userId in (1, 3, 5, 9)
内部根据主从ID值生成对象树并返回List<Map>结构的对象,如json化后则为:
[
{
"id":"u1",
"name":"user1",
"order":[
{
"id":"o1",
"name":"order1",
"userId":"u1",
"comments":[{}, {}]
},
{
"id":"o2",
"name":"order1",
"userId":"u2",
"comments":[{}, {}]
}
],
"address":[
{
"id":"a1",
"name":"address1",
"userId":"u1"
}
]
},
{
"id":"u2",
"name":"user2",
"order":[
{
"id":"o3",
"name":"user2",
"userId":"u2",
"comments":[{}, {}]
},
{
"id":"o4",
"name":"order2",
"userId":"u2",
"comments":[{}, {}]
}
],
"address":[
{
"id":"a2",
"name":"address2",
"userId":"u2"
}
]
}
]