问题
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