|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.ektorp.support.CouchDbRepositorySupport<T>
T - public class CouchDbRepositorySupport<T>
Provides "out of the box" CRUD functionality for sub classes. Note that this class will try to access the standard design document named according to this convention: _design/[repository type simple name] e.g. _design/Sofa if this repository's handled type is foo.bar.Sofa It is preferable that this design document must define a view named "all". The "all"-view should only return document id's that refer to documents that can be loaded as this repository's handled type.
| Field Summary | |
|---|---|
protected CouchDbConnector |
db
|
protected org.slf4j.Logger |
log
|
| Constructor Summary | |
|---|---|
protected |
CouchDbRepositorySupport(java.lang.Class<T> type,
CouchDbConnector db)
|
| Method Summary | |
|---|---|
void |
add(T entity)
|
boolean |
contains(java.lang.String docId)
|
protected ViewQuery |
createQuery(java.lang.String viewName)
Creates a ViewQuery pre-configured with correct dbPath, design document id and view name. |
T |
get(java.lang.String id)
|
java.util.List<T> |
getAll()
If the repository's design document has a view named "all" it will be used to fetch all documents of this repository's handled type. |
void |
initStandardDesignDocument()
Will create the standard design document if it does not exists in the database. |
protected java.util.List<T> |
queryView(java.lang.String viewName)
Allows subclasses to query a view and load the result as the repository's handled type. |
protected java.util.List<T> |
queryView(java.lang.String viewName,
java.lang.String keyValue)
Allows subclasses to query views with simple String value keys and load the result as the repository's handled type. |
void |
remove(T entity)
|
void |
update(T entity)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final org.slf4j.Logger log
protected final CouchDbConnector db
| Constructor Detail |
|---|
protected CouchDbRepositorySupport(java.lang.Class<T> type,
CouchDbConnector db)
| Method Detail |
|---|
public void add(T entity)
add in interface GenericRepository<T>public java.util.List<T> getAll()
getAll in interface GenericRepository<T>public T get(java.lang.String id)
get in interface GenericRepository<T>public void remove(T entity)
remove in interface GenericRepository<T>public void update(T entity)
update in interface GenericRepository<T>protected ViewQuery createQuery(java.lang.String viewName)
viewName -
protected java.util.List<T> queryView(java.lang.String viewName,
java.lang.String keyValue)
viewName - keyValue -
protected java.util.List<T> queryView(java.lang.String viewName)
viewName -
public void initStandardDesignDocument()
Will create the standard design document if it does not exists in the database.
Will also generate view definitions for finder methods defined in this class and annotated by the @GenerateView annotation. The method name must adhere to the name convention of findBy[Property].
The method:
public boolean contains(java.lang.String docId)
contains in interface GenericRepository<T>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||