异常:'id' 未找到,可用列:SCOPE_IDENTITY()

Anorm: 'id' not found, available columns: SCOPE_IDENTITY()

我是 运行 一个 SQL 查询,在 H2 或 MySQL 中复制粘贴时效果很好,但在 Anorm 中失败并出现一条神秘的错误消息:'id' not found, available columns: SCOPE_IDENTITY()

[debug] c.j.b.PreparedStatementHandle -
      INSERT INTO projects (person_id,name,code_name,isControl,toAnalyze)
      VALUES (111,'asdf','asdf',1,1)
[info]   anorm.AnormException: 'id' not found, available columns: SCOPE_IDENTITY(), SCOPE_IDENTITY()

N.B。 table 中有一列 id - 自增主键 - 但不确定是否相关。

这是什么意思?

其实是因为我查询

SQL"...".executeInsert(parser.*)

使用定义错误的解析器而不是

SQL"...".executeInsert()

SCOPE_IDENTITY 指的是插入行的 ID,并将解析器传递给 executeInsert 方法使其成为 return 自定义对象列表(拥有 id 字段,显然)而不是整数列表。