开发者

Why isn't this EJBQL query validated by JBoss 5?

开发者 https://www.devze.com 2023-01-10 14:34 出处:网络
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:

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 JDBCEJBQLCompi开发者_高级运维ler doesn't change anything.

Anybody knows what's wrong here?

Thanks for your help! :-)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消