【发布时间】:2018-05-25 11:55:24
【问题描述】:
我有一个问题一直在努力解决,但我无处可去。
我正在使用 JPA Hibernate 创建表,但他没有创建表,而是向我显示了错误:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 表‘escola.tab_alunos’不存在
这是我的 persistence.xml:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version=“2.0”>
<persistence-unit name="banco" transaction-type="RESOURCE_LOCAL">
<description>
Persistence unit for the JPA tutorial of the Hibernate Getting Started Guide
</description>
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>org.halyph.sessiondemo.Event</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/escola" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="0000" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>
</persistence-unit>
这是 Aluno 类:
@Entity
@Table(name=“TAB_ALUNOS”)
@SequenceGenerator(name=“TAB_ALUNOS_PK”, sequenceName=“SEQ_ALUNOS_PK”, allocationSize=1)
public class Aluno {
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="TAB_ALUNOS_PK")
private Long id;
@Column(length=10, nullable=false)
private String matricula;
@Column(length=100, nullable=false)
private String nome;
@Column(length=9 ,nullable=false)
private String sexo;
@Column(name="DATA_NASCIMENTO", length=10, nullable=false)
private String dataNascimento;
@Column(length=30, columnDefinition="DEFAULT 'Ativo'")
private String situacao;
// ....
}
知道如何解决这个问题吗?
仅作记录,我第一次启动该项目时,它工作得很好,但由于我犯了一个错误,我不得不删除表,之后休眠停止创建表,现在我可以'什么都不做
【问题讨论】: