to.etc.webapp.qsql
Class JdbcQueryExecutor

java.lang.Object
  extended by to.etc.webapp.qsql.JdbcQueryExecutor
All Implemented Interfaces:
IQueryExecutor<QDataContext>, IQueryExecutorFactory

public class JdbcQueryExecutor
extends java.lang.Object
implements IQueryExecutor<QDataContext>, IQueryExecutorFactory


Field Summary
static JdbcQueryExecutor FACTORY
           
 
Constructor Summary
protected JdbcQueryExecutor()
           
 
Method Summary
 void attach(QDataContext root, java.lang.Object o)
           
 void delete(QDataContext root, java.lang.Object o)
          EXPERIMENTAL/NOT FINAL Cause the object to be deleted from the database.
<T> T
find(QDataContext root, java.lang.Class<T> clz, java.lang.Object pk)
          Load the persistent object with the specified type and primary key from the database.
<T> T
find(QDataContext root, ICriteriaTableDef<T> metatable, java.lang.Object pk)
           
 IQueryExecutor<?> findContextHandler(QDataContext root, java.lang.Class<?> clz)
           
 IQueryExecutor<?> findContextHandler(QDataContext root, ICriteriaTableDef<?> tableMeta)
           
 IQueryExecutor<?> findContextHandler(QDataContext root, java.lang.Object recordInstance)
           
<T> T
getInstance(QDataContext root, java.lang.Class<T> clz, java.lang.Object pk)
          Load the persistent object with the specified type and primary key from the database.
<T> T
getInstance(QDataContext root, ICriteriaTableDef<T> clz, java.lang.Object pk)
           
<T> java.util.List<T>
query(QDataContext root, QCriteria<T> q)
          Execute the query specified by q and return a list of results.
 java.util.List<java.lang.Object[]> query(QDataContext root, QSelection<?> sel)
          Issue a selection query, where multiple fields or projections on fields are selected from a base class.
 void refresh(QDataContext root, java.lang.Object o)
          EXPERIMENTAL/NOT FINAL Refresh with latest content in the database.
 void save(QDataContext root, java.lang.Object o)
          EXPERIMENTAL/NOT FINAL Cause the object to be inserted in the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FACTORY

public static final JdbcQueryExecutor FACTORY
Constructor Detail

JdbcQueryExecutor

protected JdbcQueryExecutor()
Method Detail

findContextHandler

public IQueryExecutor<?> findContextHandler(QDataContext root,
                                            java.lang.Class<?> clz)
Specified by:
findContextHandler in interface IQueryExecutorFactory
Returns:

findContextHandler

public IQueryExecutor<?> findContextHandler(QDataContext root,
                                            ICriteriaTableDef<?> tableMeta)
Specified by:
findContextHandler in interface IQueryExecutorFactory

findContextHandler

public IQueryExecutor<?> findContextHandler(QDataContext root,
                                            java.lang.Object recordInstance)
Specified by:
findContextHandler in interface IQueryExecutorFactory

find

public <T> T find(QDataContext root,
                  java.lang.Class<T> clz,
                  java.lang.Object pk)
       throws java.lang.Exception
Description copied from interface: IQueryExecutor
Load the persistent object with the specified type and primary key from the database. This will execute an actual select in the database if the object is not yet cached, ensuring that the object actually exists. If the object does not exist this will return null.

Specified by:
find in interface IQueryExecutor<QDataContext>
Type Parameters:
T - The object type.
clz - The persistent class for which an instance is being sought.
pk - The PK for the instance required.
Returns:
Null if the instance does not exist, the actual and fully initialized instance (or proxy) otherwise.
Throws:
java.lang.Exception
See Also:
IQueryExecutor.find(to.etc.webapp.query.QDataContext, java.lang.Class, java.lang.Object)

getInstance

public <T> T getInstance(QDataContext root,
                         java.lang.Class<T> clz,
                         java.lang.Object pk)
              throws java.lang.Exception
Description copied from interface: IQueryExecutor
Load the persistent object with the specified type and primary key from the database. This will return an object always even if the object does not exist in the database! This should only be used when you need an instance representing a given primary key that you know exists. This usually returns a proxy, meaning that nonexistent objects will throw exceptions as soon as properties other than it's primary key are accessed. To get an object and be sure it is present in the database use QDataContext.find(Class, Object).

Specified by:
getInstance in interface IQueryExecutor<QDataContext>
Type Parameters:
T - The object type
clz - The persistent class for which an instance is being sought.
pk - The PK for the instance required.
Returns:
Always returns an instance; it can be invalid when it does not really exist on the backing store.
Throws:
java.lang.Exception

find

public <T> T find(QDataContext root,
                  ICriteriaTableDef<T> metatable,
                  java.lang.Object pk)
       throws java.lang.Exception
Specified by:
find in interface IQueryExecutor<QDataContext>
Throws:
java.lang.Exception

getInstance

public <T> T getInstance(QDataContext root,
                         ICriteriaTableDef<T> clz,
                         java.lang.Object pk)
              throws java.lang.Exception
Specified by:
getInstance in interface IQueryExecutor<QDataContext>
Throws:
java.lang.Exception

query

public <T> java.util.List<T> query(QDataContext root,
                                   QCriteria<T> q)
                        throws java.lang.Exception
Description copied from interface: IQueryExecutor
Execute the query specified by q and return a list of results. Before and after the query execution all registered listeners will be called.

Specified by:
query in interface IQueryExecutor<QDataContext>
Type Parameters:
T - The return type for this query, a persistent class type
q - The selection criteria
Returns:
Throws:
java.lang.Exception

query

public java.util.List<java.lang.Object[]> query(QDataContext root,
                                                QSelection<?> sel)
                                         throws java.lang.Exception
Description copied from interface: IQueryExecutor
Issue a selection query, where multiple fields or projections on fields are selected from a base class.

Specified by:
query in interface IQueryExecutor<QDataContext>
Returns:
Throws:
java.lang.Exception

refresh

public void refresh(QDataContext root,
                    java.lang.Object o)
             throws java.lang.Exception
Description copied from interface: IQueryExecutor
EXPERIMENTAL/NOT FINAL Refresh with latest content in the database.

Specified by:
refresh in interface IQueryExecutor<QDataContext>
Throws:
java.lang.Exception

save

public void save(QDataContext root,
                 java.lang.Object o)
          throws java.lang.Exception
Description copied from interface: IQueryExecutor
EXPERIMENTAL/NOT FINAL Cause the object to be inserted in the database.

Specified by:
save in interface IQueryExecutor<QDataContext>
Throws:
java.lang.Exception

delete

public void delete(QDataContext root,
                   java.lang.Object o)
            throws java.lang.Exception
Description copied from interface: IQueryExecutor
EXPERIMENTAL/NOT FINAL Cause the object to be deleted from the database.

Specified by:
delete in interface IQueryExecutor<QDataContext>
Throws:
java.lang.Exception

attach

public void attach(QDataContext root,
                   java.lang.Object o)
            throws java.lang.Exception
Specified by:
attach in interface IQueryExecutor<QDataContext>
Throws:
java.lang.Exception