summaryrefslogtreecommitdiffstats
path: root/java/MyMyBatis/src/AbstractDAOOperations.java
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2017-04-19 16:01:19 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2017-04-19 16:01:19 +0200
commit8ec2af6e29ecb29645367a28fb1a48cf7f4f24ff (patch)
treeb30a535b4bdcde33e148110b018e39c7d6d7b989 /java/MyMyBatis/src/AbstractDAOOperations.java
parent77653bb945a5ae8adfed549fd4c5d908f5a514ae (diff)
downloadshare-8ec2af6e29ecb29645367a28fb1a48cf7f4f24ff.zip
share-8ec2af6e29ecb29645367a28fb1a48cf7f4f24ff.tar.gz
java : MyMyBatis : add AbstractModel<> to implement save in AbstractDAOOperations<>
Diffstat (limited to 'java/MyMyBatis/src/AbstractDAOOperations.java')
-rw-r--r--java/MyMyBatis/src/AbstractDAOOperations.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/java/MyMyBatis/src/AbstractDAOOperations.java b/java/MyMyBatis/src/AbstractDAOOperations.java
index 5307641..a96e336 100644
--- a/java/MyMyBatis/src/AbstractDAOOperations.java
+++ b/java/MyMyBatis/src/AbstractDAOOperations.java
@@ -2,7 +2,9 @@ package ch.asynk;
import java.util.List;
-public abstract class AbstractDAOOperations<TObject, TIdentity, TMapper extends AbstractMapper<TObject, TIdentity>> extends AbstractDAO<TObject, TMapper>
+public abstract class AbstractDAOOperations<TIdentity,
+ TObject extends AbstractModel<TIdentity>,
+ TMapper extends AbstractMapper<TObject, TIdentity>> extends AbstractDAO<TObject, TMapper>
{
public int insert(final TObject obj)
@@ -15,6 +17,11 @@ public abstract class AbstractDAOOperations<TObject, TIdentity, TMapper extends
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);