在many-to-one
, one-to-one
, 关系中,一方引入另一方的属性,如果引用属性值数据在数据库中不见,hibernate默认会抛出异常,解决此问题,加@NotFound
注解即可.@notFound
注解默认值为NotFoundAction.EXCEPTION
@ManyToOne
@JoinColumn(name="area_id")
@NotFound(action = NotFoundAction.IGNORE)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public Area getArea() {
return area;
}