当两个表具有相同的列名时,跳过NonUniqueDiscoveredSqlAliasException [英] Skip NonUniqueDiscoveredSqlAliasException when two table has same column names

查看:50
本文介绍了当两个表具有相同的列名时,跳过NonUniqueDiscoveredSqlAliasException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现有的应用程序正在使用版本3.6.10的HibernateDAOSupport和hibernateTemplate.当我有如下所示的本机查询时,则在当前系统上可以正常使用.

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

现在我正在将应用程序升级到JPA,因此会引发错误:NonUniqueDiscoveredSqlAliasException

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.

推荐答案

根据文档,恐怕这是不可能的:

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

在以下查询中需要列别名注入否则抛出NonUniqueDiscoveredSqlAliasException.

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

这篇关于当两个表具有相同的列名时,跳过NonUniqueDiscoveredSqlAliasException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆