diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/MappingToolTask.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/MappingToolTask.java index d5e311837..cd4328def 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/MappingToolTask.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/MappingToolTask.java @@ -50,22 +50,22 @@ import org.apache.openjpa.util.MultiLoaderClassResolver; *
  • schemaFile
  • *
  • sqlFile
  • *
  • sqlEncode
  • + *
  • sqlTerminator
  • *
  • tmpClassLoader
  • * Of these arguments, only action 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. diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java index 7e42e9b15..c9f1fe19a 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java @@ -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 = ";"; } /** diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java index dd1b197d8..b3f6a3781 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java @@ -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(); } diff --git a/openjpa-project/src/doc/manual/ref_guide_mapping.xml b/openjpa-project/src/doc/manual/ref_guide_mapping.xml index 2407b0b26..1379ee1ab 100644 --- a/openjpa-project/src/doc/manual/ref_guide_mapping.xml +++ b/openjpa-project/src/doc/manual/ref_guide_mapping.xml @@ -125,7 +125,9 @@ mappings, even if the schema already exists. -sqlEncode/-se <encoding>: Use this option with -sqlFile to write the SQL script in a different Java character set encoding than the default JVM locale, such as -UTF-8. +-sqlTerminator/-st <terminal>: Use this option +with -sqlFile to write the SQL terminating with a +different character instead of a semicolon.