select u.name,p.name
from user u left join passenger p on p.user_id = u.id
会出现前一列覆盖后一列的情况
如果
select u.name uname,p.name pname
from user u left join passenger p on p.user_id = u.id
在数据库中查询正确,hibernate查询会报
WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: 1052, SQLState: 23000>
ERROR [org.hibernate.util.JDBCExceptionReporter] - <Column 'name' in field list is ambiguous>
请高手指点。谢谢!
------解决方案--------------------
ambiguous模棱两可的,不知道对应哪个表的name列。改为
select u.name as uname,p.name as pname
from user u left join passenger p on p.user_id = u.id
------解决方案--------------------
Column 'name' not found
错误类型又不一样了。