jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1127940 - /jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/H2RevisionStore.java
Date Thu, 26 May 2011 14:28:05 GMT
Author: stefan
Date: Thu May 26 14:28:05 2011
New Revision: 1127940

URL: http://svn.apache.org/viewvc?rev=1127940&view=rev
Log:
MicroKernel prototype (WIP)

Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/H2RevisionStore.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/H2RevisionStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/H2RevisionStore.java?rev=1127940&r1=1127939&r2=1127940&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/H2RevisionStore.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/H2RevisionStore.java
Thu May 26 14:28:05 2011
@@ -25,10 +25,8 @@ import java.io.InputStream;
 import java.security.DigestOutputStream;
 import java.security.MessageDigest;
 import java.sql.Connection;
-import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
-import java.sql.SQLException;
 import java.sql.Statement;
 
 /**
@@ -129,18 +127,12 @@ public class H2RevisionStore extends Sim
         String id = toHex(rawId);
         Connection con = cp.getConnection();
         try {
-            PreparedStatement stmt = con.prepareStatement("insert into REVS (ID, DATA) values
(?, ?)");
+            PreparedStatement stmt = con.prepareStatement(
+                    "insert into REVS (ID, DATA) select ?, ? where not exists (select 1 from
revs where ID = ?)");
             stmt.setBytes(1, rawId);
             stmt.setBytes(2, baos.toByteArray());
+            stmt.setBytes(3, rawId);
             stmt.executeUpdate();
-        } catch (SQLException e) {
-            if (e.getSQLState().equals("23505")) {
-                // duplicate key, ignore
-                return id;
-            } else {
-                // re-throw
-                throw e;
-            }
         } finally {
             con.close();
         }



Mime
View raw message