summaryrefslogtreecommitdiffstats
path: root/java/MyMyBatis/src/AbstractDAOOperations.java
blob: e39f6808b1cb2f052c3dbf6b54d4f444b9b900a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package ch.asynk;

import java.util.List;

public abstract class AbstractDAOOperations<TObject, TIdentity, TMapper extends AbstractMapper<TObject, TIdentity>> extends AbstractDAO<TObject, TMapper>
{
    public int insert(final TObject obj)
    {
        return execInt(true, new CallBack<Integer, TMapper>() {
            public Integer call(TMapper m) { return m.insert(obj); }
        });
    }

    public int update(final TObject obj)
    {
        return execInt(true, new CallBack<Integer, TMapper>() {
            public Integer call(TMapper m) { return m.update(obj); }
        });
    }

    public int delete(final TObject obj)
    {
        return execInt(true, new CallBack<Integer, TMapper>() {
            public Integer call(TMapper m) { return m.delete(obj); }
        });
    }

    public int count()
    {
        return execInt(false, new CallBack<Integer, TMapper>() {
            public Integer call(TMapper m) { return m.count(); }
        });
    }

    public List<TObject> select()
    {
        return execObjects(false, new CallBack<List<TObject>, TMapper>() {
            public List<TObject> call(TMapper m) { return m.select(); }
        });
    }

    public TObject selectOne(final TIdentity id)
    {
        return execObject(false, new CallBack<TObject, TMapper>() {
            public TObject call(TMapper m) { return m.selectOne(id); }
        });
    }
}