HHH-1122 - Fix hbm2ddl.SchemaUpdate has no delimiter
This commit is contained in:
parent
bf892ef354
commit
8bfaaea4b6
|
@ -55,6 +55,7 @@ public class SchemaUpdate {
|
||||||
private final JdbcConnectionAccess jdbcConnectionAccess;
|
private final JdbcConnectionAccess jdbcConnectionAccess;
|
||||||
private final List<Exception> exceptions = new ArrayList<Exception>();
|
private final List<Exception> exceptions = new ArrayList<Exception>();
|
||||||
private String outputFile;
|
private String outputFile;
|
||||||
|
private String delimiter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a SchemaUpdate object. This form is intended for use from tooling
|
* Creates a SchemaUpdate object. This form is intended for use from tooling
|
||||||
|
@ -133,7 +134,7 @@ public class SchemaUpdate {
|
||||||
List<org.hibernate.tool.schema.spi.Target> toolTargets = new ArrayList<org.hibernate.tool.schema.spi.Target>();
|
List<org.hibernate.tool.schema.spi.Target> toolTargets = new ArrayList<org.hibernate.tool.schema.spi.Target>();
|
||||||
|
|
||||||
if ( target.doScript() ) {
|
if ( target.doScript() ) {
|
||||||
toolTargets.add( new TargetStdoutImpl() );
|
toolTargets.add( new TargetStdoutImpl( delimiter ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( target.doExport() ) {
|
if ( target.doExport() ) {
|
||||||
|
@ -142,7 +143,7 @@ public class SchemaUpdate {
|
||||||
|
|
||||||
if ( outputFile != null ) {
|
if ( outputFile != null ) {
|
||||||
LOG.writingGeneratedSchemaToFile( outputFile );
|
LOG.writingGeneratedSchemaToFile( outputFile );
|
||||||
toolTargets.add( new TargetFileImpl( outputFile ) );
|
toolTargets.add( new TargetFileImpl( outputFile, delimiter ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return toolTargets;
|
return toolTargets;
|
||||||
|
@ -167,7 +168,14 @@ public class SchemaUpdate {
|
||||||
this.outputFile = outputFile;
|
this.outputFile = outputFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the end of statement delimiter
|
||||||
|
*
|
||||||
|
* @param delimiter The delimiter
|
||||||
|
*
|
||||||
|
*/
|
||||||
public void setDelimiter(String delimiter) {
|
public void setDelimiter(String delimiter) {
|
||||||
|
this.delimiter = delimiter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -180,6 +188,7 @@ public class SchemaUpdate {
|
||||||
|
|
||||||
final SchemaUpdate schemaUpdate = new SchemaUpdate( metadata );
|
final SchemaUpdate schemaUpdate = new SchemaUpdate( metadata );
|
||||||
schemaUpdate.setOutputFile( parsedArgs.outFile );
|
schemaUpdate.setOutputFile( parsedArgs.outFile );
|
||||||
|
schemaUpdate.setDelimiter( parsedArgs.delimiter );
|
||||||
schemaUpdate.execute( parsedArgs.script, parsedArgs.doUpdate );
|
schemaUpdate.execute( parsedArgs.script, parsedArgs.doUpdate );
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
@ -252,6 +261,7 @@ public class SchemaUpdate {
|
||||||
String propertiesFile = null;
|
String propertiesFile = null;
|
||||||
String cfgXmlFile = null;
|
String cfgXmlFile = null;
|
||||||
String outFile = null;
|
String outFile = null;
|
||||||
|
String delimiter = null;
|
||||||
|
|
||||||
String implicitNamingStrategyImplName = null;
|
String implicitNamingStrategyImplName = null;
|
||||||
String physicalNamingStrategyImplName = null;
|
String physicalNamingStrategyImplName = null;
|
||||||
|
@ -282,6 +292,9 @@ public class SchemaUpdate {
|
||||||
else if ( arg.startsWith( "--naming=" ) ) {
|
else if ( arg.startsWith( "--naming=" ) ) {
|
||||||
DeprecationLogger.DEPRECATION_LOGGER.logDeprecatedNamingStrategyArgument();
|
DeprecationLogger.DEPRECATION_LOGGER.logDeprecatedNamingStrategyArgument();
|
||||||
}
|
}
|
||||||
|
else if ( arg.startsWith( "--delimiter=" ) ) {
|
||||||
|
parsedArgs.delimiter = arg.substring( 12 );
|
||||||
|
}
|
||||||
else if ( arg.startsWith( "--implicit-naming=" ) ) {
|
else if ( arg.startsWith( "--implicit-naming=" ) ) {
|
||||||
parsedArgs.implicitNamingStrategyImplName = arg.substring( 18 );
|
parsedArgs.implicitNamingStrategyImplName = arg.substring( 18 );
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,12 @@ import org.hibernate.tool.schema.spi.Target;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class TargetFileImpl implements Target {
|
public class TargetFileImpl implements Target {
|
||||||
private FileWriter fileWriter;
|
final private FileWriter fileWriter;
|
||||||
|
final private String delimiter;
|
||||||
|
|
||||||
public TargetFileImpl(String outputFile) {
|
public TargetFileImpl(String outputFile, String delimter) {
|
||||||
try {
|
try {
|
||||||
|
this.delimiter = delimter;
|
||||||
this.fileWriter = new FileWriter( outputFile );
|
this.fileWriter = new FileWriter( outputFile );
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
|
@ -40,6 +42,9 @@ public class TargetFileImpl implements Target {
|
||||||
public void accept(String action) {
|
public void accept(String action) {
|
||||||
try {
|
try {
|
||||||
fileWriter.write( action );
|
fileWriter.write( action );
|
||||||
|
if ( delimiter != null ) {
|
||||||
|
fileWriter.write( delimiter );
|
||||||
|
}
|
||||||
fileWriter.write( "\n" );
|
fileWriter.write( "\n" );
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
|
@ -57,4 +62,5 @@ public class TargetFileImpl implements Target {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,16 @@ import org.hibernate.tool.schema.spi.Target;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class TargetStdoutImpl implements Target {
|
public class TargetStdoutImpl implements Target {
|
||||||
|
final private String delimiter;
|
||||||
|
|
||||||
|
public TargetStdoutImpl() {
|
||||||
|
this( null );
|
||||||
|
}
|
||||||
|
|
||||||
|
public TargetStdoutImpl(String delimiter) {
|
||||||
|
this.delimiter = delimiter;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptsImportScriptActions() {
|
public boolean acceptsImportScriptActions() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -23,10 +33,14 @@ public class TargetStdoutImpl implements Target {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void accept(String action) {
|
public void accept(String action) {
|
||||||
|
if ( delimiter != null ) {
|
||||||
|
action += delimiter;
|
||||||
|
}
|
||||||
System.out.println( action );
|
System.out.println( action );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void release() {
|
public void release() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue