Skip NonUniqueDiscoveredSqlAliasException when two table has same column names

蓝咒 提交于 2021-02-11 12:29:29

问题


My existing application is using HibernateDAOSupport and hibernateTemplate with version 3.6.10. When I have a native query like below then it works fine with current system.

select a.name, b.name from a inner join b on a.bid=b.id

Now I am upgrading my application to JPA so it throws me error : NonUniqueDiscoveredSqlAliasException

I can fix this error by changing query to below one:

select a.name as aname, b.name from a inner join b on a.bid=b.id

But the problem is my application is huge and finding out these queries would be tedious. Want to know if there is any setting where I can skip this error to throw.


回答1:


I'm afraid that this is not possible according to the documentation:

https://docs.jboss.org/hibernate/orm/5.4/userguide/html_single/Hibernate_User_Guide.html#sql-multi-entity-query

Column alias injection is needed in the following query which otherwise throws NonUniqueDiscoveredSqlAliasException.



来源:https://stackoverflow.com/questions/56734641/skip-nonuniquediscoveredsqlaliasexception-when-two-table-has-same-column-names

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!