0
我有一個類Persoon:JPA繼承映射沒有給出錯誤,但JPQL查詢不給任何結果
@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」也無法工作。
哦,那是我的問題中的一個錯字。從Persoon中選擇p返回0結果是我的問題。 – wimdetr