0
私はcouchbaseを初めて使用しており、couchbaseからドキュメントを取得する際に問題が発生しています。オブジェクト(List of Devices)のネストされたリストは常にnullです。私はSpring BootとSpring Data Couchbaseを使用しました。Springデータ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
}
}
は、私はあなたがこの問題についての私を助けることができる願っています。