mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-21 10:34:51 +00:00
HHH-8159 - Apply fixups indicated by analysis tools
This commit is contained in:
parent
d67a96e813
commit
7004914ec0
@ -177,7 +177,9 @@ subprojects { subProject ->
|
||||
"-encoding", "UTF-8",
|
||||
"-processor", "org.jboss.logging.processor.apt.LoggingToolsProcessor",
|
||||
"-s", "$sourceSets.main.generatedLoggingSrcDir.absolutePath",
|
||||
"-AloggingVersion=3.0",
|
||||
// "-AloggingVersion=3.0",
|
||||
"-Adebug=true",
|
||||
"-AskipTranslations=true",
|
||||
"-source", rootProject.javaLanguageLevel,
|
||||
"-target", rootProject.javaLanguageLevel,
|
||||
"-AtranslationFilesPath=${project.rootDir}/src/main/resources"
|
||||
|
@ -24,6 +24,7 @@
|
||||
package org.hibernate.hql.internal.ast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@ -133,6 +134,7 @@ public QueryTranslatorImpl(
|
||||
* @throws QueryException There was a problem parsing the query string.
|
||||
* @throws MappingException There was a problem querying defined mappings.
|
||||
*/
|
||||
@Override
|
||||
public void compile(
|
||||
Map replacements,
|
||||
boolean shallow) throws QueryException, MappingException {
|
||||
@ -149,6 +151,7 @@ public void compile(
|
||||
* @throws QueryException There was a problem parsing the query string.
|
||||
* @throws MappingException There was a problem querying defined mappings.
|
||||
*/
|
||||
@Override
|
||||
public void compile(
|
||||
String collectionRole,
|
||||
Map replacements,
|
||||
@ -304,7 +307,7 @@ private void errorIfSelect() throws HibernateException {
|
||||
throw new QueryExecutionRequestException( "Not supported for select queries", hql );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryIdentifier() {
|
||||
return queryIdentifier;
|
||||
}
|
||||
@ -322,25 +325,27 @@ private HqlSqlWalker getWalker() {
|
||||
*
|
||||
* @return an array of <tt>Type</tt>s.
|
||||
*/
|
||||
@Override
|
||||
public Type[] getReturnTypes() {
|
||||
errorIfDML();
|
||||
return getWalker().getReturnTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getReturnAliases() {
|
||||
errorIfDML();
|
||||
return getWalker().getReturnAliases();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[][] getColumnNames() {
|
||||
errorIfDML();
|
||||
return getWalker().getSelectClause().getColumnNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set getQuerySpaces() {
|
||||
return getWalker().getQuerySpaces();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List list(SessionImplementor session, QueryParameters queryParameters)
|
||||
throws HibernateException {
|
||||
// Delegate to the QueryLoader...
|
||||
@ -397,6 +402,7 @@ public List list(SessionImplementor session, QueryParameters queryParameters)
|
||||
/**
|
||||
* Return the query results as an iterator
|
||||
*/
|
||||
@Override
|
||||
public Iterator iterate(QueryParameters queryParameters, EventSource session)
|
||||
throws HibernateException {
|
||||
// Delegate to the QueryLoader...
|
||||
@ -407,13 +413,14 @@ public Iterator iterate(QueryParameters queryParameters, EventSource session)
|
||||
/**
|
||||
* Return the query results, as an instance of <tt>ScrollableResults</tt>
|
||||
*/
|
||||
@Override
|
||||
public ScrollableResults scroll(QueryParameters queryParameters, SessionImplementor session)
|
||||
throws HibernateException {
|
||||
// Delegate to the QueryLoader...
|
||||
errorIfDML();
|
||||
return queryLoader.scroll( queryParameters, session );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int executeUpdate(QueryParameters queryParameters, SessionImplementor session)
|
||||
throws HibernateException {
|
||||
errorIfSelect();
|
||||
@ -423,17 +430,16 @@ public int executeUpdate(QueryParameters queryParameters, SessionImplementor ses
|
||||
/**
|
||||
* The SQL query string to be called; implemented by all subclasses
|
||||
*/
|
||||
@Override
|
||||
public String getSQLString() {
|
||||
return sql;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> collectSqlStrings() {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
if ( isManipulationStatement() ) {
|
||||
String[] sqlStatements = statementExecutor.getSqlStatements();
|
||||
for ( int i = 0; i < sqlStatements.length; i++ ) {
|
||||
list.add( sqlStatements[i] );
|
||||
}
|
||||
Collections.addAll( list, sqlStatements );
|
||||
}
|
||||
else {
|
||||
list.add( sql );
|
||||
@ -446,11 +452,11 @@ public List<String> collectSqlStrings() {
|
||||
public boolean isShallowQuery() {
|
||||
return shallowQuery;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryString() {
|
||||
return hql;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getEnabledFilters() {
|
||||
return enabledFilters;
|
||||
}
|
||||
@ -458,17 +464,17 @@ public Map getEnabledFilters() {
|
||||
public int[] getNamedParameterLocs(String name) {
|
||||
return getWalker().getNamedParameterLocations( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsCollectionFetches() {
|
||||
errorIfDML();
|
||||
List collectionFetches = ( ( QueryNode ) sqlAst ).getFromClause().getCollectionFetches();
|
||||
return collectionFetches != null && collectionFetches.size() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isManipulationStatement() {
|
||||
return sqlAst.needsExecutor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateScrollability() throws HibernateException {
|
||||
// Impl Note: allows multiple collection fetches as long as the
|
||||
// entire fecthed graph still "points back" to a single
|
||||
@ -496,10 +502,9 @@ public void validateScrollability() throws HibernateException {
|
||||
}
|
||||
|
||||
FromElement owner = null;
|
||||
Iterator itr = query.getSelectClause().getFromElementsForLoad().iterator();
|
||||
while ( itr.hasNext() ) {
|
||||
for ( Object o : query.getSelectClause().getFromElementsForLoad() ) {
|
||||
// should be the first, but just to be safe...
|
||||
final FromElement fromElement = ( FromElement ) itr.next();
|
||||
final FromElement fromElement = (FromElement) o;
|
||||
if ( fromElement.getOrigin() == null ) {
|
||||
owner = fromElement;
|
||||
break;
|
||||
@ -560,7 +565,7 @@ else if ( walker.getStatementType() == HqlSqlTokenTypes.INSERT ) {
|
||||
throw new QueryException( "Unexpected statement type" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParameterTranslations getParameterTranslations() {
|
||||
if ( paramTranslations == null ) {
|
||||
paramTranslations = new ParameterTranslationsImpl( getWalker().getParameters() );
|
||||
@ -581,6 +586,7 @@ public Class getDynamicInstantiationResultType() {
|
||||
|
||||
public static class JavaConstantConverter implements NodeTraverser.VisitationStrategy {
|
||||
private AST dotRoot;
|
||||
@Override
|
||||
public void visit(AST node) {
|
||||
if ( dotRoot != null ) {
|
||||
// we are already processing a dot-structure
|
||||
@ -589,7 +595,7 @@ public void visit(AST node) {
|
||||
dotRoot = null;
|
||||
}
|
||||
|
||||
if ( dotRoot == null && node.getType() == HqlTokenTypes.DOT ) {
|
||||
if ( node.getType() == HqlTokenTypes.DOT ) {
|
||||
dotRoot = node;
|
||||
handleDotStructure( dotRoot );
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
*
|
||||
*/
|
||||
package org.hibernate.hql.internal.ast.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -58,8 +59,8 @@
|
||||
*/
|
||||
public class SessionFactoryHelper {
|
||||
|
||||
private SessionFactoryImplementor sfi;
|
||||
private Map collectionPropertyMappingByRole;
|
||||
private final SessionFactoryImplementor sfi;
|
||||
private final Map<String, PropertyMapping> collectionPropertyMappingByRole;
|
||||
|
||||
/**
|
||||
* Construct a new SessionFactoryHelper instance.
|
||||
@ -68,7 +69,7 @@ public class SessionFactoryHelper {
|
||||
*/
|
||||
public SessionFactoryHelper(SessionFactoryImplementor sfi) {
|
||||
this.sfi = sfi;
|
||||
collectionPropertyMappingByRole = new HashMap();
|
||||
this.collectionPropertyMappingByRole = new HashMap<String, PropertyMapping>();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,6 +86,7 @@ public SessionFactoryImplementor getFactory() {
|
||||
* for the purpose of inheritance discrimination?
|
||||
*
|
||||
* @param persister The persister to be checked.
|
||||
*
|
||||
* @return True if the persister does define an actual discriminator column.
|
||||
*/
|
||||
public boolean hasPhysicalDiscriminatorColumn(Queryable persister) {
|
||||
@ -103,6 +105,7 @@ public boolean hasPhysicalDiscriminatorColumn(Queryable persister) {
|
||||
* Given a (potentially unqualified) class name, locate its imported qualified name.
|
||||
*
|
||||
* @param className The potentially unqualified class name
|
||||
*
|
||||
* @return The qualified class name.
|
||||
*/
|
||||
public String getImportedClassName(String className) {
|
||||
@ -113,6 +116,7 @@ public String getImportedClassName(String className) {
|
||||
* Given a (potentially unqualified) class name, locate its persister.
|
||||
*
|
||||
* @param className The (potentially unqualified) class name.
|
||||
*
|
||||
* @return The defined persister for this class, or null if none found.
|
||||
*/
|
||||
public Queryable findQueryableUsingImports(String className) {
|
||||
@ -125,6 +129,7 @@ public Queryable findQueryableUsingImports(String className) {
|
||||
*
|
||||
* @param sfi The session factory implementor.
|
||||
* @param className The (potentially unqualified) class name.
|
||||
*
|
||||
* @return The defined persister for this class, or null if none found.
|
||||
*/
|
||||
public static Queryable findQueryableUsingImports(SessionFactoryImplementor sfi, String className) {
|
||||
@ -133,7 +138,7 @@ public static Queryable findQueryableUsingImports(SessionFactoryImplementor sfi,
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return ( Queryable ) sfi.getEntityPersister( importedClassName );
|
||||
return (Queryable) sfi.getEntityPersister( importedClassName );
|
||||
}
|
||||
catch ( MappingException me ) {
|
||||
return null;
|
||||
@ -144,7 +149,9 @@ public static Queryable findQueryableUsingImports(SessionFactoryImplementor sfi,
|
||||
* Locate the persister by class or entity name.
|
||||
*
|
||||
* @param name The class or entity name
|
||||
*
|
||||
* @return The defined persister for this entity, or null if none found.
|
||||
*
|
||||
* @throws MappingException
|
||||
*/
|
||||
private EntityPersister findEntityPersisterByName(String name) throws MappingException {
|
||||
@ -169,7 +176,9 @@ private EntityPersister findEntityPersisterByName(String name) throws MappingExc
|
||||
* exist.
|
||||
*
|
||||
* @param name The class or entity name
|
||||
*
|
||||
* @return The defined persister for this entity
|
||||
*
|
||||
* @throws SemanticException Indicates the persister could not be found
|
||||
*/
|
||||
public EntityPersister requireClassPersister(String name) throws SemanticException {
|
||||
@ -190,11 +199,12 @@ public EntityPersister requireClassPersister(String name) throws SemanticExcepti
|
||||
* Locate the collection persister by the collection role.
|
||||
*
|
||||
* @param role The collection role name.
|
||||
*
|
||||
* @return The defined CollectionPersister for this collection role, or null.
|
||||
*/
|
||||
public QueryableCollection getCollectionPersister(String role) {
|
||||
try {
|
||||
return ( QueryableCollection ) sfi.getCollectionPersister( role );
|
||||
return (QueryableCollection) sfi.getCollectionPersister( role );
|
||||
}
|
||||
catch ( ClassCastException cce ) {
|
||||
throw new QueryException( "collection is not queryable: " + role );
|
||||
@ -209,12 +219,14 @@ public QueryableCollection getCollectionPersister(String role) {
|
||||
* such a persister exist.
|
||||
*
|
||||
* @param role The collection role name.
|
||||
*
|
||||
* @return The defined CollectionPersister for this collection role.
|
||||
*
|
||||
* @throws QueryException Indicates that the collection persister could not be found.
|
||||
*/
|
||||
public QueryableCollection requireQueryableCollection(String role) throws QueryException {
|
||||
try {
|
||||
QueryableCollection queryableCollection = ( QueryableCollection ) sfi.getCollectionPersister( role );
|
||||
QueryableCollection queryableCollection = (QueryableCollection) sfi.getCollectionPersister( role );
|
||||
if ( queryableCollection != null ) {
|
||||
collectionPropertyMappingByRole.put( role, new CollectionPropertyMapping( queryableCollection ) );
|
||||
}
|
||||
@ -232,10 +244,11 @@ public QueryableCollection requireQueryableCollection(String role) throws QueryE
|
||||
* Retrieve a PropertyMapping describing the given collection role.
|
||||
*
|
||||
* @param role The collection role for which to retrieve the property mapping.
|
||||
*
|
||||
* @return The property mapping.
|
||||
*/
|
||||
public PropertyMapping getCollectionPropertyMapping(String role) {
|
||||
return ( PropertyMapping ) collectionPropertyMappingByRole.get( role );
|
||||
return collectionPropertyMappingByRole.get( role );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -244,6 +257,7 @@ public PropertyMapping getCollectionPropertyMapping(String role) {
|
||||
*
|
||||
* @param role The collection role
|
||||
* @param roleAlias The sql column-qualification alias (i.e., the table alias)
|
||||
*
|
||||
* @return the collection element columns
|
||||
*/
|
||||
public String[] getCollectionElementColumns(String role, String roleAlias) {
|
||||
@ -267,11 +281,12 @@ public JoinSequence createJoinSequence() {
|
||||
* @param tableAlias The table alias to use in qualifying the join conditions
|
||||
* @param joinType The type of join to render (inner, outer, etc); see {@link org.hibernate.sql.JoinFragment}
|
||||
* @param columns The columns making up the condition of the join.
|
||||
*
|
||||
* @return The generated join sequence.
|
||||
*/
|
||||
public JoinSequence createJoinSequence(boolean implicit, AssociationType associationType, String tableAlias, JoinType joinType, String[] columns) {
|
||||
JoinSequence joinSequence = createJoinSequence();
|
||||
joinSequence.setUseThetaStyle( implicit ); // Implicit joins use theta style (WHERE pk = fk), explicit joins use JOIN (after from)
|
||||
joinSequence.setUseThetaStyle( implicit ); // Implicit joins use theta style (WHERE pk = fk), explicit joins use JOIN (after from)
|
||||
joinSequence.addJoin( associationType, tableAlias, joinType, columns );
|
||||
return joinSequence;
|
||||
}
|
||||
@ -281,12 +296,13 @@ public JoinSequence createJoinSequence(boolean implicit, AssociationType associa
|
||||
*
|
||||
* @param collPersister The persister for the collection at which the join should be rooted.
|
||||
* @param collectionName The alias to use for qualifying column references.
|
||||
*
|
||||
* @return The generated join sequence.
|
||||
*/
|
||||
public JoinSequence createCollectionJoinSequence(QueryableCollection collPersister, String collectionName) {
|
||||
JoinSequence joinSequence = createJoinSequence();
|
||||
joinSequence.setRoot( collPersister, collectionName );
|
||||
joinSequence.setUseThetaStyle( true ); // TODO: figure out how this should be set.
|
||||
joinSequence.setUseThetaStyle( true ); // TODO: figure out how this should be set.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// This was the reason for failures regarding INDEX_OP and subclass joins on
|
||||
// theta-join dialects; not sure what behavior we were trying to emulate ;)
|
||||
@ -299,7 +315,9 @@ public JoinSequence createCollectionJoinSequence(QueryableCollection collPersist
|
||||
* given type which represents the id or unique-key.
|
||||
*
|
||||
* @param entityType The type representing the entity.
|
||||
*
|
||||
* @return The corresponding property name
|
||||
*
|
||||
* @throws QueryException Indicates such a property could not be found.
|
||||
*/
|
||||
public String getIdentifierOrUniqueKeyPropertyName(EntityType entityType) {
|
||||
@ -315,6 +333,7 @@ public String getIdentifierOrUniqueKeyPropertyName(EntityType entityType) {
|
||||
* Retrieve the number of columns represented by this type.
|
||||
*
|
||||
* @param type The type.
|
||||
*
|
||||
* @return The number of columns.
|
||||
*/
|
||||
public int getColumnSpan(Type type) {
|
||||
@ -326,6 +345,7 @@ public int getColumnSpan(Type type) {
|
||||
* contained within instance of that collection.
|
||||
*
|
||||
* @param collectionType The collection type to check.
|
||||
*
|
||||
* @return The entity name of the elements of this collection.
|
||||
*/
|
||||
public String getAssociatedEntityName(CollectionType collectionType) {
|
||||
@ -337,6 +357,7 @@ public String getAssociatedEntityName(CollectionType collectionType) {
|
||||
* within instances of that collection.
|
||||
*
|
||||
* @param collectionType The collection type to be checked.
|
||||
*
|
||||
* @return The Type of the elements of the collection.
|
||||
*/
|
||||
private Type getElementType(CollectionType collectionType) {
|
||||
@ -348,16 +369,18 @@ private Type getElementType(CollectionType collectionType) {
|
||||
* element type be an association type.
|
||||
*
|
||||
* @param collectionType The collection type to be checked.
|
||||
*
|
||||
* @return The AssociationType of the elements of the collection.
|
||||
*/
|
||||
public AssociationType getElementAssociationType(CollectionType collectionType) {
|
||||
return ( AssociationType ) getElementType( collectionType );
|
||||
return (AssociationType) getElementType( collectionType );
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate a registered sql function by name.
|
||||
*
|
||||
* @param functionName The name of the function to locate
|
||||
*
|
||||
* @return The sql function, or null if not found.
|
||||
*/
|
||||
public SQLFunction findSQLFunction(String functionName) {
|
||||
@ -368,7 +391,9 @@ public SQLFunction findSQLFunction(String functionName) {
|
||||
* Locate a registered sql function by name, requiring that such a registered function exist.
|
||||
*
|
||||
* @param functionName The name of the function to locate
|
||||
*
|
||||
* @return The sql function.
|
||||
*
|
||||
* @throws QueryException Indicates no matching sql functions could be found.
|
||||
*/
|
||||
private SQLFunction requireSQLFunction(String functionName) {
|
||||
@ -383,7 +408,8 @@ private SQLFunction requireSQLFunction(String functionName) {
|
||||
* Find the function return type given the function name and the first argument expression node.
|
||||
*
|
||||
* @param functionName The function name.
|
||||
* @param first The first argument expression.
|
||||
* @param first The first argument expression.
|
||||
*
|
||||
* @return the function return type given the function name and the first argument expression node.
|
||||
*/
|
||||
public Type findFunctionReturnType(String functionName, AST first) {
|
||||
@ -395,7 +421,7 @@ public Type findFunctionReturnType(String functionName, SQLFunction sqlFunction,
|
||||
// determine the type of the first argument...
|
||||
Type argumentType = null;
|
||||
if ( firstArgument != null ) {
|
||||
if ( "cast".equals(functionName) ) {
|
||||
if ( "cast".equals( functionName ) ) {
|
||||
argumentType = sfi.getTypeResolver().heuristicType( firstArgument.getNextSibling().getText() );
|
||||
}
|
||||
else if ( SqlNode.class.isInstance( firstArgument ) ) {
|
||||
|
@ -57,15 +57,15 @@ public class CriteriaImpl implements Criteria, Serializable {
|
||||
private transient SessionImplementor session;
|
||||
private final String rootAlias;
|
||||
|
||||
private List criterionEntries = new ArrayList();
|
||||
private List orderEntries = new ArrayList();
|
||||
private List<CriterionEntry> criterionEntries = new ArrayList<CriterionEntry>();
|
||||
private List<OrderEntry> orderEntries = new ArrayList<OrderEntry>();
|
||||
private Projection projection;
|
||||
private Criteria projectionCriteria;
|
||||
|
||||
private List subcriteriaList = new ArrayList();
|
||||
private List<Subcriteria> subcriteriaList = new ArrayList<Subcriteria>();
|
||||
|
||||
private Map fetchModes = new HashMap();
|
||||
private Map lockModes = new HashMap();
|
||||
private Map<String, FetchMode> fetchModes = new HashMap<String, FetchMode>();
|
||||
private Map<String, LockMode> lockModes = new HashMap<String, LockMode>();
|
||||
|
||||
private Integer maxResults;
|
||||
private Integer firstResult;
|
||||
@ -98,7 +98,7 @@ public CriteriaImpl(String entityOrClassName, String alias, SessionImplementor s
|
||||
this.cacheable = false;
|
||||
this.rootAlias = alias;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CriteriaImpl(" +
|
||||
entityOrClassName + ":" +
|
||||
@ -124,7 +124,7 @@ public String getEntityOrClassName() {
|
||||
return entityOrClassName;
|
||||
}
|
||||
|
||||
public Map getLockModes() {
|
||||
public Map<String, LockMode> getLockModes() {
|
||||
return lockModes;
|
||||
}
|
||||
|
||||
@ -132,15 +132,15 @@ public Criteria getProjectionCriteria() {
|
||||
return projectionCriteria;
|
||||
}
|
||||
|
||||
public Iterator iterateSubcriteria() {
|
||||
public Iterator<Subcriteria> iterateSubcriteria() {
|
||||
return subcriteriaList.iterator();
|
||||
}
|
||||
|
||||
public Iterator iterateExpressionEntries() {
|
||||
public Iterator<CriterionEntry> iterateExpressionEntries() {
|
||||
return criterionEntries.iterator();
|
||||
}
|
||||
|
||||
public Iterator iterateOrderings() {
|
||||
public Iterator<OrderEntry> iterateOrderings() {
|
||||
return orderEntries.iterator();
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ public Criteria add(Criteria criteriaInst, Criterion expression) {
|
||||
|
||||
|
||||
// Criteria impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@Override
|
||||
public String getAlias() {
|
||||
return rootAlias;
|
||||
}
|
||||
@ -159,46 +159,45 @@ public String getAlias() {
|
||||
public Projection getProjection() {
|
||||
return projection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setProjection(Projection projection) {
|
||||
this.projection = projection;
|
||||
this.projectionCriteria = this;
|
||||
setResultTransformer( PROJECTION );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria add(Criterion expression) {
|
||||
add( this, expression );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria addOrder(Order ordering) {
|
||||
orderEntries.add( new OrderEntry( ordering, this ) );
|
||||
return this;
|
||||
}
|
||||
|
||||
public FetchMode getFetchMode(String path) {
|
||||
return (FetchMode) fetchModes.get(path);
|
||||
return fetchModes.get(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setFetchMode(String associationPath, FetchMode mode) {
|
||||
fetchModes.put( associationPath, mode );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setLockMode(LockMode lockMode) {
|
||||
return setLockMode( getAlias(), lockMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setLockMode(String alias, LockMode lockMode) {
|
||||
lockModes.put( alias, lockMode );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria createAlias(String associationPath, String alias) {
|
||||
return createAlias( associationPath, alias, JoinType.INNER_JOIN );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria createAlias(String associationPath, String alias, JoinType joinType) {
|
||||
new Subcriteria( this, associationPath, alias, joinType );
|
||||
return this;
|
||||
@ -208,7 +207,7 @@ public Criteria createAlias(String associationPath, String alias, JoinType joinT
|
||||
public Criteria createAlias(String associationPath, String alias, int joinType) throws HibernateException {
|
||||
return createAlias( associationPath, alias, JoinType.parse( joinType ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria createAlias(String associationPath, String alias, JoinType joinType, Criterion withClause) {
|
||||
new Subcriteria( this, associationPath, alias, joinType, withClause );
|
||||
return this;
|
||||
@ -219,11 +218,11 @@ public Criteria createAlias(String associationPath, String alias, int joinType,
|
||||
throws HibernateException {
|
||||
return createAlias( associationPath, alias, JoinType.parse( joinType ), withClause );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria createCriteria(String associationPath) {
|
||||
return createCriteria( associationPath, JoinType.INNER_JOIN );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria createCriteria(String associationPath, JoinType joinType) {
|
||||
return new Subcriteria( this, associationPath, joinType );
|
||||
}
|
||||
@ -232,11 +231,11 @@ public Criteria createCriteria(String associationPath, JoinType joinType) {
|
||||
public Criteria createCriteria(String associationPath, int joinType) throws HibernateException {
|
||||
return createCriteria(associationPath, JoinType.parse( joinType ));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria createCriteria(String associationPath, String alias) {
|
||||
return createCriteria( associationPath, alias, JoinType.INNER_JOIN );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria createCriteria(String associationPath, String alias, JoinType joinType) {
|
||||
return new Subcriteria( this, associationPath, alias, joinType );
|
||||
}
|
||||
@ -245,7 +244,7 @@ public Criteria createCriteria(String associationPath, String alias, JoinType jo
|
||||
public Criteria createCriteria(String associationPath, String alias, int joinType) throws HibernateException {
|
||||
return createCriteria( associationPath, alias, JoinType.parse( joinType ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria createCriteria(String associationPath, String alias, JoinType joinType, Criterion withClause) {
|
||||
return new Subcriteria( this, associationPath, alias, joinType, withClause );
|
||||
}
|
||||
@ -259,7 +258,7 @@ public Criteria createCriteria(String associationPath, String alias, int joinTyp
|
||||
public ResultTransformer getResultTransformer() {
|
||||
return resultTransformer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setResultTransformer(ResultTransformer tupleMapper) {
|
||||
this.resultTransformer = tupleMapper;
|
||||
return this;
|
||||
@ -268,7 +267,7 @@ public Criteria setResultTransformer(ResultTransformer tupleMapper) {
|
||||
public Integer getMaxResults() {
|
||||
return maxResults;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setMaxResults(int maxResults) {
|
||||
this.maxResults = maxResults;
|
||||
return this;
|
||||
@ -277,7 +276,7 @@ public Criteria setMaxResults(int maxResults) {
|
||||
public Integer getFirstResult() {
|
||||
return firstResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setFirstResult(int firstResult) {
|
||||
this.firstResult = firstResult;
|
||||
return this;
|
||||
@ -286,7 +285,7 @@ public Criteria setFirstResult(int firstResult) {
|
||||
public Integer getFetchSize() {
|
||||
return fetchSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setFetchSize(int fetchSize) {
|
||||
this.fetchSize = fetchSize;
|
||||
return this;
|
||||
@ -295,22 +294,18 @@ public Criteria setFetchSize(int fetchSize) {
|
||||
public Integer getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setTimeout(int timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isReadOnlyInitialized() {
|
||||
return readOnly != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isReadOnly() {
|
||||
if ( ! isReadOnlyInitialized() && getSession() == null ) {
|
||||
throw new IllegalStateException(
|
||||
@ -318,23 +313,21 @@ public boolean isReadOnly() {
|
||||
);
|
||||
}
|
||||
return ( isReadOnlyInitialized() ?
|
||||
readOnly.booleanValue() :
|
||||
readOnly :
|
||||
getSession().getPersistenceContext().isDefaultReadOnly()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Criteria setReadOnly(boolean readOnly) {
|
||||
this.readOnly = Boolean.valueOf( readOnly );
|
||||
this.readOnly = readOnly;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getCacheable() {
|
||||
return this.cacheable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setCacheable(boolean cacheable) {
|
||||
this.cacheable = cacheable;
|
||||
return this;
|
||||
@ -343,7 +336,7 @@ public Criteria setCacheable(boolean cacheable) {
|
||||
public String getCacheRegion() {
|
||||
return this.cacheRegion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setCacheRegion(String cacheRegion) {
|
||||
this.cacheRegion = cacheRegion.trim();
|
||||
return this;
|
||||
@ -352,22 +345,22 @@ public Criteria setCacheRegion(String cacheRegion) {
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setComment(String comment) {
|
||||
this.comment = comment;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setFlushMode(FlushMode flushMode) {
|
||||
this.flushMode = flushMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setCacheMode(CacheMode cacheMode) {
|
||||
this.cacheMode = cacheMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List list() throws HibernateException {
|
||||
before();
|
||||
try {
|
||||
@ -377,11 +370,11 @@ public List list() throws HibernateException {
|
||||
after();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScrollableResults scroll() {
|
||||
return scroll( ScrollMode.SCROLL_INSENSITIVE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScrollableResults scroll(ScrollMode scrollMode) {
|
||||
before();
|
||||
try {
|
||||
@ -391,7 +384,7 @@ public ScrollableResults scroll(ScrollMode scrollMode) {
|
||||
after();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object uniqueResult() throws HibernateException {
|
||||
return AbstractQueryImpl.uniqueElement( list() );
|
||||
}
|
||||
@ -428,7 +421,7 @@ public boolean isLookupByNaturalKey() {
|
||||
if ( criterionEntries.size() != 1 ) {
|
||||
return false;
|
||||
}
|
||||
CriterionEntry ce = (CriterionEntry) criterionEntries.get(0);
|
||||
CriterionEntry ce = criterionEntries.get(0);
|
||||
return ce.getCriterion() instanceof NaturalIdentifier;
|
||||
}
|
||||
|
||||
@ -464,7 +457,7 @@ private Subcriteria(Criteria parent, String path, String alias, JoinType joinTyp
|
||||
private Subcriteria(Criteria parent, String path, JoinType joinType) {
|
||||
this( parent, path, null, joinType );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Subcriteria("
|
||||
+ path + ":"
|
||||
@ -474,7 +467,7 @@ public String toString() {
|
||||
|
||||
|
||||
// State ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@Override
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
}
|
||||
@ -494,7 +487,7 @@ public Criteria getParent() {
|
||||
public LockMode getLockMode() {
|
||||
return lockMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setLockMode(LockMode lockMode) {
|
||||
this.lockMode = lockMode;
|
||||
return this;
|
||||
@ -513,22 +506,22 @@ public boolean hasRestriction() {
|
||||
}
|
||||
|
||||
// Criteria impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@Override
|
||||
public Criteria add(Criterion expression) {
|
||||
hasRestriction = true;
|
||||
CriteriaImpl.this.add(this, expression);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria addOrder(Order order) {
|
||||
CriteriaImpl.this.orderEntries.add( new OrderEntry(order, this) );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria createAlias(String associationPath, String alias) {
|
||||
return createAlias( associationPath, alias, JoinType.INNER_JOIN );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria createAlias(String associationPath, String alias, JoinType joinType) throws HibernateException {
|
||||
new Subcriteria( this, associationPath, alias, joinType );
|
||||
return this;
|
||||
@ -538,7 +531,7 @@ public Criteria createAlias(String associationPath, String alias, JoinType joinT
|
||||
public Criteria createAlias(String associationPath, String alias, int joinType) throws HibernateException {
|
||||
return createAlias( associationPath, alias, JoinType.parse( joinType ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria createAlias(String associationPath, String alias, JoinType joinType, Criterion withClause) throws HibernateException {
|
||||
new Subcriteria( this, associationPath, alias, joinType, withClause );
|
||||
return this;
|
||||
@ -549,11 +542,11 @@ public Criteria createAlias(String associationPath, String alias, int joinType,
|
||||
throws HibernateException {
|
||||
return createAlias( associationPath, alias, JoinType.parse( joinType ), withClause );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria createCriteria(String associationPath) {
|
||||
return createCriteria( associationPath, JoinType.INNER_JOIN );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria createCriteria(String associationPath, JoinType joinType) throws HibernateException {
|
||||
return new Subcriteria( Subcriteria.this, associationPath, joinType );
|
||||
}
|
||||
@ -562,11 +555,11 @@ public Criteria createCriteria(String associationPath, JoinType joinType) throws
|
||||
public Criteria createCriteria(String associationPath, int joinType) throws HibernateException {
|
||||
return createCriteria( associationPath, JoinType.parse( joinType ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria createCriteria(String associationPath, String alias) {
|
||||
return createCriteria( associationPath, alias, JoinType.INNER_JOIN );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria createCriteria(String associationPath, String alias, JoinType joinType) throws HibernateException {
|
||||
return new Subcriteria( Subcriteria.this, associationPath, alias, joinType );
|
||||
}
|
||||
@ -575,7 +568,7 @@ public Criteria createCriteria(String associationPath, String alias, JoinType jo
|
||||
public Criteria createCriteria(String associationPath, String alias, int joinType) throws HibernateException {
|
||||
return createCriteria( associationPath, alias, JoinType.parse( joinType ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria createCriteria(String associationPath, String alias, JoinType joinType, Criterion withClause) throws HibernateException {
|
||||
return new Subcriteria( this, associationPath, alias, joinType, withClause );
|
||||
}
|
||||
@ -585,96 +578,96 @@ public Criteria createCriteria(String associationPath, String alias, int joinTyp
|
||||
throws HibernateException {
|
||||
return createCriteria( associationPath, alias, JoinType.parse( joinType ), withClause );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly() {
|
||||
return CriteriaImpl.this.isReadOnly();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnlyInitialized() {
|
||||
return CriteriaImpl.this.isReadOnlyInitialized();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setReadOnly(boolean readOnly) {
|
||||
CriteriaImpl.this.setReadOnly( readOnly );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setCacheable(boolean cacheable) {
|
||||
CriteriaImpl.this.setCacheable(cacheable);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setCacheRegion(String cacheRegion) {
|
||||
CriteriaImpl.this.setCacheRegion(cacheRegion);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List list() throws HibernateException {
|
||||
return CriteriaImpl.this.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScrollableResults scroll() throws HibernateException {
|
||||
return CriteriaImpl.this.scroll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScrollableResults scroll(ScrollMode scrollMode) throws HibernateException {
|
||||
return CriteriaImpl.this.scroll(scrollMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object uniqueResult() throws HibernateException {
|
||||
return CriteriaImpl.this.uniqueResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setFetchMode(String associationPath, FetchMode mode) {
|
||||
CriteriaImpl.this.setFetchMode( StringHelper.qualify(path, associationPath), mode);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setFlushMode(FlushMode flushMode) {
|
||||
CriteriaImpl.this.setFlushMode(flushMode);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setCacheMode(CacheMode cacheMode) {
|
||||
CriteriaImpl.this.setCacheMode(cacheMode);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setFirstResult(int firstResult) {
|
||||
CriteriaImpl.this.setFirstResult(firstResult);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setMaxResults(int maxResults) {
|
||||
CriteriaImpl.this.setMaxResults(maxResults);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setTimeout(int timeout) {
|
||||
CriteriaImpl.this.setTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setFetchSize(int fetchSize) {
|
||||
CriteriaImpl.this.setFetchSize(fetchSize);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setLockMode(String alias, LockMode lockMode) {
|
||||
CriteriaImpl.this.setLockMode(alias, lockMode);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setResultTransformer(ResultTransformer resultProcessor) {
|
||||
CriteriaImpl.this.setResultTransformer(resultProcessor);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setComment(String comment) {
|
||||
CriteriaImpl.this.setComment(comment);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Criteria setProjection(Projection projection) {
|
||||
CriteriaImpl.this.projection = projection;
|
||||
CriteriaImpl.this.projectionCriteria = this;
|
||||
@ -699,7 +692,7 @@ public Criterion getCriterion() {
|
||||
public Criteria getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return criterion.toString();
|
||||
}
|
||||
@ -721,7 +714,7 @@ public Order getOrder() {
|
||||
public Criteria getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return order.toString();
|
||||
}
|
||||
|
@ -38,47 +38,50 @@
|
||||
*/
|
||||
|
||||
class ComponentCollectionCriteriaInfoProvider implements CriteriaInfoProvider {
|
||||
QueryableCollection persister;
|
||||
Map /* <String,Type> */ subTypes = new HashMap /* <String,Type> */();
|
||||
private final QueryableCollection persister;
|
||||
private final Map<String, Type> subTypes = new HashMap<String, Type>();
|
||||
|
||||
ComponentCollectionCriteriaInfoProvider(QueryableCollection persister) {
|
||||
this.persister = persister;
|
||||
if ( !persister.getElementType().isComponentType() ) {
|
||||
throw new IllegalArgumentException( "persister for role " + persister.getRole() + " is not a collection-of-component" );
|
||||
}
|
||||
|
||||
ComponentType componentType = (ComponentType) persister.getElementType();
|
||||
String[] names = componentType.getPropertyNames();
|
||||
Type[] types = componentType.getSubtypes();
|
||||
|
||||
for ( int i = 0; i < names.length; i++ ) {
|
||||
subTypes.put( names[i], types[i] );
|
||||
}
|
||||
|
||||
ComponentCollectionCriteriaInfoProvider(QueryableCollection persister) {
|
||||
this.persister = persister;
|
||||
if (!persister.getElementType().isComponentType()) {
|
||||
throw new IllegalArgumentException("persister for role "+persister.getRole()+" is not a collection-of-component");
|
||||
}
|
||||
|
||||
ComponentType componentType = (ComponentType)persister.getElementType();
|
||||
String[] names = componentType.getPropertyNames();
|
||||
Type[] types = componentType.getSubtypes();
|
||||
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
subTypes.put(names[i], types[i]);
|
||||
@Override
|
||||
public String getName() {
|
||||
return persister.getRole();
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public Serializable[] getSpaces() {
|
||||
return persister.getCollectionSpaces();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return persister.getRole();
|
||||
}
|
||||
@Override
|
||||
public PropertyMapping getPropertyMapping() {
|
||||
return persister;
|
||||
}
|
||||
|
||||
public Serializable[] getSpaces() {
|
||||
return persister.getCollectionSpaces();
|
||||
}
|
||||
|
||||
public PropertyMapping getPropertyMapping() {
|
||||
return persister;
|
||||
}
|
||||
|
||||
public Type getType(String relativePath) {
|
||||
// TODO: can a component have a nested component? then we may need to do something more here...
|
||||
if (relativePath.indexOf('.') >= 0)
|
||||
throw new IllegalArgumentException("dotted paths not handled (yet?!) for collection-of-component");
|
||||
|
||||
Type type = (Type)subTypes.get(relativePath);
|
||||
|
||||
if (type == null)
|
||||
throw new IllegalArgumentException("property "+relativePath+" not found in component of collection "+getName());
|
||||
|
||||
return type;
|
||||
}
|
||||
@Override
|
||||
public Type getType(String relativePath) {
|
||||
// TODO: can a component have a nested component? then we may need to do something more here...
|
||||
if ( relativePath.indexOf( '.' ) >= 0 ) {
|
||||
throw new IllegalArgumentException( "dotted paths not handled (yet?!) for collection-of-component" );
|
||||
}
|
||||
Type type = subTypes.get( relativePath );
|
||||
if ( type == null ) {
|
||||
throw new IllegalArgumentException( "property " + relativePath + " not found in component of collection " + getName() );
|
||||
}
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
@ -66,9 +66,9 @@ public class CriteriaJoinWalker extends AbstractEntityJoinWalker {
|
||||
//the user visible aliases, which are unknown to the superclass,
|
||||
//these are not the actual "physical" SQL aliases
|
||||
private final String[] userAliases;
|
||||
private final List userAliasList = new ArrayList();
|
||||
private final List resultTypeList = new ArrayList();
|
||||
private final List includeInResultRowList = new ArrayList();
|
||||
private final List<String> userAliasList = new ArrayList<String>();
|
||||
private final List<Type> resultTypeList = new ArrayList<Type>();
|
||||
private final List<Boolean> includeInResultRowList = new ArrayList<Boolean>();
|
||||
|
||||
public Type[] getResultTypes() {
|
||||
return resultTypes;
|
||||
@ -130,7 +130,7 @@ public CriteriaJoinWalker(
|
||||
includeInResultRow = ArrayHelper.toBooleanArray( includeInResultRowList );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JoinType getJoinType(
|
||||
OuterJoinLoadable persister,
|
||||
final PropertyPath path,
|
||||
@ -207,7 +207,7 @@ else if ( isTooDeep(currentDepth) || ( associationType.isCollectionType() && isT
|
||||
}
|
||||
return resolvedJoinType;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JoinType getJoinType(
|
||||
AssociationType associationType,
|
||||
FetchMode config,
|
||||
@ -239,11 +239,12 @@ private static boolean isDefaultFetchMode(FetchMode fetchMode) {
|
||||
* Use the discriminator, to narrow the select to instances
|
||||
* of the queried subclass, also applying any filters.
|
||||
*/
|
||||
@Override
|
||||
protected String getWhereFragment() throws MappingException {
|
||||
return super.getWhereFragment() +
|
||||
( (Queryable) getPersister() ).filterFragment( getAlias(), getLoadQueryInfluencers().getEnabledFilters() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String generateTableAlias(int n, PropertyPath path, Joinable joinable) {
|
||||
// TODO: deal with side-effects (changes to includeInResultRowList, userAliasList, resultTypeList)!!!
|
||||
|
||||
@ -288,7 +289,7 @@ protected String generateTableAlias(int n, PropertyPath path, Joinable joinable)
|
||||
|
||||
return sqlAlias;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String generateRootAlias(String tableName) {
|
||||
return CriteriaQueryTranslator.ROOT_SQL_ALIAS;
|
||||
}
|
||||
@ -296,15 +297,15 @@ protected String generateRootAlias(String tableName) {
|
||||
public Set getQuerySpaces() {
|
||||
return querySpaces;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComment() {
|
||||
return "criteria query";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getWithClause(PropertyPath path) {
|
||||
return translator.getWithClause( path.getFullPath() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasRestriction(PropertyPath path) {
|
||||
return translator.hasRestriction( path.getFullPath() );
|
||||
}
|
||||
|
@ -125,23 +125,23 @@ public List list(SessionImplementor session)
|
||||
return list( session, translator.getQueryParameters(), querySpaces, resultTypes );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getResultRowAliases() {
|
||||
return userAliases;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResultTransformer resolveResultTransformer(ResultTransformer resultTransformer) {
|
||||
return translator.getRootCriteria().getResultTransformer();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean areResultSetRowsTransformedImmediately() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean[] includeInResultRow() {
|
||||
return includeInResultRow;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getResultColumnOrRow(Object[] row, ResultTransformer transformer, ResultSet rs, SessionImplementor session)
|
||||
throws SQLException, HibernateException {
|
||||
return resolveResultTransformer( transformer ).transformTuple(
|
||||
@ -149,7 +149,7 @@ protected Object getResultColumnOrRow(Object[] row, ResultTransformer transforme
|
||||
getResultRowAliases()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object[] getResultRow(Object[] row, ResultSet rs, SessionImplementor session)
|
||||
throws SQLException, HibernateException {
|
||||
final Object[] result;
|
||||
@ -249,7 +249,7 @@ public void afterLoad(SessionImplementor session, Object entity, Loadable persis
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected LockMode determineFollowOnLockMode(LockOptions lockOptions) {
|
||||
final LockMode lockModeToUse = lockOptions.findGreatestLockMode();
|
||||
|
||||
@ -260,7 +260,7 @@ protected LockMode determineFollowOnLockMode(LockOptions lockOptions) {
|
||||
|
||||
return lockModeToUse;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LockMode[] getLockModes(LockOptions lockOptions) {
|
||||
final String[] entityAliases = getAliases();
|
||||
if ( entityAliases == null ) {
|
||||
@ -274,15 +274,15 @@ protected LockMode[] getLockModes(LockOptions lockOptions) {
|
||||
}
|
||||
return lockModesArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isSubselectLoadingEnabled() {
|
||||
return hasSubselectLoadableCollections();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List getResultList(List results, ResultTransformer resultTransformer) {
|
||||
return resolveResultTransformer( resultTransformer ).transformList( results );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getQueryIdentifier() {
|
||||
return "[CRITERIA] " + getSQLString();
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
*
|
||||
*/
|
||||
package org.hibernate.loader.criteria;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@ -74,15 +75,14 @@ public class CriteriaQueryTranslator implements CriteriaQuery {
|
||||
private final CriteriaImpl rootCriteria;
|
||||
private final String rootEntityName;
|
||||
private final String rootSQLAlias;
|
||||
private int aliasCount = 0;
|
||||
|
||||
private final Map /* <Criteria, CriteriaInfoProvider> */ criteriaInfoMap = new LinkedHashMap();
|
||||
private final Map /* <String, CriteriaInfoProvider> */ nameCriteriaInfoMap = new LinkedHashMap();
|
||||
private final Map criteriaSQLAliasMap = new HashMap();
|
||||
private final Map aliasCriteriaMap = new HashMap();
|
||||
private final Map associationPathCriteriaMap = new LinkedHashMap();
|
||||
private final Map<String,JoinType> associationPathJoinTypesMap = new LinkedHashMap<String,JoinType>();
|
||||
private final Map withClauseMap = new HashMap();
|
||||
private final Map<Criteria, CriteriaInfoProvider> criteriaInfoMap = new LinkedHashMap<Criteria, CriteriaInfoProvider>();
|
||||
private final Map<String, CriteriaInfoProvider> nameCriteriaInfoMap = new LinkedHashMap<String, CriteriaInfoProvider>();
|
||||
private final Map<Criteria, String> criteriaSQLAliasMap = new HashMap<Criteria, String>();
|
||||
private final Map<String, Criteria> aliasCriteriaMap = new HashMap<String, Criteria>();
|
||||
private final Map<String, Criteria> associationPathCriteriaMap = new LinkedHashMap<String, Criteria>();
|
||||
private final Map<String, JoinType> associationPathJoinTypesMap = new LinkedHashMap<String,JoinType>();
|
||||
private final Map<String, Criterion> withClauseMap = new HashMap<String, Criterion>();
|
||||
|
||||
private final SessionFactoryImplementor sessionFactory;
|
||||
private final SessionFactoryHelper helper;
|
||||
@ -112,8 +112,9 @@ public CriteriaQueryTranslator(
|
||||
createCriteriaEntityNameMap();
|
||||
createCriteriaSQLAliasMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateSQLAlias() {
|
||||
int aliasCount = 0;
|
||||
return StringHelper.generateAlias( Criteria.ROOT_ALIAS, aliasCount ) + '_';
|
||||
}
|
||||
|
||||
@ -122,7 +123,7 @@ public String getRootSQLALias() {
|
||||
}
|
||||
|
||||
private Criteria getAliasedCriteria(String alias) {
|
||||
return ( Criteria ) aliasCriteriaMap.get( alias );
|
||||
return aliasCriteriaMap.get( alias );
|
||||
}
|
||||
|
||||
public boolean isJoin(String path) {
|
||||
@ -135,14 +136,12 @@ public JoinType getJoinType(String path) {
|
||||
}
|
||||
|
||||
public Criteria getCriteria(String path) {
|
||||
return ( Criteria ) associationPathCriteriaMap.get( path );
|
||||
return associationPathCriteriaMap.get( path );
|
||||
}
|
||||
|
||||
public Set getQuerySpaces() {
|
||||
Set result = new HashSet();
|
||||
Iterator iter = criteriaInfoMap.values().iterator();
|
||||
while ( iter.hasNext() ) {
|
||||
CriteriaInfoProvider info = ( CriteriaInfoProvider )iter.next();
|
||||
public Set<Serializable> getQuerySpaces() {
|
||||
Set<Serializable> result = new HashSet<Serializable>();
|
||||
for ( CriteriaInfoProvider info : criteriaInfoMap.values() ) {
|
||||
result.addAll( Arrays.asList( info.getSpaces() ) );
|
||||
}
|
||||
return result;
|
||||
@ -150,9 +149,9 @@ public Set getQuerySpaces() {
|
||||
|
||||
private void createAliasCriteriaMap() {
|
||||
aliasCriteriaMap.put( rootCriteria.getAlias(), rootCriteria );
|
||||
Iterator iter = rootCriteria.iterateSubcriteria();
|
||||
Iterator<CriteriaImpl.Subcriteria> iter = rootCriteria.iterateSubcriteria();
|
||||
while ( iter.hasNext() ) {
|
||||
Criteria subcriteria = ( Criteria ) iter.next();
|
||||
Criteria subcriteria = iter.next();
|
||||
if ( subcriteria.getAlias() != null ) {
|
||||
Object old = aliasCriteriaMap.put( subcriteria.getAlias(), subcriteria );
|
||||
if ( old != null ) {
|
||||
@ -163,9 +162,9 @@ private void createAliasCriteriaMap() {
|
||||
}
|
||||
|
||||
private void createAssociationPathCriteriaMap() {
|
||||
Iterator iter = rootCriteria.iterateSubcriteria();
|
||||
final Iterator<CriteriaImpl.Subcriteria> iter = rootCriteria.iterateSubcriteria();
|
||||
while ( iter.hasNext() ) {
|
||||
CriteriaImpl.Subcriteria crit = ( CriteriaImpl.Subcriteria ) iter.next();
|
||||
CriteriaImpl.Subcriteria crit = iter.next();
|
||||
String wholeAssociationPath = getWholeAssociationPath( crit );
|
||||
Object old = associationPathCriteriaMap.put( wholeAssociationPath, crit );
|
||||
if ( old != null ) {
|
||||
@ -197,7 +196,7 @@ private String getWholeAssociationPath(CriteriaImpl.Subcriteria subcriteria) {
|
||||
// and the qualifier is not the alias of this criteria
|
||||
// -> check to see if we belong to some criteria other
|
||||
// than the one that created us
|
||||
parent = ( Criteria ) aliasCriteriaMap.get( testAlias );
|
||||
parent = aliasCriteriaMap.get( testAlias );
|
||||
}
|
||||
}
|
||||
if ( parent == null ) {
|
||||
@ -224,16 +223,10 @@ private void createCriteriaEntityNameMap() {
|
||||
criteriaInfoMap.put( rootCriteria, rootProvider);
|
||||
nameCriteriaInfoMap.put ( rootProvider.getName(), rootProvider );
|
||||
|
||||
Iterator iter = associationPathCriteriaMap.entrySet().iterator();
|
||||
while ( iter.hasNext() ) {
|
||||
Map.Entry me = ( Map.Entry ) iter.next();
|
||||
CriteriaInfoProvider info = getPathInfo((String)me.getKey());
|
||||
|
||||
criteriaInfoMap.put(
|
||||
me.getValue(), //the criteria instance
|
||||
info
|
||||
);
|
||||
|
||||
for(final String key : associationPathCriteriaMap.keySet() ){
|
||||
Criteria value = associationPathCriteriaMap.get( key );
|
||||
CriteriaInfoProvider info = getPathInfo( key );
|
||||
criteriaInfoMap.put( value, info );
|
||||
nameCriteriaInfoMap.put( info.getName(), info );
|
||||
}
|
||||
}
|
||||
@ -244,7 +237,7 @@ private CriteriaInfoProvider getPathInfo(String path) {
|
||||
String componentPath = "";
|
||||
|
||||
// start with the 'rootProvider'
|
||||
CriteriaInfoProvider provider = ( CriteriaInfoProvider )nameCriteriaInfoMap.get( rootEntityName );
|
||||
CriteriaInfoProvider provider = nameCriteriaInfoMap.get( rootEntityName );
|
||||
|
||||
while ( tokens.hasMoreTokens() ) {
|
||||
componentPath += tokens.nextToken();
|
||||
@ -290,16 +283,15 @@ public int getSQLAliasCount() {
|
||||
|
||||
private void createCriteriaSQLAliasMap() {
|
||||
int i = 0;
|
||||
Iterator criteriaIterator = criteriaInfoMap.entrySet().iterator();
|
||||
while ( criteriaIterator.hasNext() ) {
|
||||
Map.Entry me = ( Map.Entry ) criteriaIterator.next();
|
||||
Criteria crit = ( Criteria ) me.getKey();
|
||||
for(final Criteria crit : criteriaInfoMap.keySet()){
|
||||
CriteriaInfoProvider value = criteriaInfoMap.get( crit );
|
||||
String alias = crit.getAlias();
|
||||
if ( alias == null ) {
|
||||
alias = (( CriteriaInfoProvider ) me.getValue()).getName(); // the entity name
|
||||
alias = value.getName(); // the entity name
|
||||
}
|
||||
criteriaSQLAliasMap.put( crit, StringHelper.generateAlias( alias, i++ ) );
|
||||
}
|
||||
|
||||
criteriaSQLAliasMap.put( rootCriteria, rootSQLAlias );
|
||||
}
|
||||
|
||||
@ -314,18 +306,16 @@ public QueryParameters getQueryParameters() {
|
||||
selection.setMaxRows( rootCriteria.getMaxResults() );
|
||||
selection.setTimeout( rootCriteria.getTimeout() );
|
||||
selection.setFetchSize( rootCriteria.getFetchSize() );
|
||||
|
||||
Iterator iter = rootCriteria.getLockModes().entrySet().iterator();
|
||||
while ( iter.hasNext() ) {
|
||||
Map.Entry me = ( Map.Entry ) iter.next();
|
||||
final Criteria subcriteria = getAliasedCriteria( ( String ) me.getKey() );
|
||||
lockOptions.setAliasSpecificLockMode( getSQLAlias( subcriteria ), (LockMode)me.getValue() );
|
||||
final Map<String, LockMode> lockModeMap = rootCriteria.getLockModes();
|
||||
for ( final String key : lockModeMap.keySet() ) {
|
||||
final Criteria subcriteria = getAliasedCriteria( key );
|
||||
lockOptions.setAliasSpecificLockMode( getSQLAlias( subcriteria ), lockModeMap.get( key ) );
|
||||
}
|
||||
List values = new ArrayList();
|
||||
List types = new ArrayList();
|
||||
iter = rootCriteria.iterateSubcriteria();
|
||||
while ( iter.hasNext() ) {
|
||||
CriteriaImpl.Subcriteria subcriteria = ( CriteriaImpl.Subcriteria ) iter.next();
|
||||
final List<Object> values = new ArrayList<Object>();
|
||||
final List<Type> types = new ArrayList<Type>();
|
||||
final Iterator<CriteriaImpl.Subcriteria> subcriteriaIterator = rootCriteria.iterateSubcriteria();
|
||||
while ( subcriteriaIterator.hasNext() ) {
|
||||
CriteriaImpl.Subcriteria subcriteria = subcriteriaIterator.next();
|
||||
LockMode lm = subcriteria.getLockMode();
|
||||
if ( lm != null ) {
|
||||
lockOptions.setAliasSpecificLockMode( getSQLAlias( subcriteria ), lm );
|
||||
@ -333,9 +323,9 @@ public QueryParameters getQueryParameters() {
|
||||
if ( subcriteria.getWithClause() != null )
|
||||
{
|
||||
TypedValue[] tv = subcriteria.getWithClause().getTypedValues( subcriteria, this );
|
||||
for ( int i = 0; i < tv.length; i++ ) {
|
||||
values.add( tv[i].getValue() );
|
||||
types.add( tv[i].getType() );
|
||||
for ( TypedValue aTv : tv ) {
|
||||
values.add( aTv.getValue() );
|
||||
types.add( aTv.getType() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -343,13 +333,13 @@ public QueryParameters getQueryParameters() {
|
||||
// Type and value gathering for the WHERE clause needs to come AFTER lock mode gathering,
|
||||
// because the lock mode gathering loop now contains join clauses which can contain
|
||||
// parameter bindings (as in the HQL WITH clause).
|
||||
iter = rootCriteria.iterateExpressionEntries();
|
||||
Iterator<CriteriaImpl.CriterionEntry> iter = rootCriteria.iterateExpressionEntries();
|
||||
while ( iter.hasNext() ) {
|
||||
CriteriaImpl.CriterionEntry ce = ( CriteriaImpl.CriterionEntry ) iter.next();
|
||||
CriteriaImpl.CriterionEntry ce = iter.next();
|
||||
TypedValue[] tv = ce.getCriterion().getTypedValues( ce.getCriteria(), this );
|
||||
for ( int i = 0; i < tv.length; i++ ) {
|
||||
values.add( tv[i].getValue() );
|
||||
types.add( tv[i].getType() );
|
||||
for ( TypedValue aTv : tv ) {
|
||||
values.add( aTv.getValue() );
|
||||
types.add( aTv.getType() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -361,7 +351,7 @@ public QueryParameters getQueryParameters() {
|
||||
lockOptions,
|
||||
selection,
|
||||
rootCriteria.isReadOnlyInitialized(),
|
||||
( rootCriteria.isReadOnlyInitialized() ? rootCriteria.isReadOnly() : false ),
|
||||
( rootCriteria.isReadOnlyInitialized() && rootCriteria.isReadOnly() ),
|
||||
rootCriteria.getCacheable(),
|
||||
rootCriteria.getCacheRegion(),
|
||||
rootCriteria.getComment(),
|
||||
@ -413,9 +403,9 @@ public String[] getProjectedAliases() {
|
||||
|
||||
public String getWhereCondition() {
|
||||
StringBuilder condition = new StringBuilder( 30 );
|
||||
Iterator criterionIterator = rootCriteria.iterateExpressionEntries();
|
||||
Iterator<CriteriaImpl.CriterionEntry> criterionIterator = rootCriteria.iterateExpressionEntries();
|
||||
while ( criterionIterator.hasNext() ) {
|
||||
CriteriaImpl.CriterionEntry entry = ( CriteriaImpl.CriterionEntry ) criterionIterator.next();
|
||||
CriteriaImpl.CriterionEntry entry = criterionIterator.next();
|
||||
String sqlString = entry.getCriterion().toSqlString( entry.getCriteria(), this );
|
||||
condition.append( sqlString );
|
||||
if ( criterionIterator.hasNext() ) {
|
||||
@ -427,9 +417,9 @@ public String getWhereCondition() {
|
||||
|
||||
public String getOrderBy() {
|
||||
StringBuilder orderBy = new StringBuilder( 30 );
|
||||
Iterator criterionIterator = rootCriteria.iterateOrderings();
|
||||
Iterator<CriteriaImpl.OrderEntry> criterionIterator = rootCriteria.iterateOrderings();
|
||||
while ( criterionIterator.hasNext() ) {
|
||||
CriteriaImpl.OrderEntry oe = ( CriteriaImpl.OrderEntry ) criterionIterator.next();
|
||||
CriteriaImpl.OrderEntry oe = criterionIterator.next();
|
||||
orderBy.append( oe.getOrder().toSqlString( oe.getCriteria(), this ) );
|
||||
if ( criterionIterator.hasNext() ) {
|
||||
orderBy.append( ", " );
|
||||
@ -437,20 +427,20 @@ public String getOrderBy() {
|
||||
}
|
||||
return orderBy.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryImplementor getFactory() {
|
||||
return sessionFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAlias(Criteria criteria) {
|
||||
return ( String ) criteriaSQLAliasMap.get( criteria );
|
||||
return criteriaSQLAliasMap.get( criteria );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityName(Criteria criteria) {
|
||||
final CriteriaInfoProvider infoProvider = ( CriteriaInfoProvider ) criteriaInfoMap.get( criteria );
|
||||
final CriteriaInfoProvider infoProvider = criteriaInfoMap.get( criteria );
|
||||
return infoProvider != null ? infoProvider.getName() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumn(Criteria criteria, String propertyName) {
|
||||
String[] cols = getColumns( propertyName, criteria );
|
||||
if ( cols.length != 1 ) {
|
||||
@ -463,6 +453,7 @@ public String getColumn(Criteria criteria, String propertyName) {
|
||||
* Get the names of the columns constrained
|
||||
* by this criterion.
|
||||
*/
|
||||
@Override
|
||||
public String[] getColumnsUsingProjection(
|
||||
Criteria subcriteria,
|
||||
String propertyName) throws HibernateException {
|
||||
@ -497,26 +488,22 @@ public String[] getColumnsUsingProjection(
|
||||
return projectionColumns;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getIdentifierColumns(Criteria criteria) {
|
||||
String[] idcols =
|
||||
( ( Loadable ) getPropertyMapping( getEntityName( criteria ) ) ).getIdentifierColumnNames();
|
||||
return StringHelper.qualify( getSQLAlias( criteria ), idcols );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getIdentifierType(Criteria criteria) {
|
||||
return ( ( Loadable ) getPropertyMapping( getEntityName( criteria ) ) ).getIdentifierType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedValue getTypedIdentifierValue(Criteria criteria, Object value) {
|
||||
final Loadable loadable = ( Loadable ) getPropertyMapping( getEntityName( criteria ) );
|
||||
return new TypedValue(
|
||||
loadable.getIdentifierType(),
|
||||
value,
|
||||
EntityMode.POJO
|
||||
);
|
||||
return new TypedValue( loadable.getIdentifierType(), value );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getColumns(
|
||||
String propertyName,
|
||||
Criteria subcriteria) throws HibernateException {
|
||||
@ -532,6 +519,7 @@ public String[] getColumns(
|
||||
* property path is not found in subcriteria, try the "outer" query.
|
||||
* Projection aliases are ignored.
|
||||
*/
|
||||
@Override
|
||||
public String[] findColumns(String propertyName, Criteria subcriteria )
|
||||
throws HibernateException {
|
||||
try {
|
||||
@ -547,7 +535,7 @@ public String[] findColumns(String propertyName, Criteria subcriteria )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getTypeUsingProjection(Criteria subcriteria, String propertyName)
|
||||
throws HibernateException {
|
||||
|
||||
@ -581,7 +569,7 @@ public Type getTypeUsingProjection(Criteria subcriteria, String propertyName)
|
||||
return projectionTypes[0];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType(Criteria subcriteria, String propertyName)
|
||||
throws HibernateException {
|
||||
return getPropertyMapping( getEntityName( subcriteria, propertyName ) )
|
||||
@ -591,6 +579,7 @@ public Type getType(Criteria subcriteria, String propertyName)
|
||||
/**
|
||||
* Get the a typed value for the given property value.
|
||||
*/
|
||||
@Override
|
||||
public TypedValue getTypedValue(Criteria subcriteria, String propertyName, Object value)
|
||||
throws HibernateException {
|
||||
// Detect discriminator values...
|
||||
@ -625,7 +614,7 @@ public TypedValue getTypedValue(Criteria subcriteria, String propertyName, Objec
|
||||
|
||||
private PropertyMapping getPropertyMapping(String entityName)
|
||||
throws MappingException {
|
||||
CriteriaInfoProvider info = ( CriteriaInfoProvider )nameCriteriaInfoMap.get(entityName);
|
||||
CriteriaInfoProvider info = nameCriteriaInfoMap.get(entityName);
|
||||
if (info==null) {
|
||||
throw new HibernateException( "Unknown entity: " + entityName );
|
||||
}
|
||||
@ -633,7 +622,7 @@ private PropertyMapping getPropertyMapping(String entityName)
|
||||
}
|
||||
|
||||
//TODO: use these in methods above
|
||||
|
||||
@Override
|
||||
public String getEntityName(Criteria subcriteria, String propertyName) {
|
||||
if ( propertyName.indexOf( '.' ) > 0 ) {
|
||||
String root = StringHelper.root( propertyName );
|
||||
@ -644,7 +633,7 @@ public String getEntityName(Criteria subcriteria, String propertyName) {
|
||||
}
|
||||
return getEntityName( subcriteria );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAlias(Criteria criteria, String propertyName) {
|
||||
if ( propertyName.indexOf( '.' ) > 0 ) {
|
||||
String root = StringHelper.root( propertyName );
|
||||
@ -655,7 +644,7 @@ public String getSQLAlias(Criteria criteria, String propertyName) {
|
||||
}
|
||||
return getSQLAlias( criteria );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPropertyName(String propertyName) {
|
||||
if ( propertyName.indexOf( '.' ) > 0 ) {
|
||||
String root = StringHelper.root( propertyName );
|
||||
@ -669,14 +658,14 @@ public String getPropertyName(String propertyName) {
|
||||
|
||||
public String getWithClause(String path)
|
||||
{
|
||||
final Criterion crit = (Criterion)this.withClauseMap.get(path);
|
||||
final Criterion crit = withClauseMap.get(path);
|
||||
return crit == null ? null : crit.toSqlString(getCriteria(path), this);
|
||||
}
|
||||
|
||||
public boolean hasRestriction(String path)
|
||||
{
|
||||
final CriteriaImpl.Subcriteria crit = ( CriteriaImpl.Subcriteria ) getCriteria( path );
|
||||
return crit == null ? false : crit.hasRestriction();
|
||||
return crit != null && crit.hasRestriction();
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,25 +35,25 @@
|
||||
*/
|
||||
|
||||
class EntityCriteriaInfoProvider implements CriteriaInfoProvider {
|
||||
Queryable persister;
|
||||
private final Queryable persister;
|
||||
|
||||
EntityCriteriaInfoProvider(Queryable persister) {
|
||||
this.persister = persister;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return persister.getEntityName();
|
||||
}
|
||||
|
||||
public Serializable[] getSpaces() {
|
||||
return persister.getQuerySpaces();
|
||||
}
|
||||
|
||||
public PropertyMapping getPropertyMapping() {
|
||||
return persister;
|
||||
}
|
||||
|
||||
public Type getType(String relativePath) {
|
||||
return persister.toType(relativePath);
|
||||
}
|
||||
EntityCriteriaInfoProvider(Queryable persister) {
|
||||
this.persister = persister;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return persister.getEntityName();
|
||||
}
|
||||
@Override
|
||||
public Serializable[] getSpaces() {
|
||||
return persister.getQuerySpaces();
|
||||
}
|
||||
@Override
|
||||
public PropertyMapping getPropertyMapping() {
|
||||
return persister;
|
||||
}
|
||||
@Override
|
||||
public Type getType(String relativePath) {
|
||||
return persister.toType( relativePath );
|
||||
}
|
||||
}
|
||||
|
@ -36,32 +36,36 @@
|
||||
*/
|
||||
|
||||
class ScalarCollectionCriteriaInfoProvider implements CriteriaInfoProvider {
|
||||
String role;
|
||||
QueryableCollection persister;
|
||||
SessionFactoryHelper helper;
|
||||
private final String role;
|
||||
private final QueryableCollection persister;
|
||||
private final SessionFactoryHelper helper;
|
||||
|
||||
ScalarCollectionCriteriaInfoProvider(SessionFactoryHelper helper, String role) {
|
||||
this.role = role;
|
||||
this.helper = helper;
|
||||
this.persister = helper.requireQueryableCollection(role);
|
||||
}
|
||||
ScalarCollectionCriteriaInfoProvider(SessionFactoryHelper helper, String role) {
|
||||
this.role = role;
|
||||
this.helper = helper;
|
||||
this.persister = helper.requireQueryableCollection( role );
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return role;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public Serializable[] getSpaces() {
|
||||
return persister.getCollectionSpaces();
|
||||
}
|
||||
@Override
|
||||
public Serializable[] getSpaces() {
|
||||
return persister.getCollectionSpaces();
|
||||
}
|
||||
|
||||
public PropertyMapping getPropertyMapping() {
|
||||
return helper.getCollectionPropertyMapping(role);
|
||||
}
|
||||
@Override
|
||||
public PropertyMapping getPropertyMapping() {
|
||||
return helper.getCollectionPropertyMapping( role );
|
||||
}
|
||||
|
||||
public Type getType(String relativePath) {
|
||||
//not sure what things are going to be passed here, how about 'id', maybe 'index' or 'key' or 'elements' ???
|
||||
// todo: wtf!
|
||||
return getPropertyMapping().toType(relativePath);
|
||||
}
|
||||
@Override
|
||||
public Type getType(String relativePath) {
|
||||
//not sure what things are going to be passed here, how about 'id', maybe 'index' or 'key' or 'elements' ???
|
||||
// todo: wtf!
|
||||
return getPropertyMapping().toType( relativePath );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ public int getJoinTypeValue() {
|
||||
return joinTypeValue;
|
||||
}
|
||||
|
||||
public static JoinType parse(int joinType){
|
||||
if(joinType<0){
|
||||
public static JoinType parse(int joinType) {
|
||||
if ( joinType < 0 ) {
|
||||
return NONE;
|
||||
}
|
||||
switch ( joinType ){
|
||||
switch ( joinType ) {
|
||||
case 0:
|
||||
return INNER_JOIN;
|
||||
case 1:
|
||||
@ -36,7 +36,7 @@ public static JoinType parse(int joinType){
|
||||
case 4:
|
||||
return FULL_JOIN;
|
||||
default:
|
||||
throw new HibernateException( "unknown join type: "+joinType );
|
||||
throw new HibernateException( "unknown join type: " + joinType );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user