3

I am trying to store below pojo in couchbase with spring-data, but persist json is storing "user field of type User" as null.

@JsonInclude(value = Include.NON_EMPTY)
@Document
public class ProjectXYZ {

    @Id
    @GeneratedValue(strategy = GenerationStrategy.UNIQUE)
    private String id;

    @Field
    private String prjname;

    @Field
    private User user;

    //setter and getter

}

Update: User Pojo

@JsonInclude(value = Include.NON_EMPTY)
@Document
public class User {

    @Id
    @Field
    private String id;

    @Field
    private String email;

    @Field
    private String firstName;

    @Field
    private String lastName;

    //setter and getter
}

And as below I am saving it, All works fine and as expected but User object get stored as null.

    ProjectXYZ project = new ProjectXYZ();
    project.setUser(getUser(request));
    project = projectXYZService.createProject(project);
Matthew Groves
  • 25,181
  • 9
  • 71
  • 121
RTA
  • 31
  • 4

1 Answers1

1

References are not directly supported through Spring data couchbase as it needs to store meta information about the reference document id.

However there is support for fetching associated entities through N1QL ANSI Joins available in current Lovelace (3.1.x) versions. Here is the documentation for it.

subhashni
  • 216
  • 1
  • 6