转换“'1TRUE'的数据转换错误

时间:2014-03-04 12:38:40

标签: h2

我正在尝试运行以下查询: 准备:

INSERT INTO manual_sentences (project_id, sentence_id, weight, is_from_external_source, original_sentence_id, `partition`) 
VALUES (?, ?, ?, ?, ?, ?) 
ON DUPLICATE KEY UPDATE weight = weight + ?, is_from_external_source = is_from_external_source || ?

参数:42(Long), 1316(Long), 1(Integer), true(Boolean), 1315(Long), 0(Integer), 1(Integer), true(Boolean)

如果is_from_external_source = is_from_external_source || ?启动,则在MySQL模式下运行的H2 DB上会返回以下错误:

org.springframework.dao.DataIntegrityViolationException: 
### Error updating database.  Cause: org.h2.jdbc.JdbcSQLException: Data conversion error converting "'1TRUE' (MANUAL_SENTENCES: IS_FROM_EXTERNAL_SOURCE TINYINT DEFAULT 0 NOT NULL)"; SQL statement:
INSERT INTO manual_sentences (project_id, sentence_id, weight, is_from_external_source, original_sentence_id, `partition`) 
        VALUES (?, ?, ?, ?, ?, ?)
        ON DUPLICATE KEY UPDATE weight = weight + ?, is_from_external_source = is_from_external_source || ? [22018-175]
### The error may involve com.nuance.entrd.mc.nes.persistence.mappers.IManualSentenceMapper.addManualSentenceObject-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO manual_sentences (project_id, sentence_id, weight, is_from_external_source, original_sentence_id, `partition`)         VALUES (?, ?, ?, ?, ?, ?)        ON DUPLICATE KEY UPDATE weight = weight + ?, is_from_external_source = is_from_external_source || ?
### Cause: org.h2.jdbc.JdbcSQLException: Data conversion error converting "'1TRUE' (MANUAL_SENTENCES: IS_FROM_EXTERNAL_SOURCE TINYINT DEFAULT 0 NOT NULL)"; SQL statement:
INSERT INTO manual_sentences (project_id, sentence_id, weight, is_from_external_source, original_sentence_id, `partition`) 
        VALUES (?, ?, ?, ?, ?, ?)
        ON DUPLICATE KEY UPDATE weight = weight + ?, is_from_external_source = is_from_external_source || ? [22018-175]
; SQL []; Data conversion error converting "'1TRUE' (MANUAL_SENTENCES: IS_FROM_EXTERNAL_SOURCE TINYINT DEFAULT 0 NOT NULL)"; SQL statement:
INSERT INTO manual_sentences (project_id, sentence_id, weight, is_from_external_source, original_sentence_id, `partition`) 
        VALUES (?, ?, ?, ?, ?, ?)
        ON DUPLICATE KEY UPDATE weight = weight + ?, is_from_external_source = is_from_external_source || ? [22018-175]; nested exception is org.h2.jdbc.JdbcSQLException: Data conversion error converting "'1TRUE' (MANUAL_SENTENCES: IS_FROM_EXTERNAL_SOURCE TINYINT DEFAULT 0 NOT NULL)"; SQL statement:
INSERT INTO manual_sentences (project_id, sentence_id, weight, is_from_external_source, original_sentence_id, `partition`) 
        VALUES (?, ?, ?, ?, ?, ?)
        ON DUPLICATE KEY UPDATE weight = weight + ?, is_from_external_source = is_from_external_source || ? [22018-175]

除了传递整数而不是布尔值之外,我有什么想法可以解决这个问题吗?

由于

1 个答案:

答案 0 :(得分:1)

我建议使用

is_from_external_source = is_from_external_source or ?

代替。我认为将or用于布尔“或”代替||更合乎逻辑,因为||是连接操作。

此问题与H2 issue 553重复。