18
18
import org .jooq .UpdatableRecord ;
19
19
import org .jooq .impl .TableImpl ;
20
20
21
- public class TableCrud <Rec extends UpdatableRecord <Rec >, T > {
21
+ public class Dao <Rec extends UpdatableRecord <Rec >, T > {
22
22
private final TableImpl <Rec > table ;
23
- private final RecordMapper <Record , T > mapper ;
23
+ private final RecordMapper <Rec , T > mapper ;
24
24
private final RecordUnmapper <T , Rec > unmapper ;
25
25
private 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 ,
29
28
RecordUnmapper <T , Rec > unmapper ,
30
29
Supplier <DSLContext > configSupplier ) {
31
30
super ();
@@ -38,7 +37,7 @@ public TableCrud(TableImpl<Rec> table,
38
37
public T insertReturning (T obj ) {
39
38
Rec rec = records (Collections .singletonList (obj ), false ).get (0 );
40
39
rec .insert ();
41
- return rec .map (mapper );
40
+ return mapper .map (rec );
42
41
}
43
42
44
43
public void insert (T obj ) {
@@ -104,11 +103,11 @@ else if (objects.size() == 1) {
104
103
}
105
104
}
106
105
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 )));
109
108
}
110
109
111
- public List <T > find (Function <TableImpl <Rec >, Condition > func ) {
110
+ public List <T > fetch (Function <TableImpl <Rec >, Condition > func ) {
112
111
return configSupplier .get ().fetch (table , func .apply (table )).map (mapper );
113
112
}
114
113
0 commit comments