在many-to-one
, one-to-one
, 關系中,一方引入另一方的屬性改化,如果引用屬性值數(shù)據(jù)在數(shù)據(jù)庫中不見掩蛤,hibernate默認會拋出異常,解決此問題陈肛,加@NotFound
注解即可.@notFound
注解默認值為NotFoundAction.EXCEPTION
@ManyToOne
@JoinColumn(name="area_id")
@NotFound(action = NotFoundAction.IGNORE)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public Area getArea() {
return area;
}