Hibernate返回空的persistentBag

时间:2015-12-04 09:39:58

标签: hibernate jpa

我通过以下代码得到一个空的persistentBag:

locList = quoteDataDO.getMemberDetailsDOs();

这就是我的DO在表格中的列的样子:

@OneToMany(mappedBy="quoteDataDO",cascade={javax.persistence.CascadeType.PERSIST}, fetch=FetchType.LAZY)
  @OrderBy("memberDetailsId")
  private List<MemberDetailsDO> memberDetailsDOs;

MemberDetailsDO.java:

@Entity
@Table(name="BHA_MEMBER_DETAIL")
public class MemberDetailsDO
  implements Serializable
{
  static final long serialVersionUID = 8675276594294793248L;
  @Column(name="MEMB_ASSURED")
  private Boolean memberAssured = Boolean.FALSE;
  @Temporal(TemporalType.DATE)
  @Column(name="MEMB_DOB")
  private Date dateOfBirth;
  @Column(name="MEMB_SAL")
  private Float salary;
  @Id
  @SequenceGenerator(name="BHA_MEMBER_DETAIL_MEMBDETID_GENERATOR", sequenceName="BHA_MEMBER_DETAIL_S")
  @GeneratedValue(strategy=GenerationType.AUTO, generator="BHA_MEMBER_DETAIL_MEMBDETID_GENERATOR")
  @Column(name="MEMB_DET_ID")
  private Long memberDetailsId;
  @Column(name="MEMB_GENDER")
  private String gender;
  @Column(name="MEMB_NI_NUM")
  private String niNumber;
  @Column(name="MEMB_OCCUP")
  private String occupation;
  @Column(name="MEMB_PCODE")
  private String postCode;
  @ManyToOne
  @JoinColumn(name="QUOTE_DETAILS_ID")
  private QuoteDetailsDO memberQuoteDetails;
  @Column(name="REQ_MEDICAL_UW")
  private Boolean requiresMedicalUW;
  @Column(name="MEMB_BENEFIT")
  private Integer memberBenefit;
  @Column(name="AGE_NEXT")
  private Integer ageNext;
  @Column(name="OCC_LOC_ADJ")
  private Float occLocAdj;
  @Column(name="UNADJUSTED_COST")
  private Float unadjustedCost;
  @Column(name="ADJUSTED_COST")
  private Float adjustedCost;
  @Column(name="MEMB_FINAL_COST")
  private Float memberFinalCost;
  @Transient
  private int hashValue = 0;
  @ManyToOne
  @JoinColumn(name="QUOTE_DATA_ID")
  private QuoteDataDO quoteDataDO;


  public boolean equals(Object obj)
  {
    boolean isEqual = false;
    if ((obj != null) && (this.memberDetailsId != null) && ((obj instanceof MemberDetailsDO))) {
      isEqual = this.memberDetailsId.equals(((MemberDetailsDO)obj).memberDetailsId);
    }
    return isEqual;
  }

  public int hashCode()
  {
    if (this.hashValue == 0) {
      this.hashValue = HashCodeBuilder.reflectionHashCode(this);
    }
    return this.hashValue;
  }

这是我的QuoteDataDo:

@Entity
@Table(name="BHA_QUOTE_DATA")
public class QuoteDataDO
  implements Serializable
{
  static final long serialVersionUID = 8607023248147303259L;
  @Column(name="EXIST_BENF_CHNG")
  private Boolean existingBenefitChange;
  @Column(name="LONG_TERM_ABS")
  private Boolean longTermAbsence;
  @Column(name="OVERSEAS_EMPS")
  private Boolean overseasEmployees;
  @Column(name="PREV_CLAIMS")
  private Boolean previousClaims;
  @Column(name="PREV_REFUSED")
  private Boolean previouslyRefused;
  @Column(name="REGIS_SCHEMA")
  private Boolean registeredSchema;
  @Column(name="QUOTE_DATE")
  private Date quoteDataDate;
  @Column(name="COMMISSION")
  private Integer commission;
  @Column(name="NUM_INSU_YEARS")
  private Integer numInsuredYears;
  @Column(name="NUM_LIVES")
  private Integer numLives;
  @Column(name="NUM_RECENT_CLAIMS")
  private Integer numRecentClaims;
  @Column(name="QUOTE_COMP_STEP")
  private Integer quoteCompletedStep;
  @OneToMany(mappedBy="quoteDataDO",cascade={javax.persistence.CascadeType.ALL}, fetch=FetchType.LAZY)
  @OrderBy("memberDetailsId")
  private List<MemberDetailsDO> memberDetailsDOs;
  @OneToMany(mappedBy="quoteDataDO",cascade={javax.persistence.CascadeType.ALL}, fetch=FetchType.LAZY)
  @OrderBy("quoteDetailsId")
  private List<QuoteDetailsDO> quoteDetailsDOs;
  @Id
  @SequenceGenerator(name="BHA_QUOTE_DATA_QUOTEDATAID_GENERATOR", sequenceName="BHA_QUOTE_DATA_S")
  @GeneratedValue(strategy=GenerationType.AUTO, generator="BHA_QUOTE_DATA_QUOTEDATAID_GENERATOR")
  @Column(name="QUOTE_DATA_ID")
  private Long quoteDataId;
  @ManyToOne
  @JoinColumn(name="PROD_ID")
  private ProductDO productDO;
  @OneToOne(mappedBy="quoteDataDO")
  @Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE})
  private QuoteDO quoteDO;
  @Column(name="HEAD_PO_CODE")
  private String headOfficePostCode;
  @Column(name="NAT_OF_BIS")
  private String natureOfBusiness;
  @Column(name="REDY_TO_QUOTE")
  private Boolean readyToQuote;
  @Column(name="SCHEMA_NAME")
  private String schemaName;
  @Column(name="UNDER_GROUP_ARRMNT")
  private String underGroupArragement;
  @ManyToOne
  @JoinColumn(name="USER_PROFILE_ID")
  private SystemUserProfileDO systemUserProfileDO;
  @Column(name="T_N_C_FLAG")
  private Boolean termsAndConditionsAgreed;
  @Column(name="EQUITY_PART_FLAG")
  private Boolean equityPartners;
  @Column(name="UNIT_RATE")
  private Float unitRate;
  @Column(name="PREMIUM_FREQUENCY")
  private String premiumFrequency;

  @Column(name="NEW_ENTRANTS")
  private Boolean newEntrants;

  @Column(name="ADDL_LOADING")
  private Boolean addlLoading;

  @Column(name="REASON_FOR_ABSENCE")
  private Integer causeList;

  @Column(name="LEVEL_OF_COVER")
  private String levelOfCover;

  @Column(name="RENEW_DATE")  
  private String renewDate;

  @Column(name="UNIT_RATE_SALARY")
  private Float unitRateBySalary;

}

因为这个我得到了NullPointerException,因为它是空的。请建议我是Hibernate的新手

0 个答案:

没有答案