我是Java EE的新手,正在尝试实现Hibernate JPA关系,但是未创建付款表之一并抛出以下错误,但是联接表存在:
GenerationTarget encountered exception accepting command : Error executing DDL "create table payments (reference varchar(255) not null, Status Pending, ThirdPartyReference varchar(255) not null, amount double precision not null, dateCompleted date, dateCreated date not null, description varchar(255), dueDate date, payer_PhoneNumber varchar(12) not null, specialReference varchar(14) not null, acctount_id bigint, primary key (reference)) engine=InnoDB" via JDBC Statement
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL
贝娄(Bellow)提供了付款课程的详细信息:
package Organization.Core.Gateway.entities;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.time.LocalDate;
@Entity (name= "payments")
public class Payment {
public Account getServiceProvider() {
return ServiceProvider;
}
public void setServiceProvider(Account serviceProvider) {
ServiceProvider = serviceProvider;
}
public double getAmount() {
return amount;
}
public void setAmount(double amount) {
this.amount = amount;
}
public String getThirdPartyReference() {
return ThirdPartyReference;
}
public void setThirdPartyReference(String thirdPartyReference) {
ThirdPartyReference = thirdPartyReference;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getSpecialReference() {
return specialReference;
}
public void setSpecialReference(String specialReference) {
this.specialReference = specialReference;
}
public String getStatus() {
return Status;
}
public void setStatus(String status) {
Status = status;
}
public String getPayer_PhoneNumber() {
return payer_PhoneNumber;
}
public void setPayer_PhoneNumber(String MSISDN) {
this.payer_PhoneNumber = MSISDN;
}
public LocalDate getDateCreated() {
return dateCreated;
}
public void setDateCreated(LocalDate dateCreated) {
this.dateCreated = dateCreated;
}
public LocalDate getDateCompleted() {
return dateCompleted;
}
public void setDateCompleted(LocalDate dateCompleted) {
this.dateCompleted = dateCompleted;
}
public LocalDate getDueDate() {
return dueDate;
}
public void setDueDate(LocalDate dueDate) {
this.dueDate = dueDate;
}
@OneToOne(targetEntity = Account.class, cascade = CascadeType.ALL)
@JoinColumn(name = "acctount_id", referencedColumnName = "Id")
private Account ServiceProvider;
private double amount;
@Column(unique = true, nullable = false)
private String ThirdPartyReference;
@Id
//@GeneratedValue(strategy = GenerationType.AUTO)
//@SequenceGenerator(name = "reference_generator", sequenceName = "PAY", allocationSize = 15)
private String reference;
private String description;
@Column(nullable = false, length = 14)
private String specialReference;
@Column(columnDefinition = "Pending")
private String Status;
@Column(nullable = false,length =12)
private String payer_PhoneNumber;
@Column(nullable = false)
private LocalDate dateCreated;
private LocalDate dateCompleted;
private LocalDate dueDate;
}
比帐户明细:
package Organization.Core.Gateway.entities;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Set;
@Entity( name = "accounts")
@Inheritance(strategy = InheritanceType.JOINED)
public class Account {
@Override
public String toString() {
return "Account{" +
"Id=" + Id +
", FirstName='" + FirstName + '\'' +
", Surname='" + Surname + '\'' +
", Payments=" + Payments +
'}';
}
public Long getId() {
return Id;
}
public void setId(Long id) {
Id = id;
}
public String getFirstName() {
return FirstName;
}
public void setFirstName(String firstName) {
FirstName = firstName;
}
public String getSurname() {
return Surname;
}
public void setSurname(String surname) {
Surname = surname;
}
public Set getPayments() {
return Payments;
}
public void setPayments(Set payments) {
Payments = payments;
}
@javax.persistence.Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long Id;
@NotNull
private String FirstName;
@NotNull
private String Surname;
@OneToMany(targetEntity = Payment.class, fetch = FetchType.LAZY)
private Set Payments;
}
最后是我要访问的商家帐户:
package Organization.Core.Gateway.entities;
import javax.persistence.Column;
import javax.persistence.Entity;
@Entity(name = "merchants")
public class Merchant extends Account{
public int getMpesa_ServiceproviderCode() {
return mpesa_ServiceproviderCode;
}
public void setMpesa_ServiceproviderCode(int mpesa_ServiceproviderCode) {
this.mpesa_ServiceproviderCode = mpesa_ServiceproviderCode;
}
public String getOrganizationName() {
return organizationName;
}
public void setOrganizationName(String organizationName) {
this.organizationName = organizationName;
}
@Column(name = "providershortCode")
private int mpesa_ServiceproviderCode;
@Override
public String toString() {
return "Merchant{" +
"mpesa_ServiceproviderCode=" + mpesa_ServiceproviderCode +
", organizationName='" + organizationName + '\'' +
'}';
}
private String organizationName;
}
持久性文件详细信息
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">
org.hibernate.jpa.HibernatePersistenceProvider
PS:我读了一些我试图更改方言的文章,因为我使用的是mariadb,甚至在这里也查看了文章。