我的问题的简化版本:假设有两个实体,鱼和芯片。
Fish与Chip建模为一对多的关系:
public class Fish {
@OneToMany
@JoinTable(name = "the_map",
joinColumns = @JoinColumn(name = "fish_id"),
inverseJoinColumns = @JoinColumn(name = "chip_id")
)
@MapKeyColumn(name = "the_key")
private Map<Integer, Chip> chipsMap;
}
以下HQL-Query生成有效的SQL:
from Fish order by chipsMap[2].createDate
尝试使用Spring Data
PageRequest pr = new PageRequest(0, 10,
Sort.Direction.ASC.fromString("chipsMap[2].createDate"));
fishRepository.findAll(pr);
引发
org.springframework.data.mapping.PropertyReferenceException:
No property chipsMap[2] found for type Fish!
Spring Data JPA中的问题?或者语法错误?