Hi Florian,
I've been looking into the mapping of case classes... In fact, this is
already possible out of the box, if you
- annotate those case classes with java.beans.ConstructorProperties
- have an exact match between fetched columns and case class fields
Consider the following two queries:
val books1 =
dsl().select(T_BOOK.ID, T_BOOK.AUTHOR_ID, T_BOOK.TITLE)
.from(T_BOOK)
.orderBy(T_BOOK.ID asc)
.fetchInto(classOf[BookCase])
println(books1);
val books2 =
dsl().select()
.from(T_BOOK)
.orderBy(T_BOOK.ID asc)
.fetchInto(classOf[BookCaseWithConstructorProperties])
println(books2);
And these case classes:
case class BookCase(
id: Int,
authorId: Int,
title: String)
case class BookCaseWithConstructorProperties
@ConstructorProperties(Array("id", "authorId", "title")) (
id: Int,
authorId: Int,
title: String)
Cheers, Lukas
--
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.