|
||||||||||
| 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 | |
|---|---|
static java.lang.String |
AUTO_UPDATE_VIEW_ON_CHANGE
System property key: org.ektorp.support.AutoUpdateViewOnChange |
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. |
protected void |
debugDesignDoc(DesignDocument generated)
|
T |
get(java.lang.String id)
|
T |
get(java.lang.String id,
java.lang.String rev)
|
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. |
protected DesignDocumentFactory |
getDesignDocumentFactory()
|
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,
ComplexKey key)
Allows subclasses to query views with simple String value keys and load the result as the repository's handled type. |
protected java.util.List<T> |
queryView(java.lang.String viewName,
int key)
Allows subclasses to query views with simple String value keys and load the result as the repository's handled type. |
protected java.util.List<T> |
queryView(java.lang.String viewName,
java.lang.String key)
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 |
setDesignDocumentFactory(DesignDocumentFactory df)
|
void |
update(T entity)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String AUTO_UPDATE_VIEW_ON_CHANGE
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>UpdateConflictException - if there was an update conflict.public java.util.List<T> getAll()
getAll in interface GenericRepository<T>public T get(java.lang.String id)
get in interface GenericRepository<T>id -
DocumentNotFoundException - if the document was not found.
public T get(java.lang.String id,
java.lang.String rev)
get in interface GenericRepository<T>id - rev -
DocumentNotFoundException - if the document was not found.public void remove(T entity)
remove in interface GenericRepository<T>public void update(T entity)
update in interface GenericRepository<T>UpdateConflictException - if there was an update conflict.protected ViewQuery createQuery(java.lang.String viewName)
viewName -
protected java.util.List<T> queryView(java.lang.String viewName,
java.lang.String key)
viewName - key -
protected java.util.List<T> queryView(java.lang.String viewName,
int key)
viewName - keyValue -
protected java.util.List<T> queryView(java.lang.String viewName,
ComplexKey key)
viewName - key -
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:
protected void debugDesignDoc(DesignDocument generated)
public boolean contains(java.lang.String docId)
contains in interface GenericRepository<T>public void setDesignDocumentFactory(DesignDocumentFactory df)
protected DesignDocumentFactory getDesignDocumentFactory()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||