openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r1232449 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/ openjpa-project/src/doc/manual/
Date Tue, 17 Jan 2012 15:52:17 GMT
Author: ppoddar
Date: Tue Jan 17 15:52:17 2012
New Revision: 1232449

URL: http://svn.apache.org/viewvc?rev=1232449&view=rev
Log:
OPENJPA-2108: Allow configuration for SQL termination character in Mapping Tool

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/MappingToolTask.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java
    openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_mapping.xml

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/MappingToolTask.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/MappingToolTask.java?rev=1232449&r1=1232448&r2=1232449&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/MappingToolTask.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/MappingToolTask.java
Tue Jan 17 15:52:17 2012
@@ -50,22 +50,22 @@ import org.apache.openjpa.util.MultiLoad
  * <li><code>schemaFile</code></li>
  * <li><code>sqlFile</code></li>
  * <li><code>sqlEncode</code></li>
+ * <li><code>sqlTerminator</code></li>
  * <li><code>tmpClassLoader</code></li>
  * </ul> Of these arguments, only <code>action</code> is required.
  */
 public class MappingToolTask
     extends AbstractTask {
 
-    private static final Localizer _loc = Localizer.forPackage
-        (MappingToolTask.class);
+    private static final Localizer _loc = Localizer.forPackage(MappingToolTask.class);
 
     protected MappingTool.Flags flags = new MappingTool.Flags();
-    protected String file = null;
-    protected String schemaFile = null;
-    protected String sqlFile = null;
-    protected String sqlEncode = null;
+    protected String file;
+    protected String schemaFile;
+    protected String sqlFile;
+    protected String sqlEncode;
     protected boolean tmpClassLoader = true;
-
+    
     /**
      * Set the enumerated MappingTool action type.
      */
@@ -170,6 +170,14 @@ public class MappingToolTask
     public void setSQLEncode(String sqlEncode) {
         this.sqlEncode = sqlEncode;
     }
+    
+    /**
+     * Sets the characters used to terminate a generated SQL.
+     * By default, a semicolon.
+     */
+    public void setSQLTerminator(String t) {
+        flags.sqlTerminator = t;
+    }
 
     /**
      * Set whether this action applies to metadata as well as mappings.

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java?rev=1232449&r1=1232448&r2=1232449&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java
Tue Jan 17 15:52:17 2012
@@ -100,8 +100,7 @@ public class MappingTool
         ACTION_IMPORT,
     };
 
-    private static final Localizer _loc =
-        Localizer.forPackage(MappingTool.class);
+    private static final Localizer _loc = Localizer.forPackage(MappingTool.class);
 
     private final JDBCConfiguration _conf;
     private final Log _log;
@@ -499,6 +498,7 @@ public class MappingTool
                             tool.setDropSequences(flags.dropSequences);
                             tool.setWriter(flags.sqlWriter);
                             tool.setOpenJPATables(flags.openjpaTables);
+                            tool.setSQLTerminator(flags.sqlTerminator);
                         }
 
                         tool.setSchemaGroup(getSchemaGroup());
@@ -980,6 +980,7 @@ public class MappingTool
         String schemaFileName = opts.removeProperty("schemaFile", "sf", null);
         String sqlFileName = opts.removeProperty("sqlFile", "sql", null);
         String sqlEncoding = opts.removeProperty("sqlEncode", "se", null);
+        String sqlTerminator = opts.removeProperty("sqlTerminator", "st", ";");
         String schemas = opts.removeProperty("s");
         if (schemas != null)
             opts.setProperty("schemas", schemas);
@@ -996,7 +997,7 @@ public class MappingTool
             flags.sqlWriter = Files.getWriter(sqlFileName, loader, sqlEncoding);
         else
             flags.sqlWriter = Files.getWriter(sqlFileName, loader);
-
+        flags.sqlTerminator = sqlTerminator;
         return run(conf, args, flags, loader);
     }
 
@@ -1133,6 +1134,7 @@ public class MappingTool
         public boolean primaryKeys = false;
         public boolean foreignKeys = false;
         public boolean indexes = false;
+        public String  sqlTerminator = ";";
     }
 
     /**

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java?rev=1232449&r1=1232448&r2=1232449&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java
Tue Jan 17 15:52:17 2012
@@ -74,8 +74,7 @@ public class SchemaTool {
     public static final String ACTION_DROPDB = "dropDB";
     public static final String ACTION_IMPORT = "import";
     public static final String ACTION_EXPORT = "export";
-    public static final String ACTION_DELETE_TABLE_CONTENTS = 
-        "deleteTableContents";
+    public static final String ACTION_DELETE_TABLE_CONTENTS = "deleteTableContents";
 
     public static final String[] ACTIONS = new String[]{
         ACTION_ADD,
@@ -91,8 +90,7 @@ public class SchemaTool {
         ACTION_DELETE_TABLE_CONTENTS,
     };
 
-    private static final Localizer _loc = Localizer.forPackage
-        (SchemaTool.class);
+    private static final Localizer _loc = Localizer.forPackage(SchemaTool.class);
 
     private final JDBCConfiguration _conf;
     private final DataSource _ds;
@@ -111,7 +109,8 @@ public class SchemaTool {
     private SchemaGroup _group = null;
     private SchemaGroup _db = null;
     private boolean _fullDB = false;
-
+    private String _sqlTerminator = ";";
+    
     /**
      * Default constructor. Tools constructed this way will not have an
      * action, so the {@link #run()} method will be a no-op.
@@ -309,6 +308,10 @@ public class SchemaTool {
         else
             _writer = new PrintWriter(writer);
     }
+    
+    public void setSQLTerminator(String t) {
+    	_sqlTerminator = t;
+    }
 
     /**
      * Return the schema group the tool will act on.
@@ -1251,7 +1254,7 @@ public class SchemaTool {
             }
         } else {
             for (int i = 0; i < sql.length; i++)
-                _writer.println(sql[i] + ";");
+                _writer.println(sql[i] + _sqlTerminator);
             _writer.flush();
         }
 

Modified: openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_mapping.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_mapping.xml?rev=1232449&r1=1232448&r2=1232449&view=diff
==============================================================================
--- openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_mapping.xml (original)
+++ openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_mapping.xml Tue Jan 17 15:52:17
2012
@@ -125,7 +125,9 @@ mappings, even if the schema already exi
 <literal>-sqlEncode/-se &lt;encoding&gt;</literal>: Use this option
 with <literal>-sqlFile</literal> to write the SQL script in a different
 Java character set encoding than the default JVM locale, such as
-<literal>UTF-8</literal>.
+<literal>-sqlTerminator/-st &lt;terminal&gt;</literal>: Use this option
+with <literal>-sqlFile</literal> to write the SQL terminating with a 
+different character instead of a semicolon.
                 </para>
             </listitem>
             <listitem>



Mime
View raw message