public class JdbcDataContext extends Object implements QDataContext
This is a poor-man's datacontext that can be used to do JDBC queries using the QCriteria interface.
| Constructor and Description |
|---|
JdbcDataContext(QDataContextFactory factory,
Connection dbc) |
| 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)
DOES NOTHING.
|
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)
Unsupported for JDBC code.
|
<T> T |
find(Class<T> clz,
Object pk)
Locate the specified record by PK.
|
<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()
Return the underlying connection verbatim.
|
QDataContextFactory |
getFactory()
Returns the context source which created this DataContext.
|
<T> T |
getInstance(Class<T> clz,
Object pk)
Get an instance; this will return an instance by first trying to load it; if that fails
it will create one but only fill the PK.
|
<T> T |
getInstance(ICriteriaTableDef<T> clz,
Object pk) |
protected Connection |
internalGetConnection() |
protected void |
internalSetConnection(Connection dbc) |
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)
Not suppore
|
void |
rollback() |
void |
save(Object o)
Not supported
|
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() |
protected void |
unclosed() |
public JdbcDataContext(QDataContextFactory factory, Connection dbc)
protected void internalSetConnection(Connection dbc)
protected Connection internalGetConnection() throws Exception
Exceptionpublic void attach(@Nonnull Object o) throws Exception
attach in interface QDataContextExceptionQDataContext.attach(java.lang.Object)public void close()
QDataContextclose in interface AutoCloseableclose in interface QDataContextpublic void commit()
throws Exception
commit in interface QDataContextExceptionpublic void delete(@Nonnull Object o) throws Exception
delete in interface QDataContextExceptionQDataContext.delete(java.lang.Object)public <T> T find(@Nonnull Class<T> clz, @Nonnull Object pk) throws Exception
find in interface QDataContextT - The object type.clz - The persistent class for which an instance is being sought.pk - The PK for the instance required.ExceptionQDataContext.find(java.lang.Class, java.lang.Object)@Nonnull public <T> T get(@Nonnull Class<T> clz, @Nonnull Object pk) throws Exception
QNotFoundException.get in interface QDataContextT - The object type.clz - The persistent class for which an instance is being sought.pk - The PK for the instance required.ExceptionQDataContext.get(java.lang.Class, java.lang.Object)@Nonnull public <T> T getInstance(@Nonnull Class<T> clz, @Nonnull Object pk) throws Exception
getInstance in interface QDataContextT - The object typeclz - The persistent class for which an instance is being sought.pk - The PK for the instance required.ExceptionQDataContext.getInstance(java.lang.Class, java.lang.Object)@Nonnull public Connection getConnection() throws Exception
getConnection in interface QDataContextExceptionQDataContext.getConnection()@Nonnull public QDataContextFactory getFactory()
QDataContextgetFactory in interface QDataContextpublic boolean inTransaction()
throws Exception
inTransaction in interface QDataContextException@Nonnull public <T> List<T> query(@Nonnull QCriteria<T> q) throws Exception
QDataContextquery in interface QDataContextT - The return type for this query, a persistent class typeq - The selection criteriaException@Nonnull public List<Object[]> query(@Nonnull QSelection<?> sel) throws Exception
QDataContextquery in interface QDataContextExceptionpublic <T> T queryOne(@Nonnull QCriteria<T> q) throws Exception
QDataContextqueryOne in interface QDataContextExceptionpublic Object[] queryOne(@Nonnull QSelection<?> q) throws Exception
QDataContextqueryOne in interface QDataContextExceptionpublic <T> T find(@Nonnull ICriteriaTableDef<T> metatable, @Nonnull Object pk) throws Exception
find in interface QDataContextException@Nonnull public <R> List<R> query(@Nonnull Class<R> resultInterface, @Nonnull QSelection<?> sel) throws Exception
QDataContextQFld annotations to define the order in the result set.query in interface QDataContextException@Nullable public <R> R queryOne(@Nonnull Class<R> resultInterface, @Nonnull QSelection<?> sel) throws Exception
QDataContextQFld annotations to define the order in the result set.queryOne in interface QDataContextException@Nonnull public <T> T getInstance(@Nonnull ICriteriaTableDef<T> clz, @Nonnull Object pk) throws Exception
getInstance in interface QDataContextExceptionpublic void refresh(@Nonnull Object o) throws Exception
refresh in interface QDataContextExceptionQDataContext.refresh(java.lang.Object)public void rollback()
throws Exception
rollback in interface QDataContextExceptionpublic void save(@Nonnull Object o) throws Exception
save in interface QDataContextExceptionQDataContext.save(java.lang.Object)public void setIgnoreClose(boolean on)
QDataContextsetIgnoreClose in interface QDataContextpublic void startTransaction()
throws Exception
startTransaction in interface QDataContextExceptionpublic void addCommitAction(@Nonnull IRunnable cx)
QDataContextaddCommitAction in interface QDataContextpublic void addListener(@Nonnull IQDataContextListener qDataContextListener)
addListener in interface QDataContextQDataContext.addListener(to.etc.webapp.query.IQDataContextListener)public <T> T original(@Nonnull T copy)
QDataContextoriginal in interface QDataContextpublic void setKeepOriginals()
QDataContextsetKeepOriginals in interface QDataContextCopyright © 2017 etc.to. All rights reserved.