org.hibernate.tool.schema.spi.SchemaManagementException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • I have a Mysql duplicate column name exception after moving to Hibernate 5 from 4 when HBM2DDL_AUTO is set to "update". It seems to cause exceptions with various combination of mixed case column name (with @Column for example) and on linux (case sensitive) but not on Windows. I have this made up code to test one particular case. {code:java} import java.sql.SQLException; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.cfg.Environment; import org.hibernate.tool.hbm2ddl.SchemaUpdate; import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; @Entity class My { @Id public int getId() { return 0; } @Column(name="Ul") public int getValue() { return 0; } public void setId(final int _id) { } public void setValue(int value) { } } public class Test { public static void main(String[] args) throws SQLException { MysqlDataSource ds = new MysqlDataSource(); ds.setUrl("jdbc:mysql://192.168.1.6/test2?user=root"); new SchemaUpdate((MetadataImplementor) new MetadataSources(new StandardServiceRegistryBuilder() .applySetting(Environment.DATASOURCE, ds).build()) .addAnnotatedClass( My.class ) .buildMetadata()).execute(true, true); } } {code} Output on run with no existing table {noformat} create table My (id integer not null, Ul integer, primary key (id)) {noformat} Output on run with existing table {code:java} alter table My add column Ul integer Exception in thread "main" org.hibernate.tool.schema.spi.SchemaManagementException: Unable to execute schema management to JDBC target [alter table My add column Ul integer] at org.hibernate.tool.schema.internal.TargetDatabaseImpl.accept(TargetDatabaseImpl.java:58) at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlString(SchemaMigratorImpl.java:332) at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlStrings(SchemaMigratorImpl.java:350) at org.hibernate.tool.schema.internal.SchemaMigratorImpl.migrateTable(SchemaMigratorImpl.java:159) at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigrationToTargets(SchemaMigratorImpl.java:101) at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:59) at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:129) at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:97) at Test.main(Test.java:41) Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Duplicate column name 'Ul' at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:422) at com.mysql.jdbc.Util.handleNewInstance(Util.java:389) at com.mysql.jdbc.Util.getInstance(Util.java:372) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:980) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3835) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3771) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2435) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2582) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2531) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1618) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1549) at org.hibernate.tool.schema.internal.TargetDatabaseImpl.accept(TargetDatabaseImpl.java:55) ... 8 more {code}
    via by Trong Dinh,
  • I have a Mysql duplicate column name exception after moving to Hibernate 5 from 4 when HBM2DDL_AUTO is set to "update". It seems to cause exceptions with various combination of mixed case column name (with @Column for example) and on linux (case sensitive) but not on Windows. I have this made up code to test one particular case. {code:java} import java.sql.SQLException; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.cfg.Environment; import org.hibernate.tool.hbm2ddl.SchemaUpdate; import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; @Entity class My { @Id public int getId() { return 0; } @Column(name="Ul") public int getValue() { return 0; } public void setId(final int _id) { } public void setValue(int value) { } } public class Test { public static void main(String[] args) throws SQLException { MysqlDataSource ds = new MysqlDataSource(); ds.setUrl("jdbc:mysql://192.168.1.6/test2?user=root"); new SchemaUpdate((MetadataImplementor) new MetadataSources(new StandardServiceRegistryBuilder() .applySetting(Environment.DATASOURCE, ds).build()) .addAnnotatedClass( My.class ) .buildMetadata()).execute(true, true); } } {code} Output on run with no existing table {noformat} create table My (id integer not null, Ul integer, primary key (id)) {noformat} Output on run with existing table {code:java} alter table My add column Ul integer Exception in thread "main" org.hibernate.tool.schema.spi.SchemaManagementException: Unable to execute schema management to JDBC target [alter table My add column Ul integer] at org.hibernate.tool.schema.internal.TargetDatabaseImpl.accept(TargetDatabaseImpl.java:58) at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlString(SchemaMigratorImpl.java:332) at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlStrings(SchemaMigratorImpl.java:350) at org.hibernate.tool.schema.internal.SchemaMigratorImpl.migrateTable(SchemaMigratorImpl.java:159) at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigrationToTargets(SchemaMigratorImpl.java:101) at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:59) at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:129) at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:97) at Test.main(Test.java:41) Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Duplicate column name 'Ul' at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:422) at com.mysql.jdbc.Util.handleNewInstance(Util.java:389) at com.mysql.jdbc.Util.getInstance(Util.java:372) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:980) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3835) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3771) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2435) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2582) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2531) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1618) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1549) at org.hibernate.tool.schema.internal.TargetDatabaseImpl.accept(TargetDatabaseImpl.java:55) ... 8 more {code}
    via by Trong Dinh,
  • Drop table in mysql Database with java
    via Stack Overflow by Ernanirst
    ,
    • org.hibernate.tool.schema.spi.SchemaManagementException: Unable to execute schema management to JDBC target [alter table My add column Ul integer] at org.hibernate.tool.schema.internal.TargetDatabaseImpl.accept(TargetDatabaseImpl.java:58) at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlString(SchemaMigratorImpl.java:332) at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlStrings(SchemaMigratorImpl.java:350) at org.hibernate.tool.schema.internal.SchemaMigratorImpl.migrateTable(SchemaMigratorImpl.java:159) at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigrationToTargets(SchemaMigratorImpl.java:101) at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:59) at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:129) at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:97) at Test.main(Test.java:41) Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Duplicate column name 'Ul' at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:422) at com.mysql.jdbc.Util.handleNewInstance(Util.java:389) at com.mysql.jdbc.Util.getInstance(Util.java:372) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:980) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3835) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3771) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2435) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2582) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2531) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1618) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1549) at org.hibernate.tool.schema.internal.TargetDatabaseImpl.accept(TargetDatabaseImpl.java:55) ... 8 more

    Users with the same issue

    rocday
    2 times, last one,
    Kialandei
    9 times, last one,
    jshakil
    23 times, last one,
    mortalman7
    1 times, last one,
    Unknown visitor1 times, last one,
    115 more bugmates