Which Android/Java ORM uses “object caching” like Hibernate does? -
i saw bunch of questions lightweight alternatives hibernate, android. of them has “identity map” pattern?
this pattern makes sure object representing row in db exists once in session. – helps program consistent: if change mapped object somewhere, changed everywhere (because references point same object). doesn’t matter if re-fetch object via new database query, or still have around earlier calls: orm makes sure behave same thing.
hibernate in it’s “level 1 cache”.
ormlite android orm package of version 4.26 (released on 9/26/2011) contains first take on internal object cache. ormlite not have "session" pattern user can inject cache dao , can flush whenever choose. here docs cache support.
to quote manual, cache supports following things:
- if create object using dao, added cache.
- when query object using dao, if object in cache returned. if not in cache added cache. not apply raw query methods.
- if update object database using dao, if exists in cache updated.
- if refresh object database using dao, if exists in cache refreshed.
- if delete object using dao, object deleted cache.
there 2 object cache implementations included ormlite core package. 1 supports weak/soft references , standard lru.
it [obviously] very simple implementation compared hibernate's level 1 cache. feedback welcome.
Comments
Post a Comment