Hi,

thanks a lot for your quick help and sorry for my late reply :-)
Before you pointed me to the CustomTable I already made the following dirty 
hack solve the problem.
However, the CustomTable approach is probably more appropriate than this.

public class DummyTable extends TableImpl<Record> {

public DummyTable(String name) {
super(name);
}

public void addFields(String... fieldNames) {
for (String fieldName : fieldNames)
createField(fieldName, SQLDataType.OTHER, this);
}

}

cheers,
kevin

p.s. sorry for not checking the issue tracker on github first for the 
ArrayIndexOutOfBoundsException.

On Friday, August 23, 2013 1:26:01 PM UTC+2, Lukas Eder wrote:
>
> Hello,
>
> 2013/8/22 <[email protected] <javascript:>>
>
>> 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?
>>
>
> True, this isn't very convenient for users not using the code generator. 
> Your best bet right now is to use CustomTables:
>
> http://www.jooq.org/doc/3.1/manual/sql-building/queryparts/custom-queryparts/
>
> In a CustomTable, you can explicitly declare fields for each table. This 
> area is not yet very sophisticated, from a usability perspective, I'm 
> afraid.
>  
>
>> 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.
>>
>
> There's a pending fix for this issue, here:
> https://github.com/jOOQ/jOOQ/issues/2655
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to