为什么 JBoss 5 没有验证此 EJBQL 查询?

发布于 2024-09-13 14:29:23 字数 1035 浏览 12 评论 0原文

我正在将现有应用程序从 Weblogic 服务器 9 迁移到 JBoss 5。

我的问题是 WHERE 子句中包含字符条件的查询,如下所示:

SELECT DISTINCT OBJECT(myObject) 
FROM MyObject myObject 
WHERE myObject.myAttribute = 'F'

...我相信与 WLS 一起使用现在会导致部署中止对于 JBoss,由于以下原因:

Caused by: org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "\'F\'" 
at line 1, column 99.
Was expecting one of:
    "ABS" ...
    "LENGTH" ...
    "LOCATE" ...
    "SQRT" ...
    "MOD" ...
    "(" ...
    "+" ...
    "-" ...
    <INTEGER_LITERAL> ...
    <FLOATING_POINT_LITERAL> ...
    <NUMERIC_VALUED_PARAMETER> ...
    <NUMERIC_VALUED_PATH> ...

ejb-jar.xml 和 jbosscmp-jdbc.xml 文件声明类型和属性。在 Java 文件中,该属性的 getter 和 setter 方法都使用 java.lang.Character 类型。 Oracle 数据库列的类型为 CHAR(1)。

jbosscmp-jdbc.xml 文件中声明的查询编译器是

org.jboss.ejb.plugins.cmp.jdbc.EJBQLToSQL92Compiler

该编译器应该与 EJBQL 2.1 查询一起使用。将编译器更改为默认的 JDBCEJBQLCompiler 不会改变任何内容。

有人知道这里出了什么问题吗?

感谢您的帮助! :-)

I am migrating an existing application from Weblogic server 9 to JBoss 5.

My problem is with a query that has a character condition in the WHERE clause, like this one:

SELECT DISTINCT OBJECT(myObject) 
FROM MyObject myObject 
WHERE myObject.myAttribute = 'F'

... which I believe was working with WLS now leads to an aborted deployment with JBoss, because of the following reason:

Caused by: org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "\'F\'" 
at line 1, column 99.
Was expecting one of:
    "ABS" ...
    "LENGTH" ...
    "LOCATE" ...
    "SQRT" ...
    "MOD" ...
    "(" ...
    "+" ...
    "-" ...
    <INTEGER_LITERAL> ...
    <FLOATING_POINT_LITERAL> ...
    <NUMERIC_VALUED_PARAMETER> ...
    <NUMERIC_VALUED_PATH> ...

The ejb-jar.xml and the jbosscmp-jdbc.xml files declare the type and the attribute. In the Java files, the getter and setter methods for this attribute both use the java.lang.Character type. The Oracle database column is of type CHAR(1).

The Query compiler declared in the jbosscmp-jdbc.xml file is

org.jboss.ejb.plugins.cmp.jdbc.EJBQLToSQL92Compiler

This compiler is the one that should be used with EJBQL 2.1 queries. Changing the compiler to the default JDBCEJBQLCompiler doesn't change anything.

Anybody knows what's wrong here?

Thanks for your help! :-)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

恋你朝朝暮暮 2024-09-20 14:29:23

EJBQL 只知道 WHERE 子句中的字符串、整数和布尔文字。 'F' 是一个字符串,查询需要一个小整型值,因为我猜,该 char 被映射到一些整数值。

编辑:也许使用“F”的文字 ascii 代码 70 可用于此查询。
尽管如此:
SQL CHAR 数据类型不应用于映射到 cmp 字段的数据库列。
也许将其更改为 varchar。

EJBQL only knows String, Integer and Boolean-Literals in the WHERE-clause. 'F' is a String and the query is expecting an smallint-value, because I guess, that char is mapped to some integer values.

EDIT: Maybe using the literal ascii-code 70 of 'F' can be used for this query.
Nevertheless:
The SQL CHAR data type should not be used for database columns that are mapped to cmp fields.
Maybe alter it to varchar.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文