Index: src/kits/ddl-gen.bat =================================================================== --- src/kits/ddl-gen.bat (revision 2530) +++ src/kits/ddl-gen.bat (working copy) @@ -36,11 +36,11 @@ if "%1"=="" ( @echo. @echo. - @echo usage: ddl-gen.bat -dialect (dialect name) -model (model_name) [-out (path to output directory)] + @echo usage: ddl-gen.bat -dialect (dialect name) -model (model_name) [-out (path to output directory)] [-delimiter (delim>)] @echo where dialect and model parameters should match the value of the dialect @echo and model properties specified for the JPA connector. @echo. - @echo Example: ddl-gen.bat -dialect HSQL -model Simple -out c:\temp + @echo Example: ddl-gen.bat -dialect HSQL -model Simple -out c:\temp -delimiter ; @echo. goto end Index: src/kits/ddl-gen.sh =================================================================== --- src/kits/ddl-gen.sh (revision 2530) +++ src/kits/ddl-gen.sh (working copy) @@ -31,11 +31,11 @@ { echo echo - echo "usage: ddl-gen.sh -dialect -model [-out ]" + echo "usage: ddl-gen.sh -dialect -model [-out ] [-delimiter ]" echo " where dialect and model parameters should match the value of the dialect and model properties" echo " specified for the JPA connector. " echo " " - echo "Example: ddl-gen.sh -dialect HSQL -model Simple -out /tmp" + echo "Example: ddl-gen.sh -dialect HSQL -model Simple -out /tmp -delimiter ;" echo " " exit } Index: src/main/java/org/modeshape/util/SchemaGen.java =================================================================== --- src/main/java/org/modeshape/util/SchemaGen.java (revision 2530) +++ src/main/java/org/modeshape/util/SchemaGen.java (working copy) @@ -29,16 +29,41 @@ public static final String CREATE_FILE_NAME = "create.modeshape-jpa-connector.ddl"; public static final String DROP_FILE_NAME = "drop.modeshape-jpa-connector.ddl"; - + private final Dialect dialect; private final Model model; private final File outputPath; + private final String delimiter; + + public SchemaGen(String dialect, String model, File outputPath) { + + this.dialect = dialectFor(dialect); + this.delimiter = null; + + this.model = JpaSource.Models.getModel(model); + if (this.model == null) { + throw new RuntimeException(JpaDdlGenI18n.invalidModel.text()); + } + this.outputPath = outputPath; + + if (this.outputPath != null && !this.outputPath.exists()) { + this.outputPath.mkdirs(); + + String logMsg = JpaDdlGenI18n.directoryLocationCreated + .text(this.outputPath.getAbsolutePath()); //$NON-NLS-1$ + logger.log(Level.INFO, logMsg); + + } + } public SchemaGen( String dialect, String model, - File outputPath ) { + File outputPath, + String delimiter) { this.dialect = dialectFor(dialect); + this.delimiter = delimiter; + this.model = JpaSource.Models.getModel(model); if (this.model == null) { throw new RuntimeException(JpaDdlGenI18n.invalidModel.text()); @@ -100,19 +125,21 @@ // cfg.setProperties(properties); SchemaExport export = new SchemaExport(configurator.getHibernateConfiguration()); export.setOutputFile(new File(outputPath, CREATE_FILE_NAME).getCanonicalPath()); + if (this.delimiter != null ) export.setDelimiter(delimiter); export.create(false, false); export.setOutputFile(new File(outputPath, DROP_FILE_NAME).getCanonicalPath()); export.drop(false, false); } - public static final String USAGE = "./ddl-gen.sh -dialect -model [-out ]\n" - + "\tExample: ./ddl-gen.sh -dialect HSQL -model Simple -out /tmp"; + public static final String USAGE = "./ddl-gen.sh -dialect -model [-out ] [-delimiter ]\n" + + "\tExample: ./ddl-gen.sh -dialect HSQL -model Simple -out /tmp -delimiter % "; public static void main( String[] args ) throws IOException { String modelName = null; String dialectName = null; File outputFile = new File("."); + String delim = null; int i = 0; while (i < args.length) { @@ -125,6 +152,9 @@ } else if ("-out".equals(args[i])) { if (i == args.length - 1) printUsage(); outputFile = new File(args[++i]); + } else if ("-delimiter".equals(args[i])) { + if (i == args.length - 1) printUsage(); + delim =args[++i]; } else if ("-help".equals(args[i]) || "-?".equals(args[i])) { printUsage(); } @@ -133,7 +163,7 @@ if (modelName == null || dialectName == null) printUsage(); - SchemaGen main = new SchemaGen(dialectName, modelName, outputFile); + SchemaGen main = new SchemaGen(dialectName, modelName, outputFile, delim); main.generate(); } Index: src/test/java/org/modeshape/util/SchemaGenTest.java =================================================================== --- src/test/java/org/modeshape/util/SchemaGenTest.java (revision 2530) +++ src/test/java/org/modeshape/util/SchemaGenTest.java (working copy) @@ -65,5 +65,19 @@ main.generate(); checkFiles(); } + + @Test + public void shouldCreateSchemaForOracleDialectWithDelimiter() throws IOException { + SchemaGen main = new SchemaGen("org.hibernate.dialect.Oracle10gDialect", MODEL_NAME, outputPath, ";"); + main.generate(); + checkFiles(); + } + + @Test + public void shouldCreateSchemaForDialectThatIsNotFullyQualifiedWithDelimiter() throws IOException { + SchemaGen main = new SchemaGen("HSQLDialect", MODEL_NAME, outputPath, "%"); + main.generate(); + checkFiles(); + } }