Hibernate @NotFound 注解

2016-10-07  本文已影响305人  liveaswind

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;
}
上一篇下一篇

猜你喜欢

热点阅读