public interface QDataContext extends AutoCloseable
| Modifier and Type | Method and Description |
|---|---|
void |
addCommitAction(IRunnable cx)
Add an action which should be executed after a succesful commit on this context.
|
void |
addListener(IQDataContextListener qDataContextListener)
Add a listener to keep track of the events on an instance.
|
void |
attach(Object o)
If the object was from an earlier database session reattach it to another, live session.
|
void |
close()
This will close and fully discard all resources belonging to this context, provided ignoreClose is
not true.
|
void |
commit() |
void |
delete(Object o)
Cause the object to be deleted from the database.
|
<T> T |
find(Class<T> clz,
Object pk)
Load the persistent object with the specified type and primary key from the database.
|
<T> T |
find(ICriteriaTableDef<T> metatable,
Object pk) |
<T> T |
get(Class<T> clz,
Object pk)
Load the persistent object with the specified type and primary key from the database.
|
Connection |
getConnection() |
QDataContextFactory |
getFactory()
Returns the context source which created this DataContext.
|
<T> T |
getInstance(Class<T> clz,
Object pk)
Load the persistent object with the specified type and primary key from the database.
|
<T> T |
getInstance(ICriteriaTableDef<T> clz,
Object pk) |
boolean |
inTransaction() |
<T> T |
original(T copy)
EXPERIMENTAL INTERFACE This retrieves the "original" copy of the specified instance (which must
be loaded inside this data context).
|
<R> List<R> |
query(Class<R> resultInterface,
QSelection<?> sel)
Query a selection, and return the result in the specified proxied interface.
|
<T> List<T> |
query(QCriteria<T> q)
Execute the query specified by q and return a list of results.
|
List<Object[]> |
query(QSelection<?> sel)
Issue a selection query, where multiple fields or projections on fields are selected from a base class.
|
<R> R |
queryOne(Class<R> resultInterface,
QSelection<?> sel)
Query a selection, and return the result in the specified proxied interface.
|
<T> T |
queryOne(QCriteria<T> q)
Execute the query specified by q, and expect and return at most 1 result.
|
Object[] |
queryOne(QSelection<?> q)
Execute the selection query specified by q, and expect and return at most 1 result.
|
void |
refresh(Object o)
EXPERIMENTAL/NOT FINAL Refresh with latest content in the database.
|
void |
rollback() |
void |
save(Object o)
Cause the object to be inserted in the database.
|
void |
setIgnoreClose(boolean on)
When ignoreClose is set to T the close call must be silently ignored.
|
void |
setKeepOriginals()
EXPERIMENTAL Sets the context so that it creates "before" copies.
|
void |
startTransaction() |
@Nonnull QDataContextFactory getFactory()
void setIgnoreClose(boolean on)
on - void close()
close in interface AutoCloseable@Nonnull <T> List<T> query(@Nonnull QCriteria<T> q) throws Exception
T - The return type for this query, a persistent class typeq - The selection criteriaException@Nullable <T> T queryOne(@Nonnull QCriteria<T> q) throws Exception
T - q - Exception@Nonnull List<Object[]> query(@Nonnull QSelection<?> sel) throws Exception
sel - Exception@Nonnull <R> List<R> query(@Nonnull Class<R> resultInterface, @Nonnull QSelection<?> sel) throws Exception
QFld annotations to define the order in the result set.resultInterface - sel - Exception@Nullable Object[] queryOne(@Nonnull QSelection<?> q) throws Exception
T - q - Exception@Nullable <R> R queryOne(@Nonnull Class<R> resultInterface, @Nonnull QSelection<?> sel) throws Exception
QFld annotations to define the order in the result set.resultInterface - sel - Exception@Nullable <T> T find(@Nonnull Class<T> clz, @Nonnull Object pk) throws Exception
T - The object type.clz - The persistent class for which an instance is being sought.pk - The PK for the instance required.Exception@Nonnull <T> T get(@Nonnull Class<T> clz, @Nonnull Object pk) throws Exception
QNotFoundException.T - The object type.clz - The persistent class for which an instance is being sought.pk - The PK for the instance required.Exception@Nullable <T> T find(@Nonnull ICriteriaTableDef<T> metatable, @Nonnull Object pk) throws Exception
Exception@Nullable <T> T original(@Nonnull T copy)
copy - void setKeepOriginals()
@Nonnull <T> T getInstance(@Nonnull Class<T> clz, @Nonnull Object pk) throws Exception
find(Class, Object).T - The object typeclz - The persistent class for which an instance is being sought.pk - The PK for the instance required.Exception@Nonnull <T> T getInstance(@Nonnull ICriteriaTableDef<T> clz, @Nonnull Object pk) throws Exception
Exceptionvoid attach(@Nonnull Object o) throws Exception
o - Exceptionvoid save(@Nonnull Object o) throws Exception
o - Exceptionvoid refresh(@Nonnull Object o) throws Exception
o - Exceptionvoid delete(@Nonnull Object o) throws Exception
o - Exception@Nonnull Connection getConnection() throws Exception
Exceptionvoid addCommitAction(@Nonnull IRunnable cx)
cx - void addListener(@Nonnull IQDataContextListener qDataContextListener)
testDataListener - Copyright © 2017 etc.to. All rights reserved.