Author: rmannibucau
Date: Sat Aug 11 20:49:43 2012
New Revision: 1372024

URL: http://svn.apache.org/viewvc?rev=1372024&view=rev
Log:
prefixing even the sequence table

Added:
    
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/openjpa/PrefixTableJdbcSeq.java
Modified:
    
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java

Modified: 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java?rev=1372024&r1=1372023&r2=1372024&view=diff
==============================================================================
--- 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
 (original)
+++ 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
 Sat Aug 11 20:49:43 2012
@@ -589,6 +589,8 @@ class AppInfoBuilder {
         public static final String TABLE_PREFIX = "openejb.jpa.table_prefix";
         public static final String OPENJPA_METADATA_REPOSITORY = 
"openjpa.MetaDataRepository";
         public static final String PREFIX_METADATA_REPOSITORY = 
"org.apache.openejb.openjpa.PrefixMappingRepository";
+        public static final String OPENJPA_SEQUENCE = "openjpa.Sequence";
+        public static final String PREFIX_SEQUENCE = 
"org.apache.openejb.openjpa.PrefixTableJdbcSeq";
 
         public static final String PROVIDER_PROP = 
"javax.persistence.provider";
         public static final String TRANSACTIONTYPE_PROP = 
"javax.persistence.transactionType";
@@ -751,6 +753,11 @@ class AppInfoBuilder {
                         throw new OpenEJBRuntimeException("can't honor table 
prefixes since you provided a custom mapping repository: " + mapping);
                     }
                     info.properties.setProperty(OPENJPA_METADATA_REPOSITORY, 
PREFIX_METADATA_REPOSITORY + "(prefix=" + prefix + ")");
+                    if (!info.properties.containsKey(OPENJPA_SEQUENCE)) {
+                        info.properties.setProperty(OPENJPA_SEQUENCE, 
PREFIX_SEQUENCE + "(prefix=" + prefix + ")");
+                    } else {
+                        logger.warning("you configured a custom sequence so 
the prefix will be ignored");
+                    }
                 }
 
                 final Set<String> keys = new 
HashSet<String>(info.properties.stringPropertyNames());

Added: 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/openjpa/PrefixTableJdbcSeq.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/openjpa/PrefixTableJdbcSeq.java?rev=1372024&view=auto
==============================================================================
--- 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/openjpa/PrefixTableJdbcSeq.java
 (added)
+++ 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/openjpa/PrefixTableJdbcSeq.java
 Sat Aug 11 20:49:43 2012
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.openjpa;
+
+import org.apache.openjpa.jdbc.kernel.TableJDBCSeq;
+
+public class PrefixTableJdbcSeq extends TableJDBCSeq {
+    private String prefix;
+
+    public void setPrefix(String prefix) {
+        this.prefix = prefix;
+    }
+
+    @Override
+    public void endConfiguration() {
+        setTable(prefix + getTable());
+        super.endConfiguration();
+    }
+}


Reply via email to