|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.hibernate.loader.Loader
Abstract superclass of object loading (and querying) strategies. This class implements
useful common functionality that concrete loaders delegate to. It is not intended that this
functionality would be directly accessed by client code. (Hence, all methods of this class
are declared protected or private.) This class relies heavily upon the
Loadable interface, which is the contract between this class and
ClassPersisters that may be loaded by it.
The present implementation is able to load any number of columns of entities and at most
one collection role per query.
Loadable
Field Summary | |
protected static String[] |
NO_SUFFIX
|
Constructor Summary | |
Loader()
|
Method Summary | |
protected String |
applyLocks(String sql,
Map lockModes,
Dialect dialect)
Append FOR UPDATE OF clause, if necessary. |
protected int |
bindNamedParameters(PreparedStatement st,
Map namedParams,
int start,
SessionImplementor session)
Bind named parameters to the PreparedStatement. |
protected int |
bindPositionalParameters(PreparedStatement st,
QueryParameters queryParameters,
int start,
SessionImplementor session)
Bind positional parameter values to the PreparedStatement (these are parameters specified by a JDBC-style ?). |
protected List |
doList(SessionImplementor session,
QueryParameters queryParameters)
Actually execute a query, ignoring the query cache |
protected static String |
generateAlias(String description,
int unique)
Generate a nice alias for the given class name or collection role name and unique integer. |
protected static String[] |
generateSuffixes(int length)
Utility method that generate 0_, 1_ suffixes. |
protected int |
getCollectionOwner()
Get the index of the entity that owns the collection, or -1 if there is no owner in the query results (ie. |
protected abstract CollectionPersister |
getCollectionPersister()
An (optional) persister for a collection to be initialized; only collection loaders return a non-null value |
protected abstract LockMode[] |
getLockModes(Map lockModes)
What lock mode does this load entities with? |
protected abstract int[] |
getOwners()
An array of indexes of the entity that owns a one-to-one association to the entity at the given index (-1 if there is no "owner") |
protected abstract Loadable[] |
getPersisters()
An array of persisters of entity classes contained in each row of results; implemented by all subclasses |
protected Object |
getResultColumnOrRow(Object[] row,
ResultSet rs,
SessionImplementor session)
Get the actual object that is returned in the user-visible result list. |
protected List |
getResultList(List results)
|
protected ResultSet |
getResultSet(PreparedStatement st,
RowSelection selection,
SessionImplementor session)
Fetch a PreparedStatement, call setMaxRows and then execute it, advance to the first result and return an SQL ResultSet |
protected abstract String |
getSQLString()
The SQL query string to be called; implemented by all subclasses |
protected abstract String[] |
getSuffixes()
The suffix identifies a particular column of results in the SQL ResultSet; implemented by all subclasses |
protected boolean |
isSingleRowLoader()
Return false is this loader is a batch entity loader |
protected List |
list(SessionImplementor session,
QueryParameters queryParameters,
Set querySpaces,
Type[] resultTypes)
Return the query results, using the query cache, called by subclasses that implement cacheable queries |
protected void |
loadCollection(SessionImplementor session,
Serializable id,
Type type)
Called by subclasses that load collections |
protected void |
loadCollectionBatch(SessionImplementor session,
Serializable[] ids,
Type type)
Called by subclasses that batch initialize collections |
protected List |
loadEntity(SessionImplementor session,
Serializable id,
Type identifierType,
Object optionalObject,
Serializable optionalIdentifier)
Called by subclasses that load entities |
protected List |
loadEntityBatch(SessionImplementor session,
Serializable[] ids,
Type idType,
Object optionalObject,
Serializable optionalID)
Called by subclasses that batch load entities |
protected Object |
loadSingleRow(ResultSet resultSet,
SessionImplementor session,
QueryParameters queryParameters,
boolean returnProxies)
|
protected void |
postInstantiate()
Calculate and cache select-clause suffixes. |
protected PreparedStatement |
prepareQueryStatement(String sql,
QueryParameters queryParameters,
boolean scroll,
SessionImplementor session)
Obtain a PreparedStatement with all parameters pre-bound. |
protected boolean |
upgradeLocks()
Does this query return objects that might be already cached by the session, whose lock mode may need upgrading |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final String[] NO_SUFFIX
Constructor Detail |
public Loader()
Method Detail |
protected abstract String getSQLString()
protected abstract Loadable[] getPersisters()
protected abstract String[] getSuffixes()
protected abstract int[] getOwners()
protected abstract CollectionPersister getCollectionPersister()
protected int getCollectionOwner()
protected abstract LockMode[] getLockModes(Map lockModes)
lockModes
- a collection of lock modes specified dynamically via the Query interfaceprotected String applyLocks(String sql, Map lockModes, Dialect dialect) throws HibernateException
HibernateException
protected boolean upgradeLocks()
protected boolean isSingleRowLoader()
protected Object loadSingleRow(ResultSet resultSet, SessionImplementor session, QueryParameters queryParameters, boolean returnProxies) throws SQLException, HibernateException
SQLException
HibernateException
protected List getResultList(List results) throws QueryException
QueryException
protected Object getResultColumnOrRow(Object[] row, ResultSet rs, SessionImplementor session) throws SQLException, HibernateException
SQLException
HibernateException
protected int bindPositionalParameters(PreparedStatement st, QueryParameters queryParameters, int start, SessionImplementor session) throws SQLException, HibernateException
SQLException
HibernateException
protected final PreparedStatement prepareQueryStatement(String sql, QueryParameters queryParameters, boolean scroll, SessionImplementor session) throws SQLException, HibernateException
SQLException
HibernateException
protected final ResultSet getResultSet(PreparedStatement st, RowSelection selection, SessionImplementor session) throws SQLException, HibernateException
SQLException
HibernateException
protected int bindNamedParameters(PreparedStatement st, Map namedParams, int start, SessionImplementor session) throws SQLException, HibernateException
SQLException
HibernateException
protected final List loadEntity(SessionImplementor session, Serializable id, Type identifierType, Object optionalObject, Serializable optionalIdentifier) throws SQLException, HibernateException
SQLException
HibernateException
protected final List loadEntityBatch(SessionImplementor session, Serializable[] ids, Type idType, Object optionalObject, Serializable optionalID) throws SQLException, HibernateException
SQLException
HibernateException
protected final void loadCollection(SessionImplementor session, Serializable id, Type type) throws SQLException, HibernateException
SQLException
HibernateException
protected final void loadCollectionBatch(SessionImplementor session, Serializable[] ids, Type type) throws SQLException, HibernateException
SQLException
HibernateException
protected List list(SessionImplementor session, QueryParameters queryParameters, Set querySpaces, Type[] resultTypes) throws SQLException, HibernateException
SQLException
HibernateException
protected final List doList(SessionImplementor session, QueryParameters queryParameters) throws SQLException, HibernateException
SQLException
HibernateException
protected void postInstantiate()
protected static String[] generateSuffixes(int length)
protected static String generateAlias(String description, int unique)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |