I am working on a spring boot application with spring data mongoDB. I have a common class which holds all the common properties and my other classes extend it so that I have those common properties in them.
@Getter
@Setter
@EntityListeners({AuditingEntityListener.class})
public abstract class AbstractAuditEntity implements Serializable {
@CreatedBy
@NotNull
private Long createdBy;
@LastModifiedBy
@NotNull
private Long updatedBy;
@CreatedDate
@NotNull
private Instant createdDate;
@LastModifiedDate
@NotNull
private Instant updatedDate;
}
now when i extend this class in my another class like
@Document(collection = "consumer")
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class ConsumerEntity extends AbstractAuditEntity {
@Id
private ObjectId id;
}
The document created in mongo database has same name as my class name i.e "ConsumerEntity", how do I get @Document(collection = "consumer") to work so that in my mongo database the collection name is reflected as "consumer". Thank You