greenDAO 使用

greenDAO Documentation https://greenrobot.org/greendao/documentation/

Tutorials and How-Tos

How to get started

Introduction – project setup

Modelling entities – schema and annotations

Sessions – identity scope and session cache

Notice that the database connection belongs to the DaoMaster, so multiple sessions refer to the same database connection. Hence, new sessions can be created quite quickly. However, each session allocates memory, typically a session “cache” for entities.

Identity scope and session “cache”

If you have two queries returning the same database object, how many Java objects are you working with: one or two? It depends entirely on the identity scope.

The default in greenDAO (the behavior is configurable) is that multiple queries return references to the same Java objects. For example, loading a User object from the USER table with ID 42 returns the same Java object for both queries.

A side effect of this is some kind of entity “caching”. If an entity object is still around in memory (greenDAO uses weak references here), the entity is not constructed again. Also, greenDAO performs no database query to update the entity values. Instead, the object is returned “immediately” from the session cache, which is one or two magnitudes faster.

Queries – using the query builder

Joins – multi-table joins and self-joins

Relations – to-one and to-many relations between entities

Custom types – mapping classes and enums to database values

Database Encryption – using SQLCipher 

GitHub greenDAO 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值