MongoDB: No converter found capable of converting from type [org.bson.types.ObjectId]

小咪咪 2023-01-13 10:58 276阅读 0赞
  1. package com.tju.entity;
  2. import org.bson.codecs.pojo.annotations.BsonId;
  3. import org.bson.types.ObjectId;
  4. import org.springframework.data.annotation.Id;
  5. import org.springframework.data.mongodb.core.mapping.Document;
  6. import java.io.Serializable;
  7. @Document(collection = "student")
  8. public class StudentEntity implements Serializable {
  9. @BsonId
  10. public ObjectId id;
  11. private String name;
  12. private String age;
  13. public String getName() {
  14. return name;
  15. }
  16. public void setName(String name) {
  17. this.name = name;
  18. }
  19. public String getAge() {
  20. return age;
  21. }
  22. public void setAge(String age) {
  23. this.age = age;
  24. }
  25. @Override
  26. public String toString() {
  27. return "MusicianEntity{" +
  28. "id=" + id +
  29. ", name='" + name + '\'' +
  30. ", age='" + age + '\'' +
  31. '}';
  32. }
  33. }

发表评论

表情:
评论列表 (有 0 条评论,276人围观)

还没有评论,来说两句吧...

相关阅读