コード例 #1
0
 /**
  * Does the mapping, and Hibernate default semantics, specify that this association should be
  * fetched by outer joining
  */
 protected boolean isJoinedFetchEnabledInMapping(FetchMode config, AssociationType type)
     throws MappingException {
   if (!type.isEntityType() && !type.isCollectionType()) {
     return false;
   } else {
     if (config == FetchMode.JOIN) return true;
     if (config == FetchMode.SELECT) return false;
     if (type.isEntityType()) {
       // TODO: look at the owning property and check that it
       //      isn't lazy (by instrumentation)
       EntityType entityType = (EntityType) type;
       EntityPersister persister =
           getFactory().getEntityPersister(entityType.getAssociatedEntityName());
       return !persister.hasProxy();
     } else {
       return false;
     }
   }
 }
コード例 #2
0
 /**
  * Determine the appropriate associationType of join (if any) to use to fetch the given
  * association.
  *
  * @param associationType The association associationType.
  * @param config The metadata-defined fetch mode.
  * @param path The path to the association
  * @param lhsTable The owner table
  * @param lhsColumns The owner join columns
  * @param nullable Is the association nullable.
  * @param currentDepth Current join depth
  * @param cascadeStyle The metadata-defined cascade style.
  * @return type of join to use ({@link org.hibernate.sql.JoinType#INNER_JOIN}, {@link
  *     org.hibernate.sql.JoinType#LEFT_OUTER_JOIN}, or -1 to indicate no joining.
  * @throws MappingException ??
  */
 protected JoinType getJoinType(
     AssociationType associationType,
     FetchMode config,
     PropertyPath path,
     String lhsTable,
     String[] lhsColumns,
     boolean nullable,
     int currentDepth,
     CascadeStyle cascadeStyle)
     throws MappingException {
   if (!isJoinedFetchEnabled(associationType, config, cascadeStyle)) {
     return JoinType.NONE;
   }
   if (isTooDeep(currentDepth) || (associationType.isCollectionType() && isTooManyCollections())) {
     return JoinType.NONE;
   }
   if (isDuplicateAssociation(lhsTable, lhsColumns, associationType)) {
     return JoinType.NONE;
   }
   return getJoinType(nullable, currentDepth);
 }
コード例 #3
0
 protected JoinType getJoinType(
     OuterJoinLoadable persister,
     final PropertyPath path,
     int propertyNumber,
     AssociationType associationType,
     FetchMode metadataFetchMode,
     CascadeStyle metadataCascadeStyle,
     String lhsTable,
     String[] lhsColumns,
     final boolean nullable,
     final int currentDepth)
     throws MappingException {
   final JoinType resolvedJoinType;
   if (translator.isJoin(path.getFullPath())) {
     resolvedJoinType = translator.getJoinType(path.getFullPath());
   } else {
     if (translator.hasProjection()) {
       resolvedJoinType = JoinType.NONE;
     } else {
       FetchMode fetchMode = translator.getRootCriteria().getFetchMode(path.getFullPath());
       if (isDefaultFetchMode(fetchMode)) {
         if (persister != null) {
           if (isJoinFetchEnabledByProfile(persister, path, propertyNumber)) {
             if (isDuplicateAssociation(lhsTable, lhsColumns, associationType)) {
               resolvedJoinType = JoinType.NONE;
             } else if (isTooDeep(currentDepth)
                 || (associationType.isCollectionType() && isTooManyCollections())) {
               resolvedJoinType = JoinType.NONE;
             } else {
               resolvedJoinType = getJoinType(nullable, currentDepth);
             }
           } else {
             resolvedJoinType =
                 super.getJoinType(
                     persister,
                     path,
                     propertyNumber,
                     associationType,
                     metadataFetchMode,
                     metadataCascadeStyle,
                     lhsTable,
                     lhsColumns,
                     nullable,
                     currentDepth);
           }
         } else {
           resolvedJoinType =
               super.getJoinType(
                   associationType,
                   metadataFetchMode,
                   path,
                   lhsTable,
                   lhsColumns,
                   nullable,
                   currentDepth,
                   metadataCascadeStyle);
         }
       } else {
         if (fetchMode == FetchMode.JOIN) {
           isDuplicateAssociation(
               lhsTable, lhsColumns, associationType); // deliberately ignore return value!
           resolvedJoinType = getJoinType(nullable, currentDepth);
         } else {
           resolvedJoinType = JoinType.NONE;
         }
       }
     }
   }
   return resolvedJoinType;
 }
コード例 #4
0
// $Id: CascadeEntityJoinWalker.java,v 1.1 2005/07/26 05:51:47 oneovthafew Exp $
コード例 #5
0
 public boolean isCollection() {
   return joinableType.isCollectionType();
 }