From commits-return-11158-apmail-jackrabbit-commits-archive=jackrabbit.apache.org@jackrabbit.apache.org Thu May 26 14:28:27 2011 Return-Path: X-Original-To: apmail-jackrabbit-commits-archive@www.apache.org Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id ED9CF687E for ; Thu, 26 May 2011 14:28:26 +0000 (UTC) Received: (qmail 48884 invoked by uid 500); 26 May 2011 14:28:26 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 48860 invoked by uid 500); 26 May 2011 14:28:26 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 48853 invoked by uid 99); 26 May 2011 14:28:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 May 2011 14:28:26 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 May 2011 14:28:25 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id CB6E923888FD; Thu, 26 May 2011 14:28:05 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@jackrabbit.apache.org From: stefan@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110526142805.CB6E923888FD@eris.apache.org> 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(); }