Hibernate Wicket多复选框问题
我是wicket hibernate开发的新手。我有下面的场景,但我不确定如何通过wicket实现它 我有一个角色表,其中包含以下值 角色 ID描述 1买方 2通知程序 3电子邮件收件人 我有一个PersonRelation表,其中包含以下详细信息 人际关系 身份证持有人 1112 2113 这里的people是一个外键,它引用people表。peoplerelation和角色表之间存在多对多关系 wicket表单在前端包含“角色表描述”作为复选框。每当用户单击复选框时,应相应地更新多对多关系表。请让我知道如何通过wicket spring hibernate实现它。感谢您帮助解决此问题 PFA是hibernate类的代码Hibernate Wicket多复选框问题,hibernate,wicket,Hibernate,Wicket,我是wicket hibernate开发的新手。我有下面的场景,但我不确定如何通过wicket实现它 我有一个角色表,其中包含以下值 角色 ID描述 1买方 2通知程序 3电子邮件收件人 我有一个PersonRelation表,其中包含以下详细信息 人际关系 身份证持有人 1112 2113 这里的people是一个外键,它引用people表。peoplerelation和角色表之间存在多对多关系 wicket表单在前端包含“角色表描述”作为复选框。每当用户单击复选框时,应相应地更新多对多关系表
@实体
公共类PeopleRelation实现了DaoFunPortalObject{
@身份证
@生成值
@列(name=“peoplerelationship\u id”)
私人长id;
@多通(级联=级联类型.ALL)
@JoinColumn(name=“People”)
私人;
@列(name=“relationship”)
私有字符串关系;
@ManyToMany(cascade=CascadeType.PERSIST)
@可接合(
name=“peoplerelationship\u角色”,
joinColumns={@JoinColumn(name=“peopleRelationship_id”)},
inverseJoinColumns={@JoinColumn(name=“Role\u id”)}
)
私有集角色=新HashSet();
公共关系(){
}
公共长getId(){
返回id;
}
公共无效集合id(长id){
this.id=id;
}
公众人物{
还人,;
}
公众人物(人){
这个。人=人;
}
公共字符串getRelationship(){
回报关系;
}
公共关系(字符串关系){
这个关系=关系;
}
公共字符串getRelation(){
回报关系;
}
公共void集合关系(字符串关系){
这个关系=关系;
}
公共集getRoles(){
返回角色;
}
公共无效集合角色(集合角色){
this.roles=角色;
}
}
@实体
公共类角色实现DaoFunPortalObject{
@身份证
@生成值
@列(name=“Role\u id”)
私人长id;
私有字符串描述;
@许多(mappedBy=“角色”)
private Set peopleRelations=new HashSet();
公共长getId(){
返回id;
}
公共无效集合id(长id){
this.id=id;
}
公共字符串getDescription(){
返回说明;
}
公共void集合描述(字符串描述){
this.description=描述;
}
公共集getPeopleRelations(){
回归人际关系;
}
公共无效setPeopleRelations(setPeopleRelations){
this.peopleRelations=peopleRelations;
}
}
导叶前端
personForm.add(new DropDownChoice<String>("state",
new PropertyModel<String>(people, "state"), statesList));
personForm.add(new TextField<String>("zip",
new PropertyModel<String>(people, "zip")));
personForm.add(new CheckBoxMultipleChoice<String>(
"roles", new Model(roleSelect), roleList));
personForm.add(新的下拉选择(“状态”),
新的财产模型(人,“州”)、州列表);
添加(新的文本字段(“zip”),
新PropertyModel(people,“zip”);
personForm.add(新复选框multipleechoice(
“角色”,新模型(角色选择,角色列表);
在hibernate中,您必须有一个新会话才能检索和保存数据。通常在web应用程序中,在请求开始时打开会话,在请求结束时关闭会话。Spring有一个OpenSessionInViewFilter,它是一个servlet过滤器,应该放在wicket应用程序之前的过滤器链中。它在请求开始时打开hibernate会话,在请求结束时关闭它。所有这些对应用程序代码都是透明的
在你的问题中,你不清楚你遇到了什么问题。您的解决方案是否导致错误消息?如果是,是什么
希望这有帮助 对我来说,不清楚复选框任务是什么。
@Entity
public class Role implements DaoFunPortalObject{
@Id
@GeneratedValue
@Column(name = "Role_id")
private Long id;
private String description;
@ManyToMany(mappedBy="roles")
private Set<PeopleRelation> peopleRelations = new HashSet<PeopleRelation>();
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Set<PeopleRelation> getPeopleRelations() {
return peopleRelations;
}
public void setPeopleRelations(Set<PeopleRelation> peopleRelations) {
this.peopleRelations = peopleRelations;
}
personForm.add(new DropDownChoice<String>("state",
new PropertyModel<String>(people, "state"), statesList));
personForm.add(new TextField<String>("zip",
new PropertyModel<String>(people, "zip")));
personForm.add(new CheckBoxMultipleChoice<String>(
"roles", new Model(roleSelect), roleList));