Reputation: 2579
I need to select all the values of a record.
I learned that it´s possible to select each value of the record separately using the DSL.val()
function.
Let´s say we have a record R
with the following properties:
name: String
, number: Int
. Selecting each value of the record separately would look like this:
R myRecord = new R()
ctx.select(val(myRecord.name), val(myRecord.number))
As you can guess this will get pretty tedious when you have a record with 15 properties.
Is it possible to select all values of a record instead of having to select each value separately?
I imagine something like this:
ctx.select(myRecord)
Upvotes: 2
Views: 222
Reputation: 221145
If you don't need the type safety, then you can use Record.valuesRow()
.fields()
:
ctx.select(myRecord.valuesRow().fields());
This will produce a Select<Record>
, whose number of columns is unknown to the compiler. If you prefer profiting from the additional type safety provided by your specific R
record type (I'm assuming e.g. Record2<String, Integer>
), then you can use the values()
constructor:
ctx.selectFrom(values(myRecord.valuesRow()));
Upvotes: 2