Annotations 一对多与多对一

个人觉得写Annotation并不比XML难写,并且可以开发时写Annotation,部署后用XML.
子类:
	@ManyToOne (optional=true, fetch = FetchType.LAZY)
	@JoinColumn(name="P_ID", nullable=true, insertable = false, updatable = false)
	protected SAttribute sAttb;

父类:
	@OneToMany(cascade = CascadeType.REFRESH, mappedBy = "sAttb", fetch = FetchType.LAZY)
	protected Set<Child> child;

注意其中mappedBy是对应的.

你可能感兴趣的:(xml)