在 NETBEANS 中
错误显示在第2行:
@Embedded
public SchoolDetails getSchoolDetails() {
return schoolDetails;
}
基本属性只能是以下类型:Java 原始类型、原始类型的包装器、String、java.math.BigInteger、java.math.BigDecimal、java.util.Date、java.util.Calendar、java.sql.Date 、java.sql.Time、java.sql.TimeStamp、byte[]、Byte[]、char[]、Character[]、枚举或任何可序列化类型。嵌入
请注意,类如下
package com.chapter3;
import java.io.Serializable;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity
public class School {
private int schoolId;
private String schooleName;
private SchoolDetails schoolDetails;
@Embedded
public SchoolDetails getSchoolDetails() {
return schoolDetails;
}
public void setSchoolDetails(SchoolDetails schoolDetails) {
this.schoolDetails = schoolDetails;
}
@Id
@GeneratedValue
public int getSchoolId() {
return schoolId;
}
public void setSchoolId(int schoolId) {
this.schoolId = schoolId;
}
public String getSchooleName() {
return schooleName;
}
public void setSchooleName(String schooleName) {
this.schooleName = schooleName;
}
}
package com.chapter3;
import javax.persistence.Embeddable;
@Embeddable
public class SchoolDetails {
private String schoolAddress;
private boolean isPublicSchool;
private int studentCount;
public boolean isIsPublicSchool() {
return isPublicSchool;
}
public void setIsPublicSchool(boolean isPublicSchool) {
this.isPublicSchool = isPublicSchool;
}
public String getSchoolAddress() {
return schoolAddress;
}
public void setSchoolAddress(String schoolAddress) {
this.schoolAddress = schoolAddress;
}
public int getStudentCount() {
return studentCount;
}
public void setStudentCount(int studentCount) {
this.studentCount = studentCount;
}
}