Entity for D 2.5.0 release, D ORM implementation language

Entity D is a language (DLang) ORM framework database operations, the design reference javax JPA implementation, with good scalability and normative database-driven dependent HuntLabs developed native database driver library Hunt-Database .

characteristic

  1. To achieve a complete CriteriaQuery support

  2. Standardization Repository uses encapsulation

  3. Fully object-oriented query, regardless of the underlying database driver

  4. Implement EQL (the Entity Query Language) to achieve the object of the SQL query language

Supported databases

  • PostgreSQL 9.0+

  • MySQL 5.1+

The main updates

  • Enhanced for EQL

  • Simplified joint-table query

  • Reconstruction database connection pool portion

  • With the new hunt-database

  • Removing libmysql / libpg dependency database driver layer using reconstructed DLang

  • Repair some known issues

Examples of Use

User Model

    module app.model.User;

    import hunt.entity;

    @Table("users")
    class User : Model
    {
        mixin MakeModel;

        @AutoIncrement
        @PrimaryKey
        int id;

        string name;

        int created;

        int updated;
    }

Article model

    module app.model.Post;

    import hunt.entity;

    import app.model.User;

    @Table("posts")
    class Post : Model
    {
        mixin MakeModel;

        @AutoIncrement
        @PrimaryKey
        int id;

        string title;

        int uid;
        @JoinColumn("uid")
        User user;

        string content;

        int status;

        int created;

        int updated;
    }

EQL use conditional queries


// 通过 EQL 查询出 10 条文章,最新发表的排在前面
auto query = em.createQuery!(Post)("SELECT p FROM Post p WHERE p.status = 1 ORDER BY p.created DESC limit 10");

foreach (post; query.getResultList())
{
    logDebug(post.title); // 打印文章标题
    logDebug(post.user.name); // 输出作者名字
}

 

Guess you like

Origin www.oschina.net/news/110670/entity-updated