In org.hibernate.tool.hbm2ddl.SchemaExport.importScript() method contains code below,
String trimmedSql = statement.trim(); if ( trimmedSql.endsWith( ";" )) { trimmedSql = trimmedSql.substring( 0, statement.length() - 1 ); }
Here the usage of statement.length() is wrong. Instead it should be trimmedSql.length()
Issue Identified:
When the user implements custom ImportSqlCommandExtractor, will return String array of statements without trimming. In is scenario it will fail to do substring & throws java.lang.StringIndexOutOfBoundsException: String index out of range {statement.length()-1}
.
Fix:
statement.length() must be changed to trimmedSql.length()
|