Thanks for your help.  I'm still trying to work through it.

I think one of the sticking points for me is creating a table with 
arbitrary numbers of rows and keeping the type safety.

If I have several distinct variables for my rows, then it is easy to keep 
type safety with the DSL.values(Row3<T1,T2,T3> rows...) method.  The 
compiler can enforce the generic types:

    Row3<String, Integer, Integer> row1 = DSL.row("x", 1, 2);
    Row3<String, Integer, Integer> row2 = DSL.row("y", 3, 4);
    Row3<String, Integer, Integer> row3 = DSL.row("z", 5, 6);
    Table<Record3<String, Integer, Integer>> values = DSL.values(row1, row2, 
row3);



But If I first put those rows into a List<Row3>, the compiler cannot do the 
type checking because it is necessary to first convert the List into an 
array, and it isn't possible to have generic parameters in array 
declarations.  Java looses all notion of generic types when the array is 
declared.  (Using a List<Row3> or array Row3[] is what I need because I'm 
adding items in a loop.)

  List<Row3<String, Integer, Integer>> rowList = new ArrayList<>();
  rowList.add(row1);
  rowList.add(row2);
  rowList.add(row3);
  
  Row3[] rows = rowList.toArray(new Row3[rowList.size()]);  // generic 
parameters are lost here
  Table<Record> values = DSL.values(rows);



The compiler has no way of knowing the generic parameters of each Record 
anymore.  In fact, it will compile and execute non-sense like this:

    Table<Record4<Double, String, Integer,String>> userInput = DSL.values(
rows);



If the DSL class had a method
DSL.values(Collection<Row3<T1,T2,T3>> rows)
 then that would work better at preserving type safety than this:
DSL.values(Row3<T1,T2,T3> rows...)




  


-- 
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/d/optout.

Reply via email to