Eclipse Link在我们的RCP应用程序中的persistence类之外创建一个查询,如下所示:
select column1, column2, ..., version from table_name使用这样的select,我们得到错误'ORA-00942',表示表或视图不存在。我们使用的是Oracle 11g数据库。同样的语句也适用于JDBC连接(不使用Eclipse Link),没有问题。同样在SQLPlus中,该语句也是有效的。我们检查了访问权限,确保在所有测试中拥有相同的用户、数据库等。然后,我们尝试将持久性类中列版本的注释设置为使用双引号:
@Column(name="\"VERSION\"", nullable=false, precision=22)
private BigDecimal version;后来它成功了。所有其他列,包括表名称,都没有引号。只是这个专栏“版本”需要引号,为什么呢?列'version‘是DDL脚本的一部分,该脚本没有使用任何双引号。所有列名均为大写。表名也是如此。
在SQLDeveloper中,‘版本’被标记为关键字。但我找不到任何解释,为什么使用单词'version‘作为列名会对SQL语句产生影响。
有人知道关键字'version‘是否会对Eclipse Link或Oracle中的查询产生影响吗?
发布于 2014-11-27 00:41:18
关于Oracle:
select * from V$RESERVED_WORDS where keyword = 'VERSION';
KEYWORD LENGTH RESERVED RES_TYPE RES_ATTR RES_SEMI DUPLICATE
-------------------- ---------- -------- -------- -------- -------- ---------
VERSION 7 N N N N N 此查询检查'VERSION‘是否为关键字(您可能需要一些特殊权限才能从此视图中进行选择)
以下是对此视图的描述:
https://docs.oracle.com/cd/B19306_01/server.102/b14237/dynviews_2048.htm#REFRN30204
Column Datatype Description
KEYWORD VARCHAR2(30) Name of the keyword
LENGTH NUMBER Length of the keyword
RESERVED VARCHAR2(1) A value of Y means that the keyword cannot be used as an identifier. A value of N means that it is not reserved.
RES_TYPE VARCHAR2(1) A value of Y means that the keyword cannot be used as a type name. A value of N means that it is not reserved.
RES_ATTR VARCHAR2(1) A value of Y means that the keyword cannot be used as an attribute name. A value of N means that it is not reserved.
RES_SEMI VARCHAR2(1) A value of Y means that the keyword is not allowed as an identifier in certain situations, such as in DML. A value of N means that it is not reserved.
DUPLICATE VARCHAR2(1) A value of Y means that the keyword is a duplicate of another keyword. A value of N means that it is not a duplicate.根据这些信息,'VERSION‘是一个关键字,但您可以将其用作标识符。
https://stackoverflow.com/questions/27154071
复制相似问题