empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From der...@apache.org
Subject empire-db git commit: EMPIREDB-247
Date Fri, 12 Aug 2016 10:32:00 GMT
Repository: empire-db
Updated Branches:
  refs/heads/EMPIREDB-247 e89108aa2 -> e74c6d4df


EMPIREDB-247

- better naming of API
- clarify usage in docs

Project: http://git-wip-us.apache.org/repos/asf/empire-db/repo
Commit: http://git-wip-us.apache.org/repos/asf/empire-db/commit/e74c6d4d
Tree: http://git-wip-us.apache.org/repos/asf/empire-db/tree/e74c6d4d
Diff: http://git-wip-us.apache.org/repos/asf/empire-db/diff/e74c6d4d

Branch: refs/heads/EMPIREDB-247
Commit: e74c6d4dfd6cf1771ca722ae7f8180a2d53fc708
Parents: e89108a
Author: Jan Glaubitz <jan@glaubitz.org>
Authored: Fri Aug 12 12:31:25 2016 +0200
Committer: Jan Glaubitz <jan@glaubitz.org>
Committed: Fri Aug 12 12:31:25 2016 +0200

----------------------------------------------------------------------
 .../src/main/java/org/apache/empire/db/DBCommand.java     |  8 ++++----
 .../src/main/java/org/apache/empire/db/DBDatabase.java    | 10 +++++-----
 .../org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java |  2 +-
 3 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/empire-db/blob/e74c6d4d/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
----------------------------------------------------------------------
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBCommand.java b/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
index 6941cc8..786fdbe 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
@@ -1132,16 +1132,16 @@ public abstract class DBCommand extends DBCommandExpr
     }
     
     /**
-     * Creates the Insert or Update ("UPSERT") SQL-Command.
+     * Creates the INSERT or UPDATE ("UPSERT") SQL-Command.
      * 
-     * This depends on your Database (driver) and might not be supported.
+     * This depends on your Database(driver) and might not be supported.
      * Check DBDatabaseDriver.isSupported(PERFORM_UPSERT)
      * 
      * @return the SQL-Command
      */
-    public synchronized String getInsertOrUpdate()
+    public synchronized String getUpdateOrInsert()
     {
-    	throw new NotSupportedException(this, "getInsertOrUpdate");
+    	throw new NotSupportedException(this, "getUpdateOrInsert");
     }
     
     /**

http://git-wip-us.apache.org/repos/asf/empire-db/blob/e74c6d4d/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
----------------------------------------------------------------------
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java b/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
index 5d84c30..a0d24e8 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
@@ -1387,10 +1387,11 @@ public abstract class DBDatabase extends DBObject
     }
 
     /**
-     * Executes an Insert or Update Statement from a command object
+     * Executes an UPDATE or INSERT Statement from a command object
      * 
-     * This depends on your Database (driver) and might not be supported.
-     * Check DBDatabaseDriver.isSupported(PERFORM_UPSERT)
+     * Depending on your database(driver) this might be supported
+     * in one single statement (Check DBDatabaseDriver.isSupported(PERFORM_UPSERT)),
+     * or as fallback with an UPDATE, followed by an INSERT if nothing was updated.
      * 
      * @param cmd the command object containing the update command
      * @param conn a valid connection to the database.
@@ -1400,11 +1401,10 @@ public abstract class DBDatabase extends DBObject
     {
     	if (getDriver().isSupported(DBDriverFeature.PERFORM_UPSERT))
     	{
-    		return executeSQL(cmd.getInsertOrUpdate(), cmd.getParamValues(), conn); 
+    		return executeSQL(cmd.getUpdateOrInsert(), cmd.getParamValues(), conn); 
     	}
     	else
     	{
-    		log.warn("{} is not supported by your Database(driver). Falling back to two statements");
     		int count = executeUpdate(cmd, conn);
     		if (count < 1) {
     			// nothing updated -> INSERT

http://git-wip-us.apache.org/repos/asf/empire-db/blob/e74c6d4d/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java
----------------------------------------------------------------------
diff --git a/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java
b/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java
index 2429660..a02f7d8 100644
--- a/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java
+++ b/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java
@@ -123,7 +123,7 @@ public class DBDatabaseDriverMySQL extends DBDatabaseDriver
         }
         
         @Override
-        public synchronized String getInsertOrUpdate()
+        public synchronized String getUpdateOrInsert()
         {
         	StringBuilder buf = new StringBuilder(getInsert());
         	buf.append(" ON DUPLICATE KEY UPDATE ");


Mime
View raw message