jeudi 25 mai 2017

How i can reused/compsose repository method?

Used DSLContext I have a method for select all relationship data.

 open fun selectAllSomethings(id: String): List<SomeDto> = ctx
    .select(..), 
    .from(..)
    .join(..)
    .leftJoin(...)
    .fetch()
    .map()

And need reused this logic with add where for concrete id and change fetch to fetchOne and map. How i can reuse first part of query?

ctx.select(..), 
    .from(..)
    .join(..)
    .leftJoin(...)

Is it necessary to divide this into two different methods? Or need to add "if" ?

Aucun commentaire:

Enregistrer un commentaire