ibatis和java中如何处理多个表的sql映射
我正在尝试将 Ibatis 与 GWT 结合使用,我有这样的场景,我有数据库表机场、航站楼和航班。一个机场可以有不同的航站楼。一个航站楼可以有一个机场和多个航班。一个航班可以有一个航站楼。所以表结构看起来像这样。
飞机场 -ID -姓名 -terminal_id
终端 -ID -姓名 -flight_id
航班 -ID -航空公司 -terminal_id
我的 select 语句如下所示
SELECT airport.name AS Airport,
terminals.name AS Terminal,
flights.airline,
FROM airport,
terminals,
flights
WHERE airport.terminal_id = terminals.id
AND terminals.flight_id = flights.id;
获得此结果的 sql 映射将是什么样子。我感到困惑的是结果集是表的组合,因此结果集不是三个表中任何一个的模型对象。
I am trying to use Ibatis with GWT and I have this scenario, I have databases tables Airport, Terminals and Flights. An airport can have different terminals. A terminal can have one Airport and many flights. And a flight can have one terminal. So the table structure looks like this.
Airport
-id
-name
-terminal_id
Terminals
-id
-name
-flight_id
Flights
-id
-airline
-terminal_id
My select statement looks like this
SELECT airport.name AS Airport,
terminals.name AS Terminal,
flights.airline,
FROM airport,
terminals,
flights
WHERE airport.terminal_id = terminals.id
AND terminals.flight_id = flights.id;
What will the sql maps look like to get this result. Where I'm getting confused is the result set is a combination of tables and so the result set isn't a model object of either of the three tables.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建一个自定义值对象(vo)以满足您的需要。
Create a custom value object(vo) to suit your need.