Morphia- MongoDB对象映射框架

网友投稿 1017 2022-10-19

Morphia- MongoDB对象映射框架

Morphia- MongoDB对象映射框架

Morphia 是一个轻量级的类型安全的 Java 类库,用来将在MongoDB 和 Java 对象之间进行映射。

@Entity("employees") class Employee {   @Id ObjectId id; // auto-generated, if not set (see ObjectId)   String firstName, lastName; // value types are automatically persisted   Long salary = null; // only non-null values are stored  @Embedded Address address;  @Reference Employee manager; // refs are stored*, and loaded automatically   @Reference List underlings; // interfaces are supported  @Serialized EncryptedReviews; // stored in one binary field     @Property("started") Date startDate; //fields can be renamed   @Property("left")Date endDate;  @Indexed boolean active = false; //fields can be indexed for better performance   @NotSaved string readButNotStored; //fields can read, but not saved   @Transient int notStored; //fields can be ignored (load/save)   transient boolean stored = true; //not @Transient, will be ignored by Serialization/GWT for example.  //Lifecycle methods -- Pre/PostLoad, Pre/PostSave...   @PostLoad void postLoad(DBObject dbObj) { ... } }

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:springboot配置文件中使用${}注入值的两种方式小结
下一篇:折半查找
相关文章

 发表评论

暂时没有评论,来抢沙发吧~