Hibernate @NotFound 注解

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

你可能感兴趣的:(Hibernate @NotFound 注解)