Spring-data-couchbase not working as expected. I must be doing something very wrong

java

#1

The following test illustrates various issues I encounter with Spring Data Couchbase.
I must be doing something very wrong but cannot figure it out.
Id is null after save.
Documents seem to be ‘embedded’ instead of ‘linked to’ because changing the original and saving doesn’t affect the ‘linked’ document.

The code below is in a repo that can be used to recreate the issues:
https://github.com/corneil/spring-data-couchbase-demo/blob/master/src/test/java/com/github/corneil/springdata/couchbase/demo/test/BasicUserTest.java
@Test
public void testSaveGroupAndUser() throws ParseException {
UserInfo user = new UserInfo();
user.setUserId(“joe”);
user.setDateOfBirth(makeDate(“1999-11-11”));
user.setEmailAddress("joe@soap.com");
user.setFullName(“Joe Soap”);
userInfoRepository.save(user);
if (user.getId() == null) {
log.error(“userInfo.id is null”);
}
// Loading by name to ensure id is populated
user = userInfoRepository.findOneByUserId(“joe”);
GroupInfo groupInfo = new GroupInfo(“group1”, user);
groupInfoRepository.save(groupInfo);
if (groupInfo.getId() == null) {
log.error(“groupInfo.id is null”);
}
log.info(“groupInfo:saved:{}”, groupInfo.getId());
// Loading by name to ensure id is populated
groupInfo = groupInfoRepository.findByGroupName(“group1”);
GroupMember member = new GroupMember(groupInfo, user, true);
groupMemberRepository.save(member);
if (member.getId() == null) {
log.error(“member.id is null”);
}
user.setFullName(“Joe Soap Modified”);
userInfoRepository.save(user);
for (GroupMember groupMember : groupMemberRepository.findAll()) {
log.info(“member:{}”, groupMember);
assertNotNull(groupMember.getMember());
if (groupMember.getMember().getId() == null) {
log.error(“groupMember.member.id is null”);
}
if (groupMember.getMemberOfgroup().getId() == null) {
log.error(“groupMember.memberOfgroup.id is null”);
}
assertNotNull(groupMember.getMemberOfgroup());
// user was modified after groupMember was written which means reading should retrieve modified user
assertEquals(“Joe Soap Modified”, groupMember.getMember().getFullName());
}
}


#2

@corneil as far as I know we only support storing it embedded and not through linking, but @subhashni is the authority here lets wait what she has to say whats going on here :slight_smile: