休眠从实体生成表不起作用



我在从实体生成表时遇到问题。我在Mac OSX上使用Eclipse Photon,我已经成功地与本地PostgreSQL数据库建立了连接,并成功地测试了正确的ping。

现在的问题是,当我点击"JPATools->GenerateTablesForEntities"时,Eclipse什么也不做。没有这样的错误信息,没有任何类型的信号。

我已经映射了我的实体,我在下面附上一些例子。

AccessDataEntity.java

@Entity
@Table(name = "access_data")
public class AccessDataEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
private long id;
@Column(name = "password", length = 15)
private String password;
@OneToOne
private PersonalInformationEntity personalInformation;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public PersonalInformationEntity getPersonalInformation() {
return personalInformation;
}
public void setPersonalInformation(PersonalInformationEntity personalInformation) {
this.personalInformation = personalInformation;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
}

个人信息实体.java

@Entity
@Table(name = "personal_information")
public class PersonalInformationEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name = "id")
private long id;
@Column(name = "name", length = 30)
private String name;
@Column(name = "surname", length = 30)
private String surname;
@Column(name = "email", length = 20)
private String email;
@Column(name = "date_of_birth")
private Date dateOfBirth;
@OneToOne(mappedBy = "personalInformation", cascade = CascadeType.ALL, fetch = FetchType.LAZY, optional = false)
private AccountEntity account;
@OneToMany(mappedBy = "personalInformation", fetch = FetchType.LAZY)
private List<PersonalGoalEntity> personalGoals;
@OneToOne(mappedBy = "personalInformation", fetch = FetchType.LAZY)
private AccessDataEntity accessData;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Date getDateOfBirth() {
return dateOfBirth;
}
public void setDateOfBirth(Date dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
public AccountEntity getAccount() {
return account;
}
public void setAccount(AccountEntity account) {
this.account = account;
}
public List<PersonalGoalEntity> getPersonalGoals() {
return personalGoals;
}
public void setPersonalGoals(List<PersonalGoalEntity> personalGoals) {
this.personalGoals = personalGoals;
}
}

我还配置了persistence.xml文件。

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="aster.jpa">
<class>it.manuelgozzi.aster.jpa.entity.AccessDataEntity</class>
<class>it.manuelgozzi.aster.jpa.entity.AccountEntity</class>
<class>it.manuelgozzi.aster.jpa.entity.MovementEntity</class>
<class>it.manuelgozzi.aster.jpa.entity.MovementGroupEntity</class>
<class>it.manuelgozzi.aster.jpa.entity.PersonalGoalEntity</class>
<class>it.manuelgozzi.aster.jpa.entity.PersonalInformationEntity</class>
<properties>
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
<!-- <property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
<property name="hibernate.connection.url" value="jdbc:postgresql://localhost:3306/aster"/>
<property name="hibernate.connection.password" value="postgres"/>
<property name="hibernate.connection.username" value="1234"/> -->
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:3306/aster"/>
<property name="javax.persistence.jdbc.user" value="postgres"/>
<property name="javax.persistence.jdbc.password" value="1234"/>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
</properties>
</persistence-unit>
</persistence>

我错过了什么?我测试了与数据库的连接,看起来还可以,在测试ping时没有出现这样的错误。我不明白为什么我什么都没看到。

我设置了我的连接配置文件,目标是休眠JPA 2.1

我终于成功了。

我忘记在pom.xml中插入hibernate依赖项。完成后,我配置了一个hibernate控制台并重试。

现在一切都很好,我错过了最重要的一点。。。

最新更新