public interface Repository
Modifier and Type | Field and Description |
---|---|
static String |
TRANSACTION_NONE |
static String |
TRANSACTION_READ_COMMITTED |
static String |
TRANSACTION_READ_UNCOMMITTED |
static String |
TRANSACTION_REPEATABLE_READ |
static String |
TRANSACTION_SERIALIZABLE |
Modifier and Type | Method and Description |
---|---|
int |
add(Queryable queryable)
Add a new object to repository.
|
<T> int |
add(T entity)
Add a new object to repository.
|
void |
close()
Close the connection with the database.
|
boolean |
containsQuery(String name) |
<T> T |
dsl()
A domain-specific languages (DSL) from native API: JPA, Couchbase, Cassandra etc.
|
boolean |
enrich(Queryable queryable)
Use the
Queryable to retrieve data and appends the result to Queryable.getParams()
parameters, where for each get method must have a correspondent set . |
void |
flush()
Push the queries from buffer to repository.
|
<T> T |
get(Class<T> returnType,
Object object)
Get one object instance of type
returnType from repository using a object as parameter. |
<T> T |
get(Queryable queryable)
Get one object instance from repository using a query.
|
<T> T |
get(Queryable queryable,
Class<T> returnType)
Get one object instance of type
returnType from repository using a query. |
<T,R> T |
get(Queryable queryable,
ResultRow<T,R> customResultRow)
Get one object instance from repository using a query.
|
<T> T |
get(T object)
Get one object instance from repository using a
object as parameter. |
Transactional |
getTransaction() |
<T> List<T> |
list(Queryable queryable)
Retrieve a set of objects
T from repository using a query. |
<T> List<T> |
list(Queryable queryable,
Class<T> returnType)
Retrieve a set of objects
returnType from repository using a query. |
<T,R> List<T> |
list(Queryable queryable,
ResultRow<T,R> customResultRow)
Retrieve a set of objects
T from repository using a query. |
int |
remove(Queryable queryable)
Execute a query to remove one or many objects from repository.
|
<T> int |
remove(T entity)
Remove the
entity from repository. |
<T> T |
scalar(Queryable queryable)
Retrieve a number, numerical quantity, string, date, boolean, some primitive value (wrapped),
the type is checked against jdbc data type.
|
int |
update(Queryable queryable)
Update many objects in repository.
|
<T> T |
update(T entity)
Update object(s) in repository.
|
static final String TRANSACTION_NONE
static final String TRANSACTION_READ_UNCOMMITTED
static final String TRANSACTION_READ_COMMITTED
static final String TRANSACTION_REPEATABLE_READ
static final String TRANSACTION_SERIALIZABLE
<T> T get(Queryable queryable)
T
- generic type to be returnedqueryable
- The Query name with yours parametersQueryNotFoundException
- when not found the query nameNonUniqueResultException
- when select or select with group by recovery more one objects<T> T get(Queryable queryable, Class<T> returnType)
returnType
from repository using a query.T
- type of object returnedqueryable
- The Query name with yours parametersreturnType
- overload the returned type from XML filereturnType
that matches with query. A null reference is
returned if the query no match anyone object.QueryNotFoundException
- when not found the query nameNonUniqueResultException
- when select or select with group by recovery more one objects<T,R> T get(Queryable queryable, ResultRow<T,R> customResultRow)
T
- type of object returnedR
- raw type from repository API (Like ResultSet
from JDBC)queryable
- The Query name with yours parameterscustomResultRow
- Customized extractor to process each row from queryreturnType
that matches with query. A null reference is
returned if the query no match anyone object.QueryNotFoundException
- when not found the query nameNonUniqueResultException
- when select or select with group by recovery more one objects<T> T get(T object)
object
as parameter.T
- type of object returnedobject
- object that contains the parameters to retrieve the entity.returnType
that matches with query. A null reference is
returned if the query no match anyone object.QueryNotFoundException
- when not found the query nameNonUniqueResultException
- when select or select with group by recovery more one objects<T> T get(Class<T> returnType, Object object)
returnType
from repository using a object
as parameter.T
- type of object returnedreturnType
- overload the returned type from XML fileobject
- parameters from query to retrieve the objectreturnType
that matches with query. A null reference is
returned if the query no match anyone object.QueryNotFoundException
- when not found the query nameNonUniqueResultException
- when select or select with group by recovery more one objects<T> T scalar(Queryable queryable)
T
- the single type to be returnedqueryable
- The Query name with yours parametersQueryNotFoundException
- when not found the query nameNonUniqueResultException
- when select or select with group by recovery more one objectsboolean enrich(Queryable queryable)
Queryable
to retrieve data and appends the result to Queryable.getParams()
parameters, where for each get
method must have a correspondent set
.queryable
- Query with yours parameterstrue
if the objects was enriched, false
otherwise.QueryNotFoundException
- when not found the query nameNonUniqueResultException
- if your Queryable
doesn't return one unique value<T> List<T> list(Queryable queryable)
T
from repository using a query.T
- generic type to be returnedqueryable
- The Query name with yours parametersQueryNotFoundException
- when not found the query name<T> List<T> list(Queryable queryable, Class<T> returnType)
returnType
from repository using a query.T
- type of object returnedqueryable
- The Query name with yours parametersreturnType
- overload the returned type from XML fileQueryNotFoundException
- when not found the query name<T,R> List<T> list(Queryable queryable, ResultRow<T,R> customResultRow)
T
from repository using a query.T
- type of object returnedR
- raw type from repository API (Like ResultSet
from JDBC)queryable
- The Query name with yours parameterscustomResultRow
- Customized extractor to process each row from queryQueryNotFoundException
- when not found the query nameint add(Queryable queryable)
queryable
- name of query must be executed to add object to repositoryQueryNotFoundException
- when not found the query name<T> int add(T entity)
T
- type of object returnedentity
- object to be added to repositoryIllegalArgumentException
- when entity is nullint update(Queryable queryable)
queryable
- The Query name with yours parametersQueryNotFoundException
- when not found the query nameIllegalArgumentException
- when the query is different from update sentence<T> T update(T entity)
T
- type of object returnedentity
- update the repository with a entity
values mapped at query.IllegalArgumentException
- when entity is nullint remove(Queryable queryable)
queryable
- The Query name with yours parametersIllegalArgumentException
- when the query is different from delete<T> int remove(T entity)
entity
from repository.T
- type of object returnedentity
- object with the parametersIllegalArgumentException
- when entity is nullvoid flush()
Transactional getTransaction()
void close()
RepositoryException
boolean containsQuery(String name)
<T> T dsl()
T
- a generic type from DSL APIUnsupportedDslOperationException
- when the repository does not supports DSLCopyright © 2012–2020 jkniv, copyleft code. All rights reserved.