我有一个班上有@EmbeddedId
@Entity
public class Samples {
@EmbeddedId
public SampleId id;
@MapsId("samplingId")
@ManyToOne(optional = false)
private Samplings sampling;
}
@Embeddable
public class SampleId implements Serializable{
private Integer samplingId;
private String sampleLetter;
public SampleId() {
}
public SampleId(Integer samplingId, String sampleLetter) {
this.samplingId = samplingId;
this.sampleLetter = sampleLetter;
}
}
在数据库示例中,samplingId
处于位置0,sampleLetter
处于位置1;
在Spring Data JPA的分页中,如果我对id进行排序,则会得到
Order by
samples0_.sample_letter,
samples0_.sampling_id asc
因此,Spring Data JPA似乎没有使用数据库位置字段
我搜索以获得
订购者 samples0_.sampling_id, samples0_.sample_letter asc
我尝试这样做:id.samplingId
,id.sampleLetter
我收到此错误:
排序表达式'id.sampleLetter:ASC'必须仅包含属性 select子句中使用的引用或别名