我正在做这样的多选:


          cq.multiselect(
            root.get("mxMsgPk"),
            root.get("referenceNo"),
            root.join("connectivityMsg", JoinType.LEFT)
                    .get("msgId"),
            root.get("inOutFlag"),
            root.join("messageStatusEntity", JoinType.LEFT)
                    .get("messageStatusId"),
            root.get("creationDate"),
            root.join("sourceMxXrefsEntity", JoinType.LEFT)
                    .join("sourceMsgEntity", JoinType.LEFT)
                    .join("sourceSystemMsg", JoinType.LEFT)
                    .get("msgId"),
            root.join("errorMsgEntity", JoinType.LEFT)
                    .get("referenceNo"),
            root.join("errorMsgEntity", JoinType.LEFT)
                    .get("errorMsgPk"),
            root.join("sourceMxXrefsEntity", JoinType.LEFT)
                    .join("sourceMsgEntity", JoinType.LEFT)
                    .get("sourceMsgPk"));




我的根实体是这样的:

@Entity
@Table(name="XYZ")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@NamedQuery(name="MxMsgEntity.findAll", query="SELECT m FROM MxMsgEntity m")
public class MxMsgEntity extends COMsgEntity {
private long mxMsgPk;
  private Set <SourceMxXrefEntity> sourceMxXrefsEntity;

public MxMsgEntity() {
}


@Id
@SequenceGenerator(name="EXC_MX_MSG", sequenceName = "SEQ_EXC_MX_MSG")
@GeneratedValue(strategy=GenerationType.AUTO, generator = "EXC_MX_MSG")
@Column(name="MX_MSG_PK", unique=true, nullable=false, precision=10)
public long getMxMsgPk() {
    return this.mxMsgPk;
}

public void setMxMsgPk(long mxMsgPk) {
    this.mxMsgPk = mxMsgPk;
}


public void setSourceMxXrefEntity(Set<SourceMxXrefEntity> sourceCOXrefsEntity) {
    this.sourceMxXrefsEntity = sourceCOXrefsEntity;
}


//bi-directional many-to-one association to SourceMxXrefEntity
@OneToMany(mappedBy="mxMsgEntity")
public Set<SourceMxXrefEntity> getSourceMxXrefEntity() {
    return sourceMxXrefsEntity;
}


}

我收到以下错误:

无法根据路径解析attribute [sourceMxXrefsEntity]。

我必须使用Join,因为SourceMxXrefEntity是MxMsgEntity上的Set。

不知道我在想什么

最佳答案

带注释的吸气剂命名为getSourceMxXrefEntity()。因此,映射属性的名称是sourceMxXrefEntity而不是sourceMxXrefsEntity

10-07 15:54