我们在Oracle数据库上方的应用程序中有多个MyBatis查询,它使用序列生成自己的ID值以供进一步使用
select s_seq1.nextval from dual
insert into some_table
(some_id, some_data, created_on, created_by)
values
(#{someId}, #{someData}, #{createdOn}, #{createdBy})
我们现在正尝试使用Derby数据库为应用程序编写集成测试,但由于没有双表,我们尝试通过创建一个名为dual的伪视图来实现上述查询,其中包含序列nextval表达式作为其列。具有两个示例列的Liquibase变更集如下
检查Derby内容,该视图已成功创建,但在运行测试时,我们仍会收到上述查询的异常
java.sql.SQLSyntaxErrorException: Column 'S_SEQ1.NEXTVAL' is either not in any table in the FROM list or appears within a join specification
and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list.
问题似乎是由于点我们必须在引号之间创建假视图列,因此MyBatis查询也可以在Derby上使用引号之间的列名,但这样就可以在Oracle上创建真正的应用程序失败。这似乎是一种僵局。任何想法都将不胜感激。