我得到了以下实体:
@Entity
@Document(collection = "devices")
public class Device {
@Id
private Long id;
@ElementCollection
@Column(name = "basic_info")
private Map<String, String> basicInfo;
// getters, setters
以及以下存储库代码:
@Repository
public interface DeviceRepository extends MongoRepository<Device, Long> {
List<Device> findByBasicInfo_Name(String name);
文档如下:
"id": 1,
"basicInfo": {
"created": "timestamp",
"name": "string",
"type": "string",
"status": "string"
}
我正在尝试基于
"name"
键入
"basicInfo"
与
findByBasicInfo_Name
功能,我甚至尝试过
findByBasicInfoName
正如有人在另一条线索中暗示的那样,没有任何运气。我得到以下错误:
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property name found for type String! Traversed path: Device.basicInfo.