实现类似菜单管理的多级添加功能的问题
本帖最后由 月白清风 于 2013-9-25 15:32 编辑欲实现类似如菜单管理里面的添加下级菜单功能,其中有一个需要在实体类中添加一对多的关联,代码如下: private List<FinLoanTypeEntity> FinLoanTypeEntitys = new ArrayList<FinLoanTypeEntity>();
private FinLoanTypeEntity FinLoanTypeEntity;//父菜单
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "parent_Id")
public FinLoanTypeEntity getFinLoanTypeEntity() {
return this.FinLoanTypeEntity;
}
public void setFinLoanTypeEntity(FinLoanTypeEntity FinLoanTypeEntity) {
this.FinLoanTypeEntity = FinLoanTypeEntity;
}
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "FinLoanTypeEntity")
public List<FinLoanTypeEntity> getFinLoanTypeEntitys() {
return FinLoanTypeEntitys;
}
public void setFinLoanTypeEntitys(List<FinLoanTypeEntity> FinLoanTypeEntitys) {
this.FinLoanTypeEntitys = FinLoanTypeEntitys;
}在启动之后,会报错如下:
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.lefu.entity.loan.FinLoanTypeEntity.FinLoanTypeEntity in com.lefu.entity.loan.FinLoanTypeEntity.finLoanTypeEntitys
这个问题应该怎么解决呢?是否注释没写对?
补充说明:@RequestMapping(params = "datagrid")
@ResponseBody
public List<TreeGrid> datagrid(HttpServletRequest request, TreeGrid treegrid) {
CriteriaQuery cq = new CriteriaQuery(FinLoanTypeEntity.class);
if (treegrid.getId() != null) {
cq.eq("FinLoanTypeEntity.id", treegrid.getId());
}
if (treegrid.getId() == null) {
cq.isNull("FinLoanTypeEntity");
}
List<FinLoanTypeEntity> finLoanTypeList = systemService.getListByCriteriaQuery(cq, false);
List<TreeGrid> treeGrids = new ArrayList<TreeGrid>();
TreeGridModel treeGridModel = new TreeGridModel();
// treeGridModel.setIcon("typeCode");
treeGridModel.setTextField("typeName");
treeGridModel.setParentText("FinLoanTypeEntity_typeName");
treeGridModel.setParentId("parentId");
treeGridModel.setSrc("cusType");
treeGridModel.setIdField("id");
treeGridModel.setChildList("FinLoanTypeEntitys");
//添加排序字段
treeGridModel.setOrder("cusType");
treeGrids = systemService.treegrid(finLoanTypeList, treeGridModel);
return treeGrids;
} 【已解决】
需要注意:@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "finLoanTypeEntity"),这里的mappedBy 应该对应的是定义的参数,而非实体类的类名。。即需要小写。
页:
[1]