为什么Hibernate将模式名称添加到Hsql函数? [英] Why is Hibernate adding schema name to Hsql functions?

查看:130
本文介绍了为什么Hibernate将模式名称添加到Hsql函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个使用Hibernate 3.0.3的遗留应用程序。我们使用HSQLDB进行单元测试。其中一个由Hibernate生成的查询如下所示:

 选择
transactio0_.REASON_ID作为REASON1_0_,
transactio0_.DESCRIPTION as DESCRIPT2_93_0_,
transactio0_.REASON_NAME as REASON3_93_0_
from APPS.MTL_TRANSACTION_REASONS transactio0_
where transactio0_.REASON_ID = 54
and transactio0_.NVL(transactio0_.disable_date,NOW ()+ 1 DAY)> NOW()

请注意,模式名称transactio0_预先添加到NVL函数中。为什么?我们如何配置Hibernate以避免这样做?



下一个问题涉及到我们正在使用的HSQLDB版本。我们目前正在使用HSQLDB 2.2.8,并希望升级到HSQLDB 2.3.2。
上面的查询在HSQLDB 2.2.8下正常工作,但在HSQLDB 2.3.2中出现无效模式名称错误。有没有什么办法可以配置HSQLDB 2.3.2,以便它能像HSQLDB 2.2.8那样成功执行查询?解析方案

生成的SQL看起来很奇怪,当然也是不正确的SQL。 transactio0 _ 是一个表别名,不应该作为任何函数名称的前缀。



也许选中的Hibernate方言不是HSQLDB方言。



在任何情况下,这都是Hibernate的旧版本,需要与接近发布时间的HSQLDB版本一起使用。



关于配置HSQLDB接受格式错误的名称,它应该是不可能的,因为原来的行为是固定的,因为它过于宽松并且接受不正确的SQL。


We have a legacy app which uses Hibernate 3.0.3. We do unit testing with HSQLDB. One of the queries that is generated by Hibernate looks like this:

select
 transactio0_.REASON_ID as REASON1_0_,
 transactio0_.DESCRIPTION as DESCRIPT2_93_0_,
 transactio0_.REASON_NAME as REASON3_93_0_ 
from APPS.MTL_TRANSACTION_REASONS transactio0_ 
where transactio0_.REASON_ID=54
 and transactio0_.NVL (transactio0_.disable_date, NOW() + 1 DAY) > NOW()

Note that the schema name "transactio0_" is prepended to the NVL function. Why? How can we configure Hibernate so that does not do that?

The next question deals with the version of HSQLDB that we are using. We're currently using HSQLDB 2.2.8 and would like to move up to HSQLDB 2.3.2. The above query works fine with HSQLDB 2.2.8 but fails in HSQLDB 2.3.2 with an "invalid schema name" error. Is there any way that we can configure HSQLDB 2.3.2 so that it can successfully execute the query like HSQLDB 2.2.8 does?

解决方案

The generated SQL looks strange and is certainly incorrect SQL. The transactio0_ is a table alias and shouldn't be prepended to any function name.

Perhaps the selected Hibernate dialect is not the HSQLDB dialect.

In any case, this is an old version of Hibernate and needs to be used with a version of HSQLDB that is closer to its time of release.

Regarding configuring HSQLDB to accept the malformed name, it shouldn't be possible as the original behavior was fixed because it was too lax and accepted incorrect SQL.

这篇关于为什么Hibernate将模式名称添加到Hsql函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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