最近遇到了Hibernate中SqlQuery查询的时候列名重复的问题。在网上找了一些方法,结果看似很高深的样子。其实解决起来很简单。
比如:session.select t.password,t.isstop,t.username,r.role_mc,d.dptname,t.id,r.isstop as IdSS,d.isstop as IDS from dsn_user t left join dsn_role r on t.role_id = r.role_id left join dsn_dpt d on t.iddpt = d.iddpt where t.logincode = 'aa'
只需要给r.isstop as IdSS,d.isstop as IDS加上别名即可。
比如:session.select t.password,t.isstop,t.username,r.role_mc,d.dptname,t.id,r.isstop as IdSS,d.isstop as IDS from dsn_user t left join dsn_role r on t.role_id = r.role_id left join dsn_dpt d on t.iddpt = d.iddpt where t.logincode = 'aa'
只需要给r.isstop as IdSS,d.isstop as IDS加上别名即可。