hsqldb Oracle模式选择用于更新NOWAIT [英] hsqldb Oracle mode select for update NOWAIT

查看:67
本文介绍了hsqldb Oracle模式选择用于更新NOWAIT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HSQLDB似乎不支持Oracle语法中的NOWAIT.

It seems NOWAIT is not supported by HSQLDB in Oracle syntax.

HSQLDB版本:2.3.3

HSQLDB version: 2.3.3

使用

SET DATABASE SQL SYNTAX ORA TRUE;

SQL产生的异常

select a, b, c from sometable where id=1 for update NOWAIT

例外

Caused by: org.hsqldb.HsqlException: unexpected token: NOWAIT
at org.hsqldb.error.Error.parseError(Unknown Source)
at org.hsqldb.ParserBase.unexpectedToken(Unknown Source)
at org.hsqldb.ParserCommand.compileStatement(Unknown Source)
at org.hsqldb.Session.compileStatement(Unknown Source)
at org.hsqldb.StatementManager.compile(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)

  1. 有人知道HSQLDB是否不支持吗?
  2. 任何想法如何在不修改原始SQL的情况下避免这种异常.我可以在单元测试中忽略NOWAIT功能,但不能修改SQL.附加信息:我们使用spring-jbdc和JdbcTemplate并考虑通过拦截将其替换为NOWAIT将sqls作为JUnit测试设置中的一个技巧.

推荐答案

在sourceforge上挖掘hsqldb源代码后,终于找到了我自己的问题的答案.

Found answer to my own question finally after digging hsqldb source code on sourceforge.

HSQLDB的2.3.3版本不支持NOWAIT.

Version 2.3.3 of HSQLDB does NOT support NOWAIT.

我已经在他们的论坛中提出了这个问题,并提出了问题,但是它与GitHub并不一样,因为您可以创建问题,因此没有打开正式的Issue/Request.

I have asked this question in their Discussion Forum and raised the issue however its not like GitHub where you can create an issue so no formal Issue/Request opened.

现在我自己修改HSQLDB代码org.hsqldb.ParserDQL类以忽略选择更新SQL中的NOWAIT,我就遇到了麻烦.

I am getting along with a bad hack for now modifying HSQLDB code myself org.hsqldb.ParserDQL class to just ignore the NOWAIT in the select-for-update SQL.

如果有人有更好的答案,我会接受他们的答案.

If anyone has better answer I will accept their answer.

更新:(2015年8月24日)

UPDATE: (Aug-24-2015)

收到HSQLDB论坛的确认,即NOWAIT将被忽略.同时,我将发布代码片段以忽略从HSQLDB sourceforge论坛收到的NOWAIT.您可能要等待HSQLDB的下一个版本,而不是将其添加到代码库中(作为一种技巧).

Received confirmation from HSQLDB forum that NOWAIT will be ignored. Meanwhile I am posting the code snippet to ignore NOWAIT that I received from the HSQLDB sourceforge forum. You may want to wait for the next version of HSQLDB than adding this to your code base (as a hack).

 if (Tokens.T_NOWAIT.equals(token.tokenString)) {
        read();
 }

已更新,以显示有关在ParserDQL.java中将以上代码片段添加到何处的完整上下文

UPDATED to show the full context as to where to add the above snippet in the ParserDQL.java

    /**
 * Retrieves a SELECT or other query expression Statement from this parse context.
 */
StatementQuery compileCursorSpecification(RangeGroup[] rangeGroups,
        int props, boolean isRoutine) {

    OrderedHashSet  colNames        = null;
    QueryExpression queryExpression = XreadQueryExpression();

    if (token.tokenType == Tokens.FOR) {
        read();

        if (token.tokenType == Tokens.READ
                || token.tokenType == Tokens.FETCH) {
            read();
            readThis(Tokens.ONLY);

            props = ResultProperties.addUpdatable(props, false);
        } else {
            readThis(Tokens.UPDATE);

            props = ResultProperties.addUpdatable(props, true);

            if (token.tokenType == Tokens.OF) {
                readThis(Tokens.OF);

                colNames = new OrderedHashSet();

                readColumnNameList(colNames, null, false);
            }
            if (Tokens.T_NOWAIT.equalsIgnoreCase(token.tokenString)) {
                readIfThis(Tokens.X_IDENTIFIER);
            }
        }
    }

这篇关于hsqldb Oracle模式选择用于更新NOWAIT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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