org.springframework.beans.factory.BeanCreationException

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.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1076)[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:851)[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)[spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)[spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369)[spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)[spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185)[spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174)[spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE] at com.alledu.AllEduApplication.main(AllEduApplication.java:10)[bin/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[na:1.8.0_51] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[na:1.8.0_51] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[na:1.8.0_51] at java.lang.reflect.Method.invoke(Method.java:497)[na:1.8.0_51] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)[spring-boot-devtools-1.4.0.RELEASE.jar:1.4.0.RELEASE] Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:954)[hibernate-entitymanager-5.0.9.Final.jar:5.0.9.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:882)[hibernate-entitymanager-5.0.9.Final.jar:5.0.9.Final] at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60)[spring-orm-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:338)[spring-orm-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:373)[spring-orm-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:362)[spring-orm-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE] ... 21 more Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Unable to execute schema management to JDBC target [create table option (id bigint not null auto_increment, value varchar(255), poll_id bigint, primary key (id))] at org.hibernate.tool.schema.internal.TargetDatabaseImpl.accept(TargetDatabaseImpl.java:59)[hibernate-core-5.0.9.Final.jar:5.0.9.Final] at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlString(SchemaMigratorImpl.java:431)[hibernate-core-5.0.9.Final.jar:5.0.9.Final] at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlStrings(SchemaMigratorImpl.java:420)[hibernate-core-5.0.9.Final.jar:5.0.9.Final] at org.hibernate.tool.schema.internal.SchemaMigratorImpl.createTable(SchemaMigratorImpl.java:236)[hibernate-core-5.0.9.Final.jar:5.0.9.Final] at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigrationToTargets(SchemaMigratorImpl.java:167)[hibernate-core-5.0.9.Final.jar:5.0.9.Final] at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:60)[hibernate-core-5.0.9.Final.jar:5.0.9.Final] at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:134)[hibernate-core-5.0.9.Final.jar:5.0.9.Final] at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:101)[hibernate-core-5.0.9.Final.jar:5.0.9.Final] at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:470)[hibernate-core-5.0.9.Final.jar:5.0.9.Final] at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444)[hibernate-core-5.0.9.Final.jar:5.0.9.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879)[hibernate-entitymanager-5.0.9.Final.jar:5.0.9.Final] ... 27 more Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'option (id bigint not null auto_increment, value varchar(255), poll_id bigint, p' at line 1 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[na:1.8.0_51] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)[na:1.8.0_51] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[na:1.8.0_51] at java.lang.reflect.Constructor.newInstance(Constructor.java:422)[na:1.8.0_51] at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)[mysql-connector-java-5.1.39.jar:5.1.39] at com.mysql.jdbc.Util.getInstance(Util.java:387)[mysql-connector-java-5.1.39.jar:5.1.39] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:942)[mysql-connector-java-5.1.39.jar:5.1.39] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3966)[mysql-connector-java-5.1.39.jar:5.1.39] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3902)[mysql-connector-java-5.1.39.jar:5.1.39] at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2526)[mysql-connector-java-5.1.39.jar:5.1.39] at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2673)[mysql-connector-java-5.1.39.jar:5.1.39] at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2545)[mysql-connector-java-5.1.39.jar:5.1.39] at com.mysql.jdbc.StatementImpl.executeUpdateInternal(StatementImpl.java:1540)[mysql-connector-java-5.1.39.jar:5.1.39] at com.mysql.jdbc.StatementImpl.executeLargeUpdate(StatementImpl.java:2595)[mysql-connector-java-5.1.39.jar:5.1.39] at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1468)[mysql-connector-java-5.1.39.jar:5.1.39] at org.hibernate.tool.schema.internal.TargetDatabaseImpl.accept(TargetDatabaseImpl.java:56)[hibernate-core-5.0.9.Final.jar:5.0.9.Final] ... 37 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