QueryException:无法解析属性

时间:2018-09-04 08:20:56

标签: java sql hibernate orm

这是我的两个pojo字段

@ManyToMany
@Cascade(value = SAVE_UPDATE)
@JoinTable(name = "catalogToCatalog",
        joinColumns = {@JoinColumn(name = "parentId",
                foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))},
        inverseJoinColumns = {@JoinColumn(name = "childId",
                foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))})
private List<Catalog> parents;

@Cascade(value = SAVE_UPDATE)
@ManyToMany(mappedBy = "parents", fetch = FetchType.EAGER, targetEntity = Catalog.class)
private List<Catalog> children;

如何使用

这样的命名查询获取数据
"from Catalog c left join c.parents p " +
        "where p.parentId = :parentId";

 QueryException: could not resolve property: parentId of: com.x.model.Catalog [from com.x.model.Catalog c left join

0 个答案:

没有答案