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> V
callInTx(java.util.concurrent.Callable<V> callable)
          Calls the given Callable inside a database transaction and returns the result of the Callable.
<T> void
delete(T entity)
          Convenient call for AbstractDao.delete(Object).
<T> void
deleteAll(java.lang.Class<T> entityClass)
          Convenient call for AbstractDao.deleteAll().
 AbstractDao<?,?> getDao(java.lang.Class<? extends java.lang.Object> entityClass)
           
<T> long
insert(T entity)
          Convenient call for AbstractDao.insert(Object).
<T> long
insertOrReplace(T entity)
          Convenient call for AbstractDao.insertOrReplace(Object).
<T,K> T
load(java.lang.Class<T> entityClass, K key)
          Convenient call for AbstractDao.load(Object).
<T,K> java.util.List<T>
loadAll(java.lang.Class<T> entityClass)
          Convenient call for AbstractDao.loadAll().
<T> QueryBuilder<T>
queryBuilder(java.lang.Class<T> entityClass)
          Convenient call for AbstractDao.queryBuilder().
<T,K> java.util.List<T>
queryRaw(java.lang.Class<T> entityClass, java.lang.String where, java.lang.String... selectionArgs)
          Convenient call for AbstractDao.queryRaw(String, String...).
<T> void
refresh(T entity)
          Convenient call for AbstractDao.refresh(Object).
 void runInTx(java.lang.Runnable runnable)
          Run the given Runnable inside a database transaction.
<T> 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 <T> long insert(T entity)
Convenient call for AbstractDao.insert(Object).


insertOrReplace

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


refresh

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


update

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


delete

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


deleteAll

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


load

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


loadAll

public <T,K> java.util.List<T> loadAll(java.lang.Class<T> entityClass)
Convenient call for AbstractDao.loadAll().


queryRaw

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


queryBuilder

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


getDao

public AbstractDao<?,?> getDao(java.lang.Class<? extends java.lang.Object> 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> V callInTx(java.util.concurrent.Callable<V> 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 greenrobot.de. All Rights Reserved.