Hello,
I'm using jOOQ version 3.1.0 for SQL building and JDBC for SQL execution. In an attempt to test my application I would like to mock the database as described in the manual:
http://www.jooq.org/doc/3.0/manual/tools/jdbc-mocking/. Since I haven't used the code generation I can't use exactly the code as described in the manual. My primitive workaround was the following:
DSLContext create = DSL.using(SQLDialect.POSTGRES);
Table<Record> table = DSL.table("some_table");
Record record = create.newRecord(table);
record.setValue(DSL.field("id"), 1);
Result<Record> result = create.newResult(table);
result.add(record);
However, this code would blow up with an ArrayIndexOutOfBoundsException at org.jooq.impl.AbstractRecord.getValue0(AbstractRecord.java:271). Is there any way of using the mocking features without code generation?
Off topic: the exception was thrown when calling this function of AbstractRecord:
final <T> Value<T> getValue0(Field<T> field) {
return getValue0(fieldsRow().indexOf(field));
}
The method indexOf(field) returns -1 as the field is not found and then calls the overloaded getValue0(int index) method, which contains the following input checking
if (index >= v.length) {
throw new IllegalArgumentException("Field " + index + " is not contained in list");
}
Maybe the comparison could be changed to check also for values smaller than 0.
Thanks a lot!
cheers,
kevin