我有一堂课Persoon:
@Entity
@Table(name = "persoon")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "Type")
public class Persoon implements Serializable {
private static final long serialVersionUID = 1L;
protected Persoon() {
}
protected Persoon(String naam, String voornaam, String mail) {
setNaam(naam);
setVoornaam(voornaam);
setEmail(mail);
}
private final StringProperty naam = new SimpleStringProperty();
@Column(name = "Naam")
public String getNaam() {
return naam.get();
}
public void setNaam(String value) {
naam.set(value);
}
public StringProperty naamProperty() {
return naam;
}
@Column(name = "Voornaam")
public String getVoornaam() {
return voornaam.get();
}
public void setVoornaam(String value) {
voornaam.set(value);
}
public StringProperty voornaamProperty() {
return voornaam;
}
private final StringProperty email = new SimpleStringProperty();
@Id
@Column(name = "Email")
public String getEmail() {
return email.get();
}
public void setEmail(String value) {
email.set(value);
}
public StringProperty emailProperty() {
return email;
}
...
其中有一个子类JobCoach:
@Entity
@DiscriminatorValue("JobCoach")
@Access(AccessType.PROPERTY)
public class JobCoach extends Persoon implements Serializable {
private final StringProperty organisatie = new SimpleStringProperty();
@Column(name = "NaamBedrijf")
public String getOrganisatie() {
return organisatie.get();
}
public void setOrganisatie(String value) {
organisatie.set(value);
}
public StringProperty organisatieProperty() {
return organisatie;
}
...
这完美映射但是当我在netbeans中运行JPQL时(右键单击persistence.xml),它返回0结果。
我的架构中的'persoon'表但确实有一行:
我的错误在哪里?
从persoon p中选择p WHERE p.Type =“JobCoach”也不会工作。
答案 0 :(得分:0)
使用select p from Persoon p WHERE .....
JPA引用实体类名而不是表名。