Hello,

Some days ago I was testing performance using orm-persistence with hibernate 2 and PostgreSQL. Today I have tested SimpleDBPersistence using a postgreSQL database and I have detected a bug in the class:

Using JDBC with PostgreSQL doesn't found any table when checking the schema because it needs the tableNamePattern in lowercase (not uppercase), the effect is that it tries to create every time you start the repository the tables and get a Exception. So the solution I propose is to search the tableNamePattern using lower and uppercase in the checkSchema method:

   protected void checkSchema() throws Exception {
       String tableName = schemaObjectPrefix + "NODE";
       ResultSet rs1 = con.getMetaData().getTables(null, null,
               (tableName).toLowerCase(), null);
       ResultSet rs2 = con.getMetaData().getTables(null, null,
               tableName, null);
       boolean schemaExists;
       try {
           schemaExists = rs1.next() || rs2.next();
       } finally {
           rs1.close();
           rs2.close();
       }

I attach the diff from latest version in svn.

Best regards
 Javier Bermejo

Index: 
src/main/java/org/apache/jackrabbit/core/state/db/SimpleDbPersistenceManager.java
===================================================================
--- 
src/main/java/org/apache/jackrabbit/core/state/db/SimpleDbPersistenceManager.java
   (revisión: 330576)
+++ 
src/main/java/org/apache/jackrabbit/core/state/db/SimpleDbPersistenceManager.java
   (copia de trabajo)
@@ -924,13 +924,17 @@
      * @throws Exception if an error occurs
      */
     protected void checkSchema() throws Exception {
-        ResultSet rs = con.getMetaData().getTables(null, null,
-                schemaObjectPrefix + "NODE", null);
+       String tableName = schemaObjectPrefix + "NODE";
+               ResultSet rs1 = con.getMetaData().getTables(null, null,
+                (tableName).toLowerCase(), null);
+        ResultSet rs2 = con.getMetaData().getTables(null, null,
+                tableName, null);
         boolean schemaExists;
         try {
-            schemaExists = rs.next();
+            schemaExists = rs1.next() || rs2.next();
         } finally {
-            rs.close();
+            rs1.close();
+            rs2.close();
         }
 
         if (!schemaExists) {

Reply via email to