T
- public class CouchDbRepositorySupport<T> extends Object implements GenericRepository<T>
Modifier and Type | Field and Description |
---|---|
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 |
Modifier | Constructor and Description |
---|---|
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)
|
Modifier and Type | Method and Description |
---|---|
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) |
public static final String AUTO_UPDATE_VIEW_ON_CHANGE
protected static final org.slf4j.Logger log
protected final CouchDbConnector db
protected final String stdDesignDocumentId
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
- 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()
Copyright © 2013. All Rights Reserved.