我正在做这样的多选:
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"));
我的root实体是这样的:
@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;
}
}
我收到以下错误:
无法针对路径解析属性[sourceMxXrefsEntity]。
我必须使用Join,因为SourceMxXrefEntity是MxMsgEntity上的Set。
不确定我缺少什么
答案 0 :(得分:1)
带注释的getter名为getSourceMxXrefEntity()
。因此,映射属性的名称为sourceMxXrefEntity
而不是sourceMxXrefsEntity
。