Annotation(二)――Hibernate中注解的开发(二)
2014-11-24 11:23:54
·
作者:
·
浏览: 1
rgType() {
return orgType;
}
public void setOrgType(OrgType orgType) {
this.orgType = orgType;
}
@ManyToOne
@JoinColumn(name="pid", updatable=false)
public Org getParentOrg() {
return parentOrg;
}
public void setParentOrg(Org parentOrg) {
this.parentOrg = parentOrg;
}
@OneToMany(mappedBy="parentOrg")
@JoinColumn(name="pid")
@OrderBy("code")
public Set
getChildOrgSet() { return childOrgSet; } public void setChildOrgSet(Set
childOrgSet) { this.childOrgSet = childOrgSet; } }
四,当然用了注解的开发方式,我们的核心配置文件就需要我修改了,这里就需要Hibernate的AnnotationSessionFactoryBean工厂类了,
com/ljh/ppp/domain
这样Hibernate框架的注解开发基本上就算完毕了,总体感觉是比较高效的。我们没写一个类一个方法,顺便将注解编写了,这样我们就不用专门用来编写映射文件了。掌握好注解的开发,在很多时候可以大大提高我们的效率。当然还有其它框架的注解运用,后边总结。