1818import org .jooq .UpdatableRecord ;
1919import org .jooq .impl .TableImpl ;
2020
21- public class TableCrud <Rec extends UpdatableRecord <Rec >,T > {
21+ public class Dao <Rec extends UpdatableRecord <Rec >,T > {
2222private final TableImpl <Rec >table ;
23- private final RecordMapper <Record ,T >mapper ;
23+ private final RecordMapper <Rec ,T >mapper ;
2424private final RecordUnmapper <T ,Rec >unmapper ;
2525private final Supplier <DSLContext >configSupplier ;
26- public TableCrud (TableImpl <Rec >table ,
27- // Ideally this would be RecordMapper<Rec, T> mapper but hitting generic issues
28- RecordMapper <Record ,T >mapper ,
26+ public Dao (TableImpl <Rec >table ,
27+ RecordMapper <Rec ,T >mapper ,
2928RecordUnmapper <T ,Rec >unmapper ,
3029Supplier <DSLContext >configSupplier ) {
3130super ();
@@ -38,7 +37,7 @@ public TableCrud(TableImpl<Rec> table,
3837public T insertReturning (T obj ) {
3938Rec rec =records (Collections .singletonList (obj ),false ).get (0 );
4039rec .insert ();
41- return rec .map (mapper );
40+ return mapper .map (rec );
4241 }
4342
4443public void insert (T obj ) {
@@ -104,11 +103,11 @@ else if (objects.size() == 1) {
104103 }
105104 }
106105
107- public T findOne (Function <TableImpl <Rec >,Condition >func ) {
108- return configSupplier .get ().fetchOne (table ,func .apply (table )). map ( mapper );
106+ public T fetchOne (Function <TableImpl <Rec >,Condition >func ) {
107+ return mapper . map ( configSupplier .get ().fetchOne (table ,func .apply (table )));
109108 }
110109
111- public List <T >find (Function <TableImpl <Rec >,Condition >func ) {
110+ public List <T >fetch (Function <TableImpl <Rec >,Condition >func ) {
112111return configSupplier .get ().fetch (table ,func .apply (table )).map (mapper );
113112 }
114113