diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilder.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilder.java index 0f26e4bc69..a4ad58b395 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilder.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilder.java @@ -21,7 +21,7 @@ import org.springframework.core.io.ResourceLoader; import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; /** - * A builder that provides a fluent API for constructing an embedded database. + * A builder that provides a convenient API for constructing an embedded database. * *
Usage example: *
@@ -65,7 +65,7 @@ public class EmbeddedDatabaseBuilder {
* Sets the name of the embedded database
* Defaults to 'testdb' if not called.
* @param databaseName the database name
- * @return this, for fluent call chaining
+ * @return this, to facilitate method chaining
*/
public EmbeddedDatabaseBuilder setName(String databaseName) {
this.databaseFactory.setDatabaseName(databaseName);
@@ -76,7 +76,7 @@ public class EmbeddedDatabaseBuilder {
* Sets the type of embedded database.
* Defaults to HSQL if not called.
* @param databaseType the database type
- * @return this, for fluent call chaining
+ * @return this, to facilitate method chaining
*/
public EmbeddedDatabaseBuilder setType(EmbeddedDatabaseType databaseType) {
this.databaseFactory.setDatabaseType(databaseType);
@@ -86,7 +86,7 @@ public class EmbeddedDatabaseBuilder {
/**
* Adds a SQL script to execute to populate the database.
* @param sqlResource the sql resource location
- * @return this, for fluent call chaining
+ * @return this, to facilitate method chaining
*/
public EmbeddedDatabaseBuilder addScript(String sqlResource) {
this.databasePopulator.addScript(this.resourceLoader.getResource(sqlResource));
@@ -95,8 +95,9 @@ public class EmbeddedDatabaseBuilder {
/**
* Add default scripts to execute to populate the database.
- * The default scripts are schema.sql to create the db schema and data.sql to populate the db with data.
- * @return this, for fluent call chaining
+ * The default scripts are schema.sql to create the db schema and
+ * data.sql to populate the db with data.
+ * @return this, to facilitate method chaining
*/
public EmbeddedDatabaseBuilder addDefaultScripts() {
addScript("schema.sql");
diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/init/ResourceDatabasePopulator.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/init/ResourceDatabasePopulator.java
index e65cb24a5e..3da2b77fd7 100644
--- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/init/ResourceDatabasePopulator.java
+++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/init/ResourceDatabasePopulator.java
@@ -42,12 +42,15 @@ import org.springframework.util.StringUtils;
* @author Keith Donald
* @author Dave Syer
* @author Juergen Hoeller
+ * @author Chris Beams
* @since 3.0
*/
public class ResourceDatabasePopulator implements DatabasePopulator {
private static String DEFAULT_COMMENT_PREFIX = "--";
+ private static String DEFAULT_STATEMENT_SEPARATOR = ";";
+
private static final Log logger = LogFactory.getLog(ResourceDatabasePopulator.class);
@@ -91,7 +94,7 @@ public class ResourceDatabasePopulator implements DatabasePopulator {
}
/**
- * Specify the statement separator, if a custom one.
+ * Specify the statement separator, if a custom one. Default is ";".
*/
public void setSeparator(String separator) {
this.separator = separator;
@@ -141,8 +144,8 @@ public class ResourceDatabasePopulator implements DatabasePopulator {
/**
* Execute the given SQL script.
- * The script will normally be loaded by classpath. There should be one statement per line.
- * Any semicolons will be removed.
+ *
The script will normally be loaded by classpath. There should be one statement
+ * per line. Any {@link #setSeparator(String) statement separators} will be removed.
*
Do not use this method to execute DDL if you expect rollback.
* @param connection the JDBC Connection with which to perform JDBC operations
* @param resource the resource (potentially associated with a specific encoding) to load the SQL script from
@@ -166,7 +169,7 @@ public class ResourceDatabasePopulator implements DatabasePopulator {
}
String delimiter = this.separator;
if (delimiter == null) {
- delimiter = ";";
+ delimiter = DEFAULT_STATEMENT_SEPARATOR;
if (!containsSqlScriptDelimiters(script, delimiter)) {
delimiter = "\n";
}