|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.spoledge.audao.db.dao.RootDaoImpl com.spoledge.audao.db.dao.gae.GaeAbstractDaoImpl<T>
public abstract class GaeAbstractDaoImpl<T>
This is the parent of all DAO implementation classes. It uses all common generic methods and utilities. The implementation is not thread safe - we assume that the client creates one DAO impl per thread.
Field Summary | |
---|---|
protected DatastoreService |
ds
The assigned datastore service. |
protected static DtoCache<Key,Entity> |
entityCache
Caching of entities - a short term cache allowing to optimize the calls find + update. |
protected GQLDynamicQuery |
gqlDynamicQuery
GQLDynamicQuery is used to preocess dynamic queries and static queries containing "!=" or "IN" operators. |
protected int |
iteratorCount
|
protected boolean |
multipleQueries
Flag indicating that "!=" or "IN" operators are used in conditions. |
protected Transaction |
tx
The last known transaction. |
protected DtoCache<Key,Entity> |
txEntityCache
Caching of entities - a short term cache allowing to optimize the calls find + update. |
Fields inherited from class com.spoledge.audao.db.dao.RootDaoImpl |
---|
log |
Constructor Summary | |
---|---|
protected |
GaeAbstractDaoImpl(DatastoreService ds)
Creates a new DAO implementation. |
Method Summary | ||
---|---|---|
protected Blob |
blob(byte[] val)
|
|
protected Blob |
blob(java.lang.Object val)
|
|
protected java.util.List<Blob> |
blobs(java.util.List list)
|
|
static void |
clearEntityCache()
Clears entity cache. |
|
protected int |
count(Query query,
java.lang.String cond,
java.lang.Object... params)
Counts records by filled query. |
|
protected java.util.Date |
date(java.sql.Date val)
This method crops time to emulate same behavior as JDBC drivers. |
|
protected java.util.Date |
date(int year,
int month,
int day)
|
|
protected java.util.Date |
date(java.sql.Timestamp val)
|
|
protected java.util.List<java.util.Date> |
datesOfDate(java.util.List<? extends java.sql.Date> list)
|
|
protected java.util.List<java.util.Date> |
datesOfTimestamp(java.util.List<? extends java.sql.Timestamp> list)
|
|
protected java.util.Date |
datetime(int year,
int month,
int day,
int hour,
int min,
int sec)
|
|
protected int |
deleteMany(Query query,
java.lang.String cond,
int offset,
int count,
java.lang.Object... params)
Deletes records by filled query. |
|
protected boolean |
deleteOne(Query query,
java.lang.String cond,
int offset,
int count,
java.lang.Object... params)
Deletes a record by filled query. |
|
protected void |
entityDelete(java.lang.Iterable<Key> keys)
Removes entities from datastore. |
|
protected boolean |
entityDelete(Key key)
Removes entity from datastore. |
|
protected Entity |
entityGet(Key key)
Reads entity from datastore by its key. |
|
protected Key |
entityPut(Entity ent,
java.lang.Object dto,
java.lang.String operation)
Writes entity to datastore. |
|
protected java.util.List<Key> |
entityPut(java.lang.Iterable<Entity> ents,
java.lang.Iterable<?> dtos,
java.lang.String operation)
Writes several entities to datastore. |
|
protected T |
fetch(Entity ent)
Fetches data from generic entity into typesafe DTO. |
|
protected abstract T |
fetch(T dto,
Entity ent)
Fetches data from generic entity into typesafe DTO. |
|
protected T[] |
fetchArray(java.util.Iterator<Entity> iterator)
Fetches data from generic entities into typesafe DTOs. |
|
protected java.util.ArrayList<T> |
fetchList(java.util.Iterator<Entity> iterator)
Fetches data from generic entities into typesafe DTOs. |
|
protected T[] |
findManyArray(Query query,
java.lang.String cond,
int offset,
int count,
java.lang.Object... params)
|
|
protected java.util.ArrayList<T> |
findManyImpl(Query query,
java.lang.String cond,
int offset,
int count,
java.lang.Object[] params)
Finds more than one record by filled query. |
|
protected java.util.ArrayList<T> |
findManyList(Query query,
java.lang.String cond,
int offset,
int count,
java.lang.Object... params)
|
|
protected T |
findOne(Query query,
java.lang.String cond,
int offset,
java.lang.Object... params)
Finds one record by filled query. |
|
protected GeoPt |
geopt(java.lang.Number latitude,
java.lang.Number longitude)
|
|
protected java.lang.Boolean |
getBoolean(Entity ent,
java.lang.String prop)
|
|
protected byte[] |
getByteArray(Entity ent,
java.lang.String prop)
|
|
protected
|
getCoreObject(Entity ent,
java.lang.String prop,
java.lang.Class<S> clazz)
|
|
protected java.sql.Date |
getDate(Entity ent,
java.lang.String prop)
|
|
protected java.lang.Double |
getDouble(Entity ent,
java.lang.String prop)
|
|
protected DtoCache<Key,Entity> |
getEntityCache()
|
|
protected FetchOptions |
getFetchOptions(int offset,
int count)
|
|
protected GQLDynamicQuery |
getGQLDynamicQuery()
|
|
protected java.lang.Integer |
getInteger(Entity ent,
java.lang.String prop)
|
|
protected
|
getList(Entity ent,
java.lang.String prop)
Returns native list - as fetched by GAE API. |
|
protected
|
getList(Entity ent,
java.lang.String prop,
java.lang.Class<S> clazz)
Returns native list - as fetched by GAE API. |
|
protected
|
getListOfObjects(Entity ent,
java.lang.String prop)
Returns list of deserialized object. |
|
protected
|
getListOfObjects(Entity ent,
java.lang.String prop,
java.lang.Class<S> clazz)
Returns list of deserialized object. |
|
protected java.lang.Long |
getLong(Entity ent,
java.lang.String prop)
|
|
protected
|
getObject(Entity ent,
java.lang.String prop,
java.lang.Class<S> clazz)
|
|
protected Query |
getQuery()
|
|
protected Query |
getQueryCond(Query q,
java.lang.String cond,
java.lang.Object... params)
|
|
protected Query |
getQueryCond(java.lang.String cond,
java.lang.Object... params)
|
|
protected java.lang.Short |
getShort(Entity ent,
java.lang.String prop)
|
|
protected java.lang.String |
getString(Entity ent,
java.lang.String prop)
|
|
protected java.sql.Timestamp |
getTimestamp(Entity ent,
java.lang.String prop)
|
|
protected void |
handleException(java.lang.Exception e)
|
|
protected void |
invalidType(Entity ent,
java.lang.String prop,
java.lang.Class<?> expected)
|
|
protected boolean |
isLimit(int count)
|
|
protected Key |
key(Key parent,
java.lang.String kind,
long id)
|
|
protected Key |
key(Key parent,
java.lang.String kind,
java.lang.String name)
|
|
protected Key |
key(long id)
|
|
protected Key |
key(java.lang.String name)
|
|
protected Key |
key(java.lang.String kind,
long id)
|
|
protected Key |
key(java.lang.String kind,
java.lang.String name)
|
|
protected java.lang.Iterable<Key> |
keyIterable(java.lang.Iterable<Entity> ie)
|
|
protected java.util.Iterator<Key> |
keyIterator(java.util.Iterator<Entity> ie)
|
|
protected java.util.List<java.lang.String> |
names(java.util.List<? extends java.lang.Enum> list)
|
|
protected java.util.List<java.lang.Integer> |
ordinals(java.util.List<? extends java.lang.Enum> list)
|
|
protected Key |
parentKey(Key key)
|
|
protected Key |
parentKey(Key key,
int depth)
|
|
protected java.lang.Long |
parentKeyAsLong(Key key,
int depth)
|
|
protected java.lang.String |
parentKeyAsString(Key key,
int depth)
|
|
protected PreparedQuery |
prepare(Query query)
Prepares query. |
|
protected PreparedQuery |
prepare(Query query,
boolean keysOnly)
Prepares query. |
|
protected ShortBlob |
shortBlob(byte[] val)
|
|
protected ShortBlob |
shortBlob(java.lang.Object val)
|
|
protected java.util.List<ShortBlob> |
shortBlobs(java.util.List list)
|
|
protected java.util.List<ShortBlob> |
shortBlobsOfByteArray(java.util.List<byte[]> list)
|
|
protected java.util.Date |
time(int hour,
int min,
int sec)
|
|
protected abstract T[] |
toArray(java.util.ArrayList<T> list)
Converts list to array. |
|
protected User |
user(java.lang.String email)
|
Methods inherited from class com.spoledge.audao.db.dao.RootDaoImpl |
---|
checkLength, checkLength, checkLength, checkMaxLength, checkMaxLength, checkMaxLength, checkNull, debugSql, debugSql, debugSql, deserialize, dtoKey, errorSql, errorSql, errorSql, getTableName, pageOffset, serialize, sqlLog |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static DtoCache<Key,Entity> entityCache
protected DtoCache<Key,Entity> txEntityCache
protected Transaction tx
protected DatastoreService ds
protected boolean multipleQueries
protected GQLDynamicQuery gqlDynamicQuery
protected int iteratorCount
Constructor Detail |
---|
protected GaeAbstractDaoImpl(DatastoreService ds)
java.lang.NullPointerException
- when the passed DS is null.Method Detail |
---|
public static void clearEntityCache()
protected T findOne(Query query, java.lang.String cond, int offset, java.lang.Object... params)
query
- the query ready for executioncond
- the SQL/GQL condition used only for loggingoffset
- the offset of the result set starting at 0params
- the parameters used only for logging
protected T[] findManyArray(Query query, java.lang.String cond, int offset, int count, java.lang.Object... params)
protected java.util.ArrayList<T> findManyList(Query query, java.lang.String cond, int offset, int count, java.lang.Object... params)
protected java.util.ArrayList<T> findManyImpl(Query query, java.lang.String cond, int offset, int count, java.lang.Object[] params)
query
- the query ready for executioncond
- the SQL/GQL condition used only for loggingoffset
- the offset of the result set starting at 0count
- the max number of returned records; -1 or Integer.MAX_VALUE mean no limitparams
- the parameters used only for logging
protected int count(Query query, java.lang.String cond, java.lang.Object... params)
query
- the query ready for executioncond
- the SQL/GQL condition used only for loggingparams
- the parameters used only for logging
protected boolean deleteOne(Query query, java.lang.String cond, int offset, int count, java.lang.Object... params) throws DaoException
query
- the query ready for executioncond
- the SQL/GQL condition used only for loggingoffset
- the offset of the result set starting at 0count
- the max number of deleted records; -1 or Integer.MAX_VALUE mean no limitparams
- the parameters used only for logging
DaoException
- when more than one record was deletedprotected int deleteMany(Query query, java.lang.String cond, int offset, int count, java.lang.Object... params) throws DaoException
query
- the query ready for executioncond
- the SQL/GQL condition used only for loggingoffset
- the offset of the result set starting at 0count
- the max number of deleted records; -1 or Integer.MAX_VALUE mean no limitparams
- the parameters used only for logging
DaoException
protected T fetch(Entity ent)
ent
- the source generic entity
protected abstract T fetch(T dto, Entity ent)
dto
- the typesafe DTO which is filled and returned; can be nullent
- the source generic entity
protected T[] fetchArray(java.util.Iterator<Entity> iterator)
protected java.util.ArrayList<T> fetchList(java.util.Iterator<Entity> iterator)
protected abstract T[] toArray(java.util.ArrayList<T> list)
protected Entity entityGet(Key key)
protected Key entityPut(Entity ent, java.lang.Object dto, java.lang.String operation) throws DaoException
ent
- the entity to be writtendto
- the dto used only for logging; also can be a simple parameteroperation
- the operation (insert/update) used only for logging
DaoException
protected java.util.List<Key> entityPut(java.lang.Iterable<Entity> ents, java.lang.Iterable<?> dtos, java.lang.String operation) throws DaoException
ents
- the entities to be writtendtos
- the dtos used only for loggingoperation
- the operation (insert/update) used only for logging
DaoException
protected boolean entityDelete(Key key) throws DaoException
DaoException
protected void entityDelete(java.lang.Iterable<Key> keys) throws DaoException
DaoException
protected PreparedQuery prepare(Query query)
protected PreparedQuery prepare(Query query, boolean keysOnly)
protected java.lang.Boolean getBoolean(Entity ent, java.lang.String prop)
protected java.lang.Short getShort(Entity ent, java.lang.String prop)
protected java.lang.Integer getInteger(Entity ent, java.lang.String prop)
protected java.lang.Long getLong(Entity ent, java.lang.String prop)
protected java.lang.Double getDouble(Entity ent, java.lang.String prop)
protected java.lang.String getString(Entity ent, java.lang.String prop)
protected java.sql.Date getDate(Entity ent, java.lang.String prop)
protected java.sql.Timestamp getTimestamp(Entity ent, java.lang.String prop)
protected byte[] getByteArray(Entity ent, java.lang.String prop)
protected <S> S getObject(Entity ent, java.lang.String prop, java.lang.Class<S> clazz)
protected <S> S getCoreObject(Entity ent, java.lang.String prop, java.lang.Class<S> clazz)
protected <S> java.util.List<S> getList(Entity ent, java.lang.String prop)
protected <S> java.util.List<S> getList(Entity ent, java.lang.String prop, java.lang.Class<S> clazz)
protected <S> java.util.List<S> getListOfObjects(Entity ent, java.lang.String prop)
protected <S> java.util.List<S> getListOfObjects(Entity ent, java.lang.String prop, java.lang.Class<S> clazz)
protected void invalidType(Entity ent, java.lang.String prop, java.lang.Class<?> expected)
protected java.util.Date date(int year, int month, int day)
protected java.util.Date datetime(int year, int month, int day, int hour, int min, int sec)
protected java.util.Date time(int hour, int min, int sec)
protected java.util.Date date(java.sql.Date val)
protected java.util.Date date(java.sql.Timestamp val)
protected Blob blob(byte[] val)
protected Blob blob(java.lang.Object val)
protected ShortBlob shortBlob(byte[] val)
protected ShortBlob shortBlob(java.lang.Object val)
protected GeoPt geopt(java.lang.Number latitude, java.lang.Number longitude)
protected User user(java.lang.String email)
protected java.util.List<Blob> blobs(java.util.List list)
protected java.util.List<ShortBlob> shortBlobs(java.util.List list)
protected java.util.List<ShortBlob> shortBlobsOfByteArray(java.util.List<byte[]> list)
protected java.util.List<java.util.Date> datesOfDate(java.util.List<? extends java.sql.Date> list)
protected java.util.List<java.util.Date> datesOfTimestamp(java.util.List<? extends java.sql.Timestamp> list)
protected java.util.List<java.lang.Integer> ordinals(java.util.List<? extends java.lang.Enum> list)
protected java.util.List<java.lang.String> names(java.util.List<? extends java.lang.Enum> list)
protected void handleException(java.lang.Exception e)
protected Query getQueryCond(java.lang.String cond, java.lang.Object... params)
protected Query getQueryCond(Query q, java.lang.String cond, java.lang.Object... params)
protected Query getQuery()
protected Key key(long id)
protected Key key(java.lang.String name)
protected Key key(java.lang.String kind, long id)
protected Key key(java.lang.String kind, java.lang.String name)
protected Key key(Key parent, java.lang.String kind, long id)
protected Key key(Key parent, java.lang.String kind, java.lang.String name)
protected Key parentKey(Key key)
protected Key parentKey(Key key, int depth)
protected java.lang.Long parentKeyAsLong(Key key, int depth)
protected java.lang.String parentKeyAsString(Key key, int depth)
protected java.lang.Iterable<Key> keyIterable(java.lang.Iterable<Entity> ie)
protected java.util.Iterator<Key> keyIterator(java.util.Iterator<Entity> ie)
protected FetchOptions getFetchOptions(int offset, int count)
protected boolean isLimit(int count)
protected GQLDynamicQuery getGQLDynamicQuery()
protected DtoCache<Key,Entity> getEntityCache()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |