【问题标题】:JPA @Embedded annotation flagged as error In netbeansJPA @Embedded 注释在 netbeans 中标记为错误
【发布时间】:2013-01-27 17:59:21
【问题描述】:

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

【问题讨论】:

    标签: hibernate jpa hibernate-annotations


    【解决方案1】:

    问题是 netbeans 中的一个错误

    netbeans issues

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多