SpringSide开发实战(四):打通数据持久层的任督二脉 - 编程入门网
private String name;
private User creator;
private Date createTime;
private String isDeleted;
private List < User > users;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getId() {
return id;
}
public void setId(Integer id) {
this .id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this .name = name;
}
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
@JoinColumn(name = " creatorid " )
public User getCreator() {
return creator;
}
public void setCreator(User creator) {
this .creator = creator;
}
@Column(name = " createtime " ,insertable = false )
@Temporal(TemporalType.TIMESTAMP)
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this .createTime = createTime;
}
@Column(name = " isdeleted " ,insertable = false )
public String getIsDeleted() {
return isDeleted;
}
public void setIsDeleted(String isDeleted) {
this .isDeleted = isDeleted;
}
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE} ,
mappedBy = " groups " ,
targetEntity = User. class )
public List < User > getUsers() {
return users;
}
public void setUsers(List < User > users) {
this .users = users;
}
}
SpringSide开发实战(四):打通数据持久层的任督二脉(6)时间:2011-05-07 blogjava 海边沫沫好了,该开始测试了,看看经过前面设计和配置的代码能否正常工作。首先,先创建三 个Manager,这三个Manager都继承自 org.springside.core.dao.extend.HibernateEntityExtendDao,至于 HibernateEntityExtendDao的功能,请参考SpringSide的文档。代码如下:
下一步,将User.class、Role.class、Group.class等领域对象添加到src\main\resources\config\hibernate.cfg.xml中,如下:
|
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |