ERROR: HHH000231: Schema export unsuccessful java.lang.StringIndexOutOfBoundsException: String index out of range
Description
Activity
Vladislav Kuznetsov May 10, 2016 at 7:54 PM
Bug is no longer actual. The code was refactored by this commit https://github.com/hibernate/hibernate-orm/commit/17de173cb5334d866f1886d3e057f49a6c987bad
Steve Ebersole October 28, 2015 at 3:24 AM
As part of verifying that this issue affects 5.0, please just set the "Affects version". Leave the "verify-affects-5.0" label and leave the issue in "Awaiting Response" status; these are critical for us to be able to track these verifications and triage them. Thanks.
Steve Ebersole October 27, 2015 at 7:16 PM
This bug report does not indicate that the reported issue affects version 5.x. Versions prior to 5.x are no longer maintained. It would be a great help to the Hibernate team and community for someone to verify that the reported issue still affects version 5.x. If so, please add the 5.x version that you verified with to the list of affected-versions and attach the (preferably SSCCE) test case you used to do the verification to the report; from there the issues will be looked at during our triage meetings.
For details, see http://in.relation.to/2015/10/27/great-jira-cleanup-2015/
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()