Author: cbegin
Date: Fri Jun 26 23:42:40 2009
New Revision: 788905
URL: http://svn.apache.org/viewvc?rev=788905&view=rev
Log:
Added ScriptRunner properties to environment to allow for low level control of
sql execution options
Modified:
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/migration/commands/BaseCommand.java
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/migration/template_environment.properties
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/environments/development.properties
Modified:
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/migration/commands/BaseCommand.java
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/migration/commands/BaseCommand.java?rev=788905&r1=788904&r2=788905&view=diff
==============================================================================
---
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/migration/commands/BaseCommand.java
(original)
+++
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/migration/commands/BaseCommand.java
Fri Jun 26 23:42:40 2009
@@ -177,17 +177,24 @@
UnpooledDataSource dataSource = new
UnpooledDataSource(driverClassLoader, driver, url, username, password);
dataSource.setAutoCommit(false);
ScriptRunner scriptRunner = new ScriptRunner(dataSource.getConnection());
- scriptRunner.setAutoCommit(true);
scriptRunner.setStopOnError(!force);
- scriptRunner.setSendFullScript(false);
scriptRunner.setLogWriter(outWriter);
scriptRunner.setErrorLogWriter(outWriter);
+ setPropertiesFromFile(scriptRunner, props);
return scriptRunner;
} catch (Exception e) {
throw new MigrationException("Error creating ScriptRunner. Cause: " +
e, e);
}
}
+ private void setPropertiesFromFile(ScriptRunner scriptRunner, Properties
props) {
+ String delimiterString = props.getProperty("delimiter");
+
scriptRunner.setAutoCommit(Boolean.valueOf(props.getProperty("auto_commit")));
+ scriptRunner.setDelimiter(delimiterString == null ? ";" : delimiterString);
+
scriptRunner.setFullLineDelimiter(Boolean.valueOf(props.getProperty("full_line_delimiter")));
+
scriptRunner.setSendFullScript(Boolean.valueOf(props.getProperty("send_full_script")));
+ }
+
protected File baseFile(String fileName) {
return new File(basePath.getAbsolutePath() + File.separator + fileName);
}
Modified:
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/migration/template_environment.properties
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/migration/template_environment.properties?rev=788905&r1=788904&r2=788905&view=diff
==============================================================================
---
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/migration/template_environment.properties
(original)
+++
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/migration/template_environment.properties
Fri Jun 26 23:42:40 2009
@@ -5,4 +5,23 @@
password=
# Name of the table that tracks changes to the database
-changelog=CHANGELOG
\ No newline at end of file
+changelog=CHANGELOG
+
+# If set to true, each statement is isolated
+# in its own transaction. Otherwise the entire
+# script is executed in one transaction.
+auto_commit=false
+
+# This controls how statements are delimited.
+# By default statements are delimited by an
+# end of line semicolon. Some databases may
+# (e.g. MS SQL Server) may require a full line
+# delimiter such as GO.
+delimiter=;
+full_line_delimiter=false
+
+# This ignores the line delimiters and
+# simply sends the entire script at once.
+# Use with JDBC drivers that can accept large
+# blocks of delimited text at once.
+send_full_script=false
Modified:
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/environments/development.properties
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/environments/development.properties?rev=788905&r1=788904&r2=788905&view=diff
==============================================================================
---
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/environments/development.properties
(original)
+++
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/environments/development.properties
Fri Jun 26 23:42:40 2009
@@ -6,3 +6,25 @@
# Name of the table that tracks changes to the database
changelog=CHANGELOG
+
+# Name of the table that tracks changes to the database
+changelog=CHANGELOG
+
+# If set to true, each statement is isolated
+# in its own transaction. Otherwise the entire
+# script is executed in one transaction.
+auto_commit=false
+
+# This controls how statements are delimited.
+# By default statements are delimited by an
+# end of line semicolon. Some databases may
+# (e.g. MS SQL Server) may require a full line
+# delimiter such as GO.
+delimiter=;
+full_line_delimiter=false
+
+# This ignores the line delimiters and
+# simply sends the entire script at once.
+# Use with JDBC drivers that can accept large
+# blocks of delimited text at once.
+send_full_script=false
\ No newline at end of file