|
本帖最后由 月白清风 于 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;
- }
复制代码 |
|