|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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 String |
AUTO_UPDATE_VIEW_ON_CHANGE
System property key: org.ektorp.support.AutoUpdateViewOnChange |
protected CouchDbConnector |
db
|
protected static org.slf4j.Logger |
log
|
protected String |
stdDesignDocumentId
|
protected Class<T> |
type
|
Constructor Summary | |
---|---|
protected |
CouchDbRepositorySupport(Class<T> type,
CouchDbConnector db)
|
protected |
CouchDbRepositorySupport(Class<T> type,
CouchDbConnector db,
boolean createIfNotExists)
|
protected |
CouchDbRepositorySupport(Class<T> type,
CouchDbConnector db,
String designDocName)
Alternative constructor allowing a custom design document name (not linked to the type class name) |
Method Summary | |
---|---|
void |
add(T entity)
|
boolean |
contains(String docId)
|
protected ViewQuery |
createQuery(String viewName)
Creates a ViewQuery pre-configured with correct dbPath, design document id and view name. |
protected void |
debugDesignDoc(DesignDocument generated)
|
T |
get(String id)
|
T |
get(String id,
Options options)
|
T |
get(String id,
String rev)
Deprecated. use get(String id, Options options) |
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 List<T> |
queryView(String viewName)
Allows subclasses to query a view and load the result as the repository's handled type. |
protected List<T> |
queryView(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 List<T> |
queryView(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 List<T> |
queryView(String viewName,
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 String AUTO_UPDATE_VIEW_ON_CHANGE
protected static final org.slf4j.Logger log
protected final CouchDbConnector db
protected final Class<T> type
protected final String stdDesignDocumentId
Constructor Detail |
---|
protected CouchDbRepositorySupport(Class<T> type, CouchDbConnector db)
protected CouchDbRepositorySupport(Class<T> type, CouchDbConnector db, boolean createIfNotExists)
protected CouchDbRepositorySupport(Class<T> type, CouchDbConnector db, String designDocName)
type
- db
- designDocName
- Method Detail |
---|
public void add(T entity)
add
in interface GenericRepository<T>
UpdateConflictException
- if there was an update conflict.public List<T> getAll()
getAll
in interface GenericRepository<T>
public T get(String id)
get
in interface GenericRepository<T>
id
-
DocumentNotFoundException
- if the document was not found.public T get(String id, Options options)
id
- options
-
DocumentNotFoundException
- if the document was not found.public T get(String id, 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(String viewName)
viewName
-
protected List<T> queryView(String viewName, String key)
viewName
- key
-
protected List<T> queryView(String viewName, int key)
viewName
- keyValue
-
protected List<T> queryView(String viewName, ComplexKey key)
viewName
- key
-
protected List<T> queryView(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(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 |