打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
org.hibernate.tool.schema.spi.SchemaManagementException Unable to execute schema management to 异常的解决

org.hibernate.tool.schema.spi.SchemaManagementException Unable to execute schema management to JDBC target 异常的解决

今天写了个简单的多对多关系,测试运行后,报了一个异常,多方检查配置文件,并没什么明显的错误,很是苦恼。

org.hibernate.tool.schema.spi.SchemaManagementException: Unable to execute schema management to JDBC target [create table sys_role (role_id bigint not null auto_increment, role_name varchar(255), role_memo varchar(255), primary key (role_id)) type=InnoDB]    	at org.hibernate.tool.schema.internal.TargetDatabaseImpl.accept(TargetDatabaseImpl.java:59)    	at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlString(SchemaMigratorImpl.java:431)    	at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlStrings(SchemaMigratorImpl.java:420)    	at org.hibernate.tool.schema.internal.SchemaMigratorImpl.createTable(SchemaMigratorImpl.java:236)    	at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigrationToTargets(SchemaMigratorImpl.java:167)    	at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:60)    	at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:133)    	at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:101)    	at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:470)    	at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444)    	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:708)    	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)    	at cn.cigar.many2many.Demo.function(Demo.java:21)    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)    	at java.lang.reflect.Method.invoke(Unknown Source)    	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)    	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)    	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)    	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)    	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)    	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)    	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)    	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)    	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)    	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)    	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)    	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)    	at org.junit.runner.JUnitCore.run(JUnitCore.java:115)    	at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:39)    	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source)    	at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)    	at java.util.Iterator.forEachRemaining(Unknown Source)    	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source)    	at java.util.stream.AbstractPipeline.copyInto(Unknown Source)    	at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)    	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source)    	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source)    	at java.util.stream.AbstractPipeline.evaluate(Unknown Source)    	at java.util.stream.ReferencePipeline.forEach(Unknown Source)    	at org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:79)    	at org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:70)    	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:170)    	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:154)    	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90)    	at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:86)    	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)    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 'type=InnoDB' at line 1    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)    	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)    	at java.lang.reflect.Constructor.newInstance(Unknown Source)    	at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)    	at com.mysql.jdbc.Util.getInstance(Util.java:381)    	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030)    	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)    	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3515)    	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3447)    	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1951)    	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2101)    	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2548)    	at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1605)    	at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1524)    	at org.hibernate.tool.schema.internal.TargetDatabaseImpl.accept(TargetDatabaseImpl.java:56)    	... 53 more

后来多方百度,有说是可能和数据库方言版本有关,尝试着修改了数据库方言的版本,再运行,居然测试成功。

原来的方言配置:

<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>

修改后的方言配置:

<property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>

修改后就大功告成。

来源:http://www.icode9.com/content-4-51701.html
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
利用junit对springMVC的Controller进行测试
java.lang.IllegalArgumentException
MyBatis Batch Update Exception
hibernate4 二级缓存demo实例
LogBack简易教程
Spring实战——通过Java代码装配bean
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服