Hibernate @NotFound

@NotFound(action = NotFoundAction.IGNORE)

底层是用了外连接实现的
 
@ManyToOne(fetch = FetchType.EAGER) 
@JoinColumn(name = "copyrightid", referencedColumnName = "id", insertable = false, updatable = false, unique = true) 
@NotFound(action = NotFoundAction.IGNORE)
 @IndexedEmbedded(prefix = "copyright_", depth = 1) 
private Copyright copyright = new Copyright(); 

public Copyright getCopyright() { 
return copyright; 
} 

public void setCopyright(Copyright copyright) { 
this.copyright = copyright; 
} 

如果Copyright 数据被删掉,会正确返回null,不会导致运行时错误

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