Reputation: 4613
I have a parent class that has some shared fields and a child class that extends it.
@SuperBuilder(toBuilder = true)
@Data
public abstract class MultiTenantAuthoredDocument {
@Indexed
private String tenantId;
@CreatedDate
private LocalDateTime createdDate;
@LastModifiedDate
private LocalDateTime lastModifiedDate;
}
@Document(collection = "users")
@SuperBuilder(toBuilder = true)
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class User extends MultiTenantAuthoredDocument {
@Id
private String id;
private String firstName;
private String lastName;
@Indexed
private String password;
@Indexed(unique = true)
private String userName;
@Indexed(unique = true)
private String email;
@Indexed
private List<UserRole> roles;
@Builder.Default
private boolean enabled = false;
}
However when running my unit tests, I get an unexpected exception when I do a findById and there's a result found namely:
No property b found on entity class be.moesmedia.erp.users.domain.User to bind constructor parameter to!
As I have no clue where property b is coming from it's pretty difficult to see what I'm doing wrong.
If anyone can help me point out what I'm doing wrong.
Upvotes: 11
Views: 9117
Reputation: 4613
So I've figured out what was going wrong, Lombok generated a constructor that accepted an Object with the properties for the SuperBuilder class. Once I added @NoArgsConstructor
to both the child and parent class, it works like a charm.
Upvotes: 28