所以我正在编写一个由研究人员组成的平台(荷兰语为'onderzoeker')。研究人员继承自Role,因为他们需要能够使用Spring安全性登录。遗漏了所有的吸气剂和制定者,但他们在那里!在此先感谢:)
ERROR
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'onderzoeke0_.onderzoekerid' in 'field list'
Class Onderzoeker
Class onderzoeker
@SuppressWarnings("serial")
@Entity
@DiscriminatorValue(value = "Onderzoeker")
public class Onderzoeker extends Rol {
@Column(name="onderzoekerid")
private int onderzoekerid;
@Column(name="onderzoekernaam")
protected String onderzoekernaam;
@Column(name="onderzoekervoornaam")
protected String onderzoekervoornaam;
@ManyToOne
@JoinColumn(name="onderzoekerteamid")
protected Team team;
@Override
public String getType() {
return "Onderzoeker";
}
}
Onderzoeker继承的类角色
package be.odisee.oxyplast.domain;
@DiscriminatorOptions(force=true)
@Entity
@Table(name="rollen")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE )
@DiscriminatorColumn(name="type",
discriminatorType=DiscriminatorType.STRING)
@DiscriminatorValue("Rol")
public abstract class Rol implements Serializable {
@Id
@Column(name="id")
@GeneratedValue(strategy=GenerationType.AUTO)
protected int id;
@Column
protected String status;
@Column(unique=true)
@Index(name="IRol_usernaam",columnNames="usernaam")
protected String usernaam;
@ManyToOne
@JoinColumn(name="sessie_id")
protected Sessie sessie;
@ManyToOne
@JoinColumn(name="persoon_id")
protected Persoon persoon;
public Rol(){}
public Rol(String status, String usernaam, Sessie sessie, Persoon persoon) {
this.status = status;
this.usernaam = usernaam;
this.sessie = sessie;
this.persoon = persoon;
}
public Rol(int id, String status, String usernaam, Sessie sessie, Persoon persoon) {
this.id = id;
this.status = status;
this.usernaam = usernaam;
this.sessie = sessie;
this.persoon = persoon;
}
这需要足够解决问题。是的,数据库是正确的,它需要是其他东西
答案 0 :(得分:0)
我有同样的问题,我最终发现父母和孩子班都需要公开 默认的构造函数!
父班:
@MappedSuperclass
public abstract class Order {
public Order() {
}
}
子类:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Table(name="ItemOrder")
public class ItemOrder extends Order {
public ItemOrder() throws Exception {
super();
}
我希望这个答案对某人有帮助。