to.etc.domui.hibernate.generic
Class HibernateQueryExecutor

java.lang.Object
  extended by to.etc.domui.hibernate.generic.HibernateQueryExecutor
All Implemented Interfaces:
IQueryExecutor<BuggyHibernateBaseContext>, IQueryExecutorFactory

public class HibernateQueryExecutor
extends java.lang.Object
implements IQueryExecutor<BuggyHibernateBaseContext>, IQueryExecutorFactory

This handler knows how to execute Hibernate queries using a basic Hibernate context.

Author:
Frits Jalvingh Created on Apr 29, 2010

Field Summary
static IQueryExecutorFactory FACTORY
           
 
Constructor Summary
protected HibernateQueryExecutor()
           
 
Method Summary
 void attach(BuggyHibernateBaseContext root, java.lang.Object o)
           
 void delete(BuggyHibernateBaseContext root, java.lang.Object o)
          Delete the record passed.
<T> T
find(BuggyHibernateBaseContext 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(BuggyHibernateBaseContext 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(BuggyHibernateBaseContext 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(BuggyHibernateBaseContext root, ICriteriaTableDef<T> clz, java.lang.Object pk)
           
<T> java.util.List<T>
query(BuggyHibernateBaseContext root, QCriteria<T> q)
          Execute the query specified by q and return a list of results.
 java.util.List<java.lang.Object[]> query(BuggyHibernateBaseContext root, QSelection<?> sel)
          Issue a selection query, where multiple fields or projections on fields are selected from a base class.
 void refresh(BuggyHibernateBaseContext root, java.lang.Object o)
          EXPERIMENTAL/NOT FINAL Refresh with latest content in the database.
 void save(BuggyHibernateBaseContext 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 IQueryExecutorFactory FACTORY
Constructor Detail

HibernateQueryExecutor

protected HibernateQueryExecutor()
Method Detail

findContextHandler

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

findContextHandler

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

findContextHandler

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

delete

public void delete(BuggyHibernateBaseContext root,
                   java.lang.Object o)
            throws java.lang.Exception
Delete the record passed.

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

find

public <T> T find(BuggyHibernateBaseContext 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<BuggyHibernateBaseContext>
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

getInstance

public <T> T getInstance(BuggyHibernateBaseContext 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<BuggyHibernateBaseContext>
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(BuggyHibernateBaseContext root,
                  ICriteriaTableDef<T> metatable,
                  java.lang.Object pk)
       throws java.lang.Exception
Specified by:
find in interface IQueryExecutor<BuggyHibernateBaseContext>
Throws:
java.lang.Exception

getInstance

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

query

public <T> java.util.List<T> query(BuggyHibernateBaseContext 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<BuggyHibernateBaseContext>
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(BuggyHibernateBaseContext 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<BuggyHibernateBaseContext>
Returns:
Throws:
java.lang.Exception

refresh

public void refresh(BuggyHibernateBaseContext 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<BuggyHibernateBaseContext>
Throws:
java.lang.Exception

save

public void save(BuggyHibernateBaseContext 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<BuggyHibernateBaseContext>
Throws:
java.lang.Exception

attach

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