JPA @Embedded注释在netbeans中标记为错误

时间:2013-01-27 09:59:21

标签: hibernate jpa hibernate-annotations

在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 [],枚举或任何Serializable类型。嵌入式

请注意以下课程

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;
    }
}

1 个答案:

答案 0 :(得分:0)

问题是netbeans中的一个错误

netbeans issues

和解决方案我必须实现可序列化的接口,错误消失了。