summaryrefslogtreecommitdiffstats
path: root/java/MyMyBatis/src/AbstractDAOOperations.java
blob: 90e0ff4a6a7bef3a95a3e210aa4992f91dc4e7b7 (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
package ch.asynk;

import java.util.List;

public abstract class AbstractDAOOperations<TIdentity,
       TObject extends AbstractModel<TIdentity, TObject>,
       TMapper extends AbstractMapper<TIdentity, TObject>> extends AbstractDAO<TObject, TMapper>
{

    public int insert(final TObject obj)
    {
        return execInt(m -> m.insert(obj), true);
    }

    public int update(final TObject obj)
    {
        return execInt(m -> m.update(obj), true);
    }

    public int save(final TObject obj)
    {
        return (obj.isUnsaved() ? insert(obj) : update(obj));
    }

    public int delete(final TObject obj)
    {
        return execInt(m -> m.delete(obj), true);
    }

    public int count()
    {
        return execInt(m -> m.count());
    }

    public List<TObject> select()
    {
        return execObjects(m -> m.select());
    }

    public TObject selectOne(final TIdentity id)
    {
        return execObject(m -> m.selectOne(id));
    }
}