• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

greenDAO: GreenDAO is a light & fast ORM that maps objects to SQLite databas ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

greenDAO

开源软件地址:

https://gitee.com/HarmonyOS-tpc/greenDAO

开源软件介绍:

GreenDao

GreenDAO is a light & fast ORM that maps objects to SQLite databases. Being highly optimized, greenDAO offers great performance and consumes minimal memory.It relieves developers from dealing with low-level database requirements while saving development time

Usage Instructions

  1. A sample project which provides runnable code examples that demonstrate uses of the classes in this project is available in the sample/ folder.You can add new perrson info and delete person info by clicking on an existing person in the list.

  2. The following core classes are the essential interface to greenDAO:DaoMaster: The entry point for using greenDAO. DaoMaster holds the database object (SQLiteDatabase) and manages DAO classes (not objects) for a specific schema. It has static methods to create the tables or drop them. Its inner classes OpenHelper and DevOpenHelper are SQLiteOpenHelper implementations that create the schema in the SQLite database.

    DaoSession: Manages all available DAO objects for a specific schema, which you can acquire using one of the getter methods. DaoSession provides also some generic persistence methods like insert, load, update, refresh and delete for entities. Lastly, a DaoSession objects also keeps track of an identity scope.

    DAOs: Data access objects (DAOs) persists and queries for entities. For each entity, greenDAO generates a DAO. It has more persistence methods than DaoSession, for example: count, loadAll, and insertInTx.

    Entities: Persistable objects. Usually, entities are objects representing a database row using standard Java properties (like a POJO or a JavaBean).

  3. The steps to initialize the database and the core greenDAO classes:DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "people-db");Database db = helper.getWritableDb();

    // get the person DAODaoSession daoSession = new DaoMaster(db).newSession();personDao = daoSession.getPersonDao();

  4. QueryBuilder : The QueryBuilder class lets you build custom queries for your entities without SQL and helps detect errors already at compile time.// query all people, sorted by their NameList people = personDao.queryBuilder().orderAsc(PersonDao.Properties.NAME).build().list();

Features

  • Setting up the database
  • Creating the DAO session
  • Inserting, Deleting and updating database
  • Queries, QueryBuilder, Order, Limit, Offset, and Pagination
  • Query and LazyList, Executing Queries multiple times
  • Raw queries, Delete queries
  • Joins
  • Database Encryption

Installation Tutorial:

  1. For using greendao in your sample application, add below dependencies:

    dependencies {	implementation project(path: ':greenDAOLib:greendaoapi')	implementation project(path: ':greenDAOLib:daocore')	implementation project(path: ':greenDAOLib:daogenerator')}
  2. For using greendao in separate application, add the below dependencies and include greendao jars in libs folder of "entry" module:

    dependencies {	implementation files('libs/greendaoapi.har')	implementation files('libs/daocore.har')	implementation files('libs/daogenerator.har')}

    Also for above two cases add the sqlcipher dependency in daocore build.gradle :

    dependencies {	implementation 'io.openharmony.tpc.thirdlib:ohos-database-sqlcipher:1.0.2'}
  3. For using greendao from a remote repository in separate application, add the below dependencies in build.gradle of "entry" module:

    dependencies {    	implementation 'io.openharmony.tpc.thirdlib:greendaocore:1.0.0'}

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap