MongoDB对象映射框架 Morphia
jopen
13年前
<strong>Morphia</strong> 是一个轻量级的类型安全的 Java 类库,用来将在 <a href="http://www.open-open.com/lib/view/open1324364690483.html">MongoDB</a> 和 Java 对象之间进行映射。 <ul> <li>Easy to use, and very <strong>lightweight</strong>; reflection is used once per type and cached for <strong>good performance</strong>. </li> <li><a href="/misc/goto?guid=4959518026386687840">Datastore</a> and <a href="/misc/goto?guid=4959518026468580318">DAO</a><T,V> access abstractions, or roll your own... </li> <li><strong>Type-safe</strong>, and <strong>Fluent <a href="/misc/goto?guid=4959518026544356303">Query</a></strong> support with (runtime) validation </li> <li><strong>Annotations</strong> based mapping behavior; there are no XML files. </li> <li><strong>Extensions</strong>: <a href="/misc/goto?guid=4959518026631200037">Validation (jsr303)</a>, and <a href="/misc/goto?guid=4959518026705241371">SLF4J Logging</a> </li> </ul> <pre class="brush:java; toolbar: true; auto-links: false;">@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<Employee> 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) { ... } }</pre> <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1328449682952" target="_blank">http://www.open-open.com/lib/view/home/1328449682952</a></p>