I have a POJO class in java
@Data
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@AllArgsConstructor
public class TestModel{
protected ObjectId id;
private String name;
}
Is there any way to populate id field in case of insertion. I can see that if I use Document
, then after insertion I can get objectId by using
document.get("_id");
So is there any way I can achieve same using custom POJO class.