【问题标题】:Hibernate criteria DB2 composite keys in IN clauseIN 子句中的休眠条件 DB2 组合键
【发布时间】:2010-04-26 15:08:54
【问题描述】:

Hibernate 标准使用 DB2 方言生成以下 SQL IN 子句中的复合键,但 DB2 回答查询不正确:

select * from tableA where (x, y) IN ( ( 'x1', y1) )

但是,DB2 抛出了这个:

SQL0104N  An unexpected token "," was found following ", y) in (
('x1'". Expected tokens may include:  "+".  SQLSTATE=42601

【问题讨论】:

  • critera 调用看起来如何,可能是错误存在?

标签: java sql hibernate db2


【解决方案1】:

正确的语法应该是

select * from tableA where (x, y) IN (VALUES ('x1', y1))

请注意,您只指定了一次 VALUES 子句,因此可以获得多行结果

select * from tableA where (x, y) IN (VALUES ('x1', y1), ('x2', y2))

不过,不知道如何让 Hibernate 做到这一点。

【讨论】:

    猜你喜欢
    • 2012-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-15
    • 1970-01-01
    • 2013-11-15
    相关资源
    最近更新 更多