CriteriaLoaderpublic class CriteriaLoader extends org.hibernate.loader.OuterJoinLoader A Loader for Criteria queries. Note that criteria queries are
more like multi-object load()s than like HQL queries. |
Fields Summary |
---|
private final CriteriaQueryTranslator | translator | private final Set | querySpaces | private final org.hibernate.type.Type[] | resultTypes | private final String[] | userAliases |
Constructors Summary |
---|
public CriteriaLoader(org.hibernate.persister.entity.OuterJoinLoadable persister, org.hibernate.engine.SessionFactoryImplementor factory, org.hibernate.impl.CriteriaImpl criteria, String rootEntityName, Map enabledFilters)
super(factory, enabledFilters);
translator = new CriteriaQueryTranslator(
factory,
criteria,
rootEntityName,
CriteriaQueryTranslator.ROOT_SQL_ALIAS
);
querySpaces = translator.getQuerySpaces();
CriteriaJoinWalker walker = new CriteriaJoinWalker(
persister,
translator,
factory,
criteria,
rootEntityName,
enabledFilters
);
initFromWalker(walker);
userAliases = walker.getUserAliases();
resultTypes = walker.getResultTypes();
postInstantiate();
|
Methods Summary |
---|
protected java.lang.String | applyLocks(java.lang.String sqlSelectString, java.util.Map lockModes, org.hibernate.dialect.Dialect dialect)
if ( lockModes == null || lockModes.isEmpty() ) {
return sqlSelectString;
}
final Map aliasedLockModes = new HashMap();
final Map keyColumnNames = dialect.forUpdateOfColumns() ? new HashMap() : null;
final String[] drivingSqlAliases = getAliases();
for ( int i = 0; i < drivingSqlAliases.length; i++ ) {
final LockMode lockMode = ( LockMode ) lockModes.get( drivingSqlAliases[i] );
if ( lockMode != null ) {
final Lockable drivingPersister = ( Lockable ) getEntityPersisters()[i];
final String rootSqlAlias = drivingPersister.getRootTableAlias( drivingSqlAliases[i] );
aliasedLockModes.put( rootSqlAlias, lockMode );
if ( keyColumnNames != null ) {
keyColumnNames.put( rootSqlAlias, drivingPersister.getRootTableIdentifierColumnNames() );
}
}
}
return dialect.applyLocksToSql( sqlSelectString, aliasedLockModes, keyColumnNames );
| protected org.hibernate.LockMode[] | getLockModes(java.util.Map lockModes)
final String[] entityAliases = getAliases();
if ( entityAliases == null ) {
return null;
}
final int size = entityAliases.length;
LockMode[] lockModesArray = new LockMode[size];
for ( int i=0; i<size; i++ ) {
LockMode lockMode = (LockMode) lockModes.get( entityAliases[i] );
lockModesArray[i] = lockMode==null ? LockMode.NONE : lockMode;
}
return lockModesArray;
| public java.util.Set | getQuerySpaces()
return querySpaces;
| protected java.lang.Object | getResultColumnOrRow(java.lang.Object[] row, org.hibernate.transform.ResultTransformer transformer, java.sql.ResultSet rs, org.hibernate.engine.SessionImplementor session)
final Object[] result;
final String[] aliases;
if ( translator.hasProjection() ) {
Type[] types = translator.getProjectedTypes();
result = new Object[types.length];
String[] columnAliases = translator.getProjectedColumnAliases();
for ( int i=0; i<result.length; i++ ) {
result[i] = types[i].nullSafeGet(rs, columnAliases[i], session, null);
}
aliases = translator.getProjectedAliases();
}
else {
result = row;
aliases = userAliases;
}
return translator.getRootCriteria().getResultTransformer()
.transformTuple(result, aliases);
| protected java.util.List | getResultList(java.util.List results, org.hibernate.transform.ResultTransformer resultTransformer)
return translator.getRootCriteria().getResultTransformer().transformList( results );
| protected boolean | isSubselectLoadingEnabled()
return hasSubselectLoadableCollections();
| public java.util.List | list(org.hibernate.engine.SessionImplementor session)
return list( session, translator.getQueryParameters(), querySpaces, resultTypes );
| public org.hibernate.ScrollableResults | scroll(org.hibernate.engine.SessionImplementor session, org.hibernate.ScrollMode scrollMode)
QueryParameters qp = translator.getQueryParameters();
qp.setScrollMode(scrollMode);
return scroll(qp, resultTypes, null, session);
|
|