你好,我正在尝试使用JBoss Hibernate工具进行逆向工程。我正在使用来自eclipse市场的eclipse luna和最新的hibernate jboss工具。当我试图配置hibernate工具配置时,在配置完成后,当我展开树并展开database节点时,它会生成以下错误:
<Reading Schema Error: Could not get list of suggested identity strategies from database. Probably a JDBC Driver Problem>堆栈跟踪:
org.hibernate.exception.SQLGrammarException: Could not get list of suggested identity strategies from database. Probably a JDBC driver problem.
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
at org.hibernate.cfg.reveng.dialect.MySQLMetaDataDialect.getSuggestedPrimaryKeyStrategyName(MySQLMetaDataDialect.java:55)
at org.hibernate.cfg.reveng.JDBCReader.processPrimaryKey(JDBCReader.java:429)
at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:86)
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter$2.execute(LazyDatabaseSchemaWorkbenchAdapter.java:126)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:63)
at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:107)
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.readDatabaseSchema(LazyDatabaseSchemaWorkbenchAdapter.java:115)
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.getChildren(LazyDatabaseSchemaWorkbenchAdapter.java:65)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:106)
at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:238)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
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 '-empirecl-test like 'oauth_access_token'' 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:408)
at com.mysql.jdbc.Util.getInstance(Util.java:383)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1062)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4226)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4158)我与eclipse的数据库连接是成功构建的,因为在eclipse Database explore的帮助下,成功地建立了连接,并显示了所有表。我正在使用Hibernate 4.3和最新的MySQL driver 5.1.31。下面是我的配置的屏幕截图。


以下是我的hibernate.cfg.xml文件:
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/nit-empirecl-test</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
</session-factory>
</hibernate-configuration>发布于 2014-08-01 03:46:22
我找到了解决方案,问题在于数据库名。我不知道,但是hibernate jboss工具,在数据库名上不支持( - )连字符。当我用下划线更改名称时,配置将成功运行。
发布于 2014-12-27 10:35:59
您应该设置hibernate默认架构(用于sql server)。
<property name="hibernate.default_schema">dbo</property>发布于 2014-12-11 11:44:52
我也有同样的问题,但在和数据库名称中没有"-“。您可以尝试设置“可选”属性hibernate.default_schema。
https://stackoverflow.com/questions/24995598
复制相似问题