0
我是couchbase的新手,我遇到了從couchbase獲取文檔的問題。對象(設備列表)的嵌套列表始終爲空。我使用了Spring Boot和Spring Data Couchbase。Spring Data Couchbase/Spring Boot:無法獲取對象的嵌套列表
模型(User.java)
@Document
public class User implements Serializable {
@Id
private String id;
@Field
@NotNull
private String username;
@Field
@NotNull
private String password;
@Field
private List<Devices> deviceList;
/** getter and setter here **/
}
模型(Devices.java)
@Document
public class Devices implements Serializable {
@Field
@NotNull
private String deviceId;
@Field
@NotNull
private String status;
@Field
@NotNull
private String createdDate;
@Reference
private User user;
/** getter and setter here **/
}
庫
@Repository
@Transactional
@N1qlPrimaryIndexed
public interface UserRepository extends CouchbaseRepository<User, String>{
User findOneByUsername(String username);
User findOneByDeviceId(String deviceId);
}
文獻
{
"username": "username",
"password": "password",
"devicesList": [
{
"deviceId": "abc123",
"status": "deactived",
"createdDate": "2017-07-28 15:59:13"
},
{
"deviceId": "abc456",
"status": "actived",
"createdDate": "2017-07-28 15:59:13"
},
{
"deviceId": "abc789",
"status": "deactived",
"createdDate": "2017-07-28 15:59:13"
}
]
}
結果
{
"responseCode": 200,
"data": {
"id": "user-login-03",
"username": "username",
"password": "password",
"deviceList": null
}
}
我希望你能幫我解決這個問題。預先感謝您