[ 
https://issues.apache.org/jira/browse/OPENJPA-399?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Teresa Kan updated OPENJPA-399:
-------------------------------

    Attachment: OPENJPA-399_2.patch

I discovered another problem in GeneratedType.Sequence. If the entity did not 
declare a schema name  and the table name was unique, the sequence was created 
successfully the first time. However, when I ran the test again, it can't find 
the sequence.  
Since the sequence name is unique within a system, therefore, we can let all 
sequences create in the default schema. IN this case, we can use the null 
schema name to search the sequences from the db. The fix will be :

Index: 
openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaGenerator.java
===================================================================
--- 
openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaGenerator.java  
    (revision 585254)
+++ 
openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaGenerator.java  
    (working copy)
@@ -819,8 +819,10 @@
         if (_log.isTraceEnabled())
             _log.trace(_loc.get("gen-seqs", schemaName, sequenceName));
 
+        // since all the sequences are generated under the default schema
+        // therefore, we can use the null schemaname to search
         Sequence[] seqs = _dict.getSequences(meta, conn.getCatalog(),
-            schemaName, sequenceName, conn);
+            null, sequenceName, conn);
 
         SchemaGroup group = getSchemaGroup();
         Schema schema;
Index: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
===================================================================
--- openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java   
(revision 585254)
+++ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java   
(working copy)
@@ -94,7 +94,7 @@
             "LONG VARCHAR FOR BIT DATA", "LONG VARCHAR", "LONG VARGRAPHIC",
         }));
         systemSchemas = new String(
-                "SYSCAT, SYSIBM, SYSSTAT, SYSIBMADM, SYSTOOLS");
+                "SYSCAT,SYSIBM,SYSSTAT,SYSIBMADM,SYSTOOLS");
         maxConstraintNameLength = 18;
         maxIndexNameLength = 18;
         maxColumnNameLength = 30;
Index: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
===================================================================
--- openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java    
(revision 585254)
+++ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java    
(working copy)
@@ -3341,7 +3341,7 @@
         try {
             int idx = 1;
             if (schemaName != null)
-                stmnt.setString(idx++, schemaName);
+                stmnt.setString(idx++, schemaName.toUpperCase());
             if (sequenceName != null)
                 stmnt.setString(idx++, sequenceName);
 


> openjpa did not handle multiple schema names with same table name
> -----------------------------------------------------------------
>
>                 Key: OPENJPA-399
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-399
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 1.0.1
>         Environment: JDK1.5, OPENJPA verison 580425
>            Reporter: Teresa Kan
>            Assignee: Teresa Kan
>         Attachments: OPENJPA-399_2.patch, OPENJPA_399.patch
>
>
> Two entities have the same table name but with different schema, only one 
> table is created. In addition, when two entities use the generatedType.AUTO 
> for ID, only one OPENJPA_SEQUENCE-TABLE is created.
> The problem due to the SchemaGroup.findTable() which only looked for a table 
> name from all the schemas. Once the table was found in one of the schema then 
> it exited and assumed that the table existed. Same problem in the 
> TableJDBCSeq.addSchema().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to