de.greenrobot.dao
Class AbstractDaoSession

java.lang.Object
  extended by de.greenrobot.dao.AbstractDaoSession

public class AbstractDaoSession
extends java.lang.Object

    

DaoSession gives you access to your DAOs, offers convenient persistence methods, and also serves as a session cache.

To access the DAOs, call the get{entity}Dao methods by the generated DaoSession sub class.

DaoSession offers many of the available persistence operations on entities as a convenience. Consider using DAOs directly to access all available operations, especially if you call a lot of operations on a single entity type to avoid the overhead imposed by DaoSession (the overhead is small, but it may add up).

By default, the DaoSession has a session cache (IdentityScopeType.Session). The session cache is not just a plain data cache to improve performance, but also manages object identities. For example, if you load the same entity twice in a query, you will get a single Java object instead of two when using a session cache. This is particular useful for relations pointing to a common set of entities.


Constructor Summary
AbstractDaoSession(SQLiteDatabase db)
           
 
Method Summary
V
callInTx(java.util.concurrent.Callable callable)
          Calls the given Callable inside a database transaction and returns the result of the Callable.
void
delete(T entity)
          Convenient call for AbstractDao.delete(Object).
void
deleteAll(java.lang.Class entityClass)
          Convenient call for AbstractDao.deleteAll().
 AbstractDao getDao(java.lang.Class entityClass)
           
long
insert(T entity)
          Convenient call for AbstractDao.insert(Object).
long
insertOrReplace(T entity)
          Convenient call for AbstractDao.insertOrReplace(Object).
T
load(java.lang.Class entityClass, K key)
          Convenient call for AbstractDao.load(Object).
java.util.List
loadAll(java.lang.Class entityClass)
          Convenient call for AbstractDao.loadAll().
QueryBuilder
queryBuilder(java.lang.Class entityClass)
          Convenient call for AbstractDao.queryBuilder().
java.util.List
queryRaw(java.lang.Class entityClass, java.lang.String where, java.lang.String... selectionArgs)
          Convenient call for AbstractDao.queryRaw(String, String...).
void
refresh(T entity)
          Convenient call for AbstractDao.refresh(Object).
 void runInTx(java.lang.Runnable runnable)
          Run the given Runnable inside a database transaction.
void
update(T entity)
          Convenient call for AbstractDao.update(Object).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDaoSession

public AbstractDaoSession(SQLiteDatabase db)
Method Detail

insert

public  long insert(T entity)
Convenient call for AbstractDao.insert(Object).


insertOrReplace

public  long insertOrReplace(T entity)
Convenient call for AbstractDao.insertOrReplace(Object).


refresh

public  void refresh(T entity)
Convenient call for AbstractDao.refresh(Object).


update

public  void update(T entity)
Convenient call for AbstractDao.update(Object).


delete

public  void delete(T entity)
Convenient call for AbstractDao.delete(Object).


deleteAll

public  void deleteAll(java.lang.Class entityClass)
Convenient call for AbstractDao.deleteAll().


load

public  T load(java.lang.Class entityClass,
                    K key)
Convenient call for AbstractDao.load(Object).


loadAll

public  java.util.List loadAll(java.lang.Class entityClass)
Convenient call for AbstractDao.loadAll().


queryRaw

public  java.util.List queryRaw(java.lang.Class entityClass,
                                        java.lang.String where,
                                        java.lang.String... selectionArgs)
Convenient call for AbstractDao.queryRaw(String, String...).


queryBuilder

public  QueryBuilder queryBuilder(java.lang.Class entityClass)
Convenient call for AbstractDao.queryBuilder().


getDao

public AbstractDao getDao(java.lang.Class entityClass)

runInTx

public void runInTx(java.lang.Runnable runnable)
Run the given Runnable inside a database transaction. If you except a result, consider callInTx.


callInTx

public  V callInTx(java.util.concurrent.Callable callable)
           throws java.lang.Exception
Calls the given Callable inside a database transaction and returns the result of the Callable. If you don't except a result, consider runInTx.

Throws:
java.lang.Exception


Copyright © 2011-2012 greenrobot.de. All Rights Reserved.