Java 不成功:使用hibernate创建表

Java 不成功:使用hibernate创建表,java,spring,hibernate,Java,Spring,Hibernate,当我想在hibernate中创建一个新表时,会出现这个错误 SEVERE: Unsuccessful: create table gmail.messages.test (CODE_PERS varchar(255) not null, LAST_NAME varchar(255), FIRST_NAME varchar(255), primary key (CODE_PERS)) 3.8.2012 18:30: org.hibernate.tool.hbm2ddl.SchemaExport c

当我想在hibernate中创建一个新表时,会出现这个错误

SEVERE: Unsuccessful: create table gmail.messages.test (CODE_PERS varchar(255) not null, LAST_NAME varchar(255), FIRST_NAME varchar(255), primary key (CODE_PERS))
3.8.2012 18:30: org.hibernate.tool.hbm2ddl.SchemaExport create
SEVERE: 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 '.test (CODE_PERS varchar(255) not null, LAST_NAME varchar(255), FIRST_NAME varch' at line 1
3.8.2012 18:30: org.hibernate.tool.hbm2ddl.SchemaExport execute
这是我的hibernate.cfg文件

<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/gmail.messages</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">admin</property>
<!-- <property name="hbm2ddl.auto" value="auto"/> -->

<property name="hibernate.show_sql">true</property>
<property name="transaction.factory_class">
    org.hibernate.transaction.JTATransactionFactory
</property>
<property name="use_outer_join">false</property>
<property name="jta.UserTransaction">java:comp/UserTransaction</property>
<property name="hibernate.connection.pool_size">12</property>
<property name="hibernate.hbm2ddl.auto">create</property>
<property name="hibernate.default_schema">gmail.messages</property>
<property name="current_session_context_class">thread</property>

<mapping resource="HibernateMapping/hibernate.hbm.xml"/>
org.hibernate.dialogue.mysqldialogue
com.mysql.jdbc.Driver
jdbc:mysql://localhost:3306/gmail.messages
根
管理
真的
org.hibernate.transaction.JTATransactionFactory
假的
java:comp/UserTransaction
12
创造
gmail.messages
线

如堆栈跟踪所示,Hibernate捕获了MySQL数据库中的异常,因此请尝试直接在数据库中执行查询(直接调试要比通过框架调试容易得多)


如果您将表名中的点更改为下划线,您的查询将成功执行。

是否允许在表名中使用。(点)符号?我尝试了org.hibernate.dialent.mysql5dialent和hibernate.hbm2ddl.auto=“auto”/update,但仍然存在相同的错误,我建议只尝试使用简单的表名,类似于message_test而不是gmail.mes……你能发布完整的“create table”查询吗?是的,这就是不允许使用点的问题。谢谢你的建议。我创建了一个新的数据库,在具有相同属性的世界之间没有点,而且它可以工作。谢谢