org.hibernate.FetchMode

Here are the examples of the java api org.hibernate.FetchMode taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

21 Examples 7

19 Source : EntityCriteria.java
with MIT License
from theonedev

public EnreplacedyCriteria<T> setFetchMode(String replacedociationPath, FetchMode mode) throws HibernateException {
    criteria.setFetchMode(replacedociationPath, mode);
    return this;
}

19 Source : ToOne.java
with GNU General Public License v2.0
from lamsfoundation

/**
 * A simple-point replacedociation (ie. a reference to another enreplacedy).
 * @author Gavin King
 */
public abstract clreplaced ToOne extends SimpleValue implements Fetchable {

    private FetchMode fetchMode;

    protected String referencedPropertyName;

    private String referencedEnreplacedyName;

    private String propertyName;

    private boolean embedded;

    private boolean lazy = true;

    protected boolean unwrapProxy;

    protected boolean referenceToPrimaryKey = true;

    /**
     * @deprecated Use {@link ToOne#ToOne(MetadataBuildingContext, Table)} instead.
     */
    @Deprecated
    protected ToOne(MetadataImplementor metadata, Table table) {
        super(metadata, table);
    }

    protected ToOne(MetadataBuildingContext buildingContext, Table table) {
        super(buildingContext, table);
    }

    public FetchMode getFetchMode() {
        return fetchMode;
    }

    public void setFetchMode(FetchMode fetchMode) {
        this.fetchMode = fetchMode;
    }

    public abstract void createForeignKey() throws MappingException;

    public abstract Type getType() throws MappingException;

    public String getReferencedPropertyName() {
        return referencedPropertyName;
    }

    public void setReferencedPropertyName(String name) {
        referencedPropertyName = name == null ? null : name.intern();
    }

    public String getReferencedEnreplacedyName() {
        return referencedEnreplacedyName;
    }

    public void setReferencedEnreplacedyName(String referencedEnreplacedyName) {
        this.referencedEnreplacedyName = referencedEnreplacedyName == null ? null : referencedEnreplacedyName.intern();
    }

    public String getPropertyName() {
        return propertyName;
    }

    public void setPropertyName(String propertyName) {
        this.propertyName = propertyName == null ? null : propertyName.intern();
    }

    @Override
    public void setTypeUsingReflection(String clreplacedName, String propertyName) throws MappingException {
        if (referencedEnreplacedyName == null) {
            final ClreplacedLoaderService cls = getMetadata().getMetadataBuildingOptions().getServiceRegistry().getService(ClreplacedLoaderService.clreplaced);
            referencedEnreplacedyName = ReflectHelper.reflectedPropertyClreplaced(clreplacedName, propertyName, cls).getName();
        }
    }

    public boolean isTypeSpecified() {
        return referencedEnreplacedyName != null;
    }

    public Object accept(ValueVisitor visitor) {
        return visitor.accept(this);
    }

    @Override
    public boolean isSame(SimpleValue other) {
        return other instanceof ToOne && isSame((ToOne) other);
    }

    public boolean isSame(ToOne other) {
        return super.isSame(other) && Objects.equals(referencedPropertyName, other.referencedPropertyName) && Objects.equals(referencedEnreplacedyName, other.referencedEnreplacedyName) && embedded == other.embedded;
    }

    public boolean isValid(Mapping mapping) throws MappingException {
        if (referencedEnreplacedyName == null) {
            throw new MappingException("replacedociation must specify the referenced enreplacedy");
        }
        return super.isValid(mapping);
    }

    public boolean isLazy() {
        return lazy;
    }

    public void setLazy(boolean lazy) {
        this.lazy = lazy;
    }

    public boolean isUnwrapProxy() {
        return unwrapProxy;
    }

    public void setUnwrapProxy(boolean unwrapProxy) {
        this.unwrapProxy = unwrapProxy;
    }

    public boolean isReferenceToPrimaryKey() {
        return referenceToPrimaryKey;
    }

    public void setReferenceToPrimaryKey(boolean referenceToPrimaryKey) {
        this.referenceToPrimaryKey = referenceToPrimaryKey;
    }
}

19 Source : ToOne.java
with GNU General Public License v2.0
from lamsfoundation

public void setFetchMode(FetchMode fetchMode) {
    this.fetchMode = fetchMode;
}

19 Source : CriteriaJoinWalker.java
with GNU General Public License v2.0
from lamsfoundation

private static boolean isDefaultFetchMode(FetchMode fetchMode) {
    return fetchMode == null || fetchMode == FetchMode.DEFAULT;
}

19 Source : DetachedCriteria.java
with GNU General Public License v2.0
from lamsfoundation

/**
 * Set the fetch mode for a given replacedociation
 *
 * @param replacedociationPath The replacedociation path
 * @param mode The fetch mode to apply
 *
 * @return {@code this}, for method chaining
 */
public DetachedCriteria setFetchMode(String replacedociationPath, FetchMode mode) {
    criteria.setFetchMode(replacedociationPath, mode);
    return this;
}

18 Source : CompositeBasedAssociationAttribute.java
with GNU General Public License v2.0
from lamsfoundation

protected FetchStyle determineFetchStyleByMetadata(FetchMode fetchMode, replacedociationType type) {
    return FetchStrategyHelper.determineFetchStyleByMetadata(fetchMode, type, sessionFactory());
}

18 Source : BaselineAttributeInformation.java
with GNU General Public License v2.0
from lamsfoundation

/**
 * @author Steve Ebersole
 */
public clreplaced BaselineAttributeInformation {

    private final boolean lazy;

    private final boolean insertable;

    private final boolean updateable;

    private final ValueGeneration valueGenerationStrategy;

    private final boolean nullable;

    private final boolean dirtyCheckable;

    private final boolean versionable;

    private final CascadeStyle cascadeStyle;

    private final FetchMode fetchMode;

    private boolean checkable;

    public BaselineAttributeInformation(boolean lazy, boolean insertable, boolean updateable, ValueGeneration valueGenerationStrategy, boolean nullable, boolean dirtyCheckable, boolean versionable, CascadeStyle cascadeStyle, FetchMode fetchMode) {
        this.lazy = lazy;
        this.insertable = insertable;
        this.updateable = updateable;
        this.valueGenerationStrategy = valueGenerationStrategy;
        this.nullable = nullable;
        this.dirtyCheckable = dirtyCheckable;
        this.versionable = versionable;
        this.cascadeStyle = cascadeStyle;
        this.fetchMode = fetchMode;
    }

    public boolean isLazy() {
        return lazy;
    }

    public boolean isInsertable() {
        return insertable;
    }

    public boolean isUpdateable() {
        return updateable;
    }

    public ValueGeneration getValueGenerationStrategy() {
        return valueGenerationStrategy;
    }

    public boolean isNullable() {
        return nullable;
    }

    public boolean isDirtyCheckable() {
        return dirtyCheckable;
    }

    public boolean isVersionable() {
        return versionable;
    }

    public CascadeStyle getCascadeStyle() {
        return cascadeStyle;
    }

    public FetchMode getFetchMode() {
        return fetchMode;
    }

    public boolean isCheckable() {
        return checkable;
    }

    public static clreplaced Builder {

        private boolean lazy;

        private boolean insertable;

        private boolean updateable;

        private ValueGeneration valueGenerationStrategy;

        private boolean nullable;

        private boolean dirtyCheckable;

        private boolean versionable;

        private CascadeStyle cascadeStyle;

        private FetchMode fetchMode;

        public Builder setLazy(boolean lazy) {
            this.lazy = lazy;
            return this;
        }

        public Builder setInsertable(boolean insertable) {
            this.insertable = insertable;
            return this;
        }

        public Builder setUpdateable(boolean updateable) {
            this.updateable = updateable;
            return this;
        }

        public Builder setValueGenerationStrategy(ValueGeneration valueGenerationStrategy) {
            this.valueGenerationStrategy = valueGenerationStrategy;
            return this;
        }

        public Builder setNullable(boolean nullable) {
            this.nullable = nullable;
            return this;
        }

        public Builder setDirtyCheckable(boolean dirtyCheckable) {
            this.dirtyCheckable = dirtyCheckable;
            return this;
        }

        public Builder setVersionable(boolean versionable) {
            this.versionable = versionable;
            return this;
        }

        public Builder setCascadeStyle(CascadeStyle cascadeStyle) {
            this.cascadeStyle = cascadeStyle;
            return this;
        }

        public Builder setFetchMode(FetchMode fetchMode) {
            this.fetchMode = fetchMode;
            return this;
        }

        public BaselineAttributeInformation createInformation() {
            return new BaselineAttributeInformation(lazy, insertable, updateable, valueGenerationStrategy, nullable, dirtyCheckable, versionable, cascadeStyle, fetchMode);
        }
    }
}

18 Source : JoinWalker.java
with GNU General Public License v2.0
from lamsfoundation

/**
 * Determine the appropriate type of join (if any) to use to fetch the
 * given replacedociation.
 *
 * @param persister The owner of the replacedociation.
 * @param path The path to the replacedociation
 * @param propertyNumber The property number representing the replacedociation.
 * @param replacedociationType The replacedociation type.
 * @param metadataFetchMode The metadata-defined fetch mode.
 * @param metadataCascadeStyle The metadata-defined cascade style.
 * @param lhsTable The owner table
 * @param lhsColumns The owner join columns
 * @param nullable Is the replacedociation nullable.
 * @param currentDepth Current join depth
 *
 * @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(OuterJoinLoadable persister, final PropertyPath path, int propertyNumber, replacedociationType replacedociationType, FetchMode metadataFetchMode, CascadeStyle metadataCascadeStyle, String lhsTable, String[] lhsColumns, final boolean nullable, final int currentDepth) throws MappingException {
    return getJoinType(replacedociationType, metadataFetchMode, path, lhsTable, lhsColumns, nullable, currentDepth, metadataCascadeStyle);
}

18 Source : JoinWalker.java
with GNU General Public License v2.0
from lamsfoundation

/**
 * Override on subclreplacedes to enable or suppress joining
 * of certain replacedociation types
 */
protected boolean isJoinedFetchEnabled(replacedociationType type, FetchMode config, CascadeStyle cascadeStyle) {
    return type.isEnreplacedyType() && isJoinedFetchEnabledInMapping(config, type);
}

18 Source : CascadeEntityJoinWalker.java
with GNU General Public License v2.0
from lamsfoundation

@Override
protected boolean isJoinedFetchEnabled(replacedociationType type, FetchMode config, CascadeStyle cascadeStyle) {
    return (type.isEnreplacedyType() || type.isCollectionType()) && (cascadeStyle == null || cascadeStyle.doCascade(cascadeAction));
}

18 Source : AbstractEntityJoinWalker.java
with GNU General Public License v2.0
from lamsfoundation

/**
 * The superclreplaced deliberately excludes collections
 */
protected boolean isJoinedFetchEnabled(replacedociationType type, FetchMode config, CascadeStyle cascadeStyle) {
    return isJoinedFetchEnabledInMapping(config, type);
}

17 Source : JoinWalker.java
with GNU General Public License v2.0
from lamsfoundation

/**
 * Does the mapping, and Hibernate default semantics, specify that
 * this replacedociation should be fetched by outer joining
 */
protected boolean isJoinedFetchEnabledInMapping(FetchMode config, replacedociationType type) throws MappingException {
    if (!type.isEnreplacedyType() && !type.isCollectionType()) {
        return false;
    } else {
        if (config == FetchMode.JOIN) {
            return true;
        }
        if (config == FetchMode.SELECT) {
            return false;
        }
        if (type.isEnreplacedyType()) {
            // TODO: look at the owning property and check that it
            // isn't lazy (by instrumentation)
            EnreplacedyType enreplacedyType = (EnreplacedyType) type;
            EnreplacedyPersister persister = getFactory().getEnreplacedyPersister(enreplacedyType.getreplacedociatedEnreplacedyName());
            return !persister.hasProxy();
        } else {
            return false;
        }
    }
}

17 Source : JoinWalker.java
with GNU General Public License v2.0
from lamsfoundation

/**
 * Determine the appropriate replacedociationType of join (if any) to use to fetch the
 * given replacedociation.
 *
 * @param replacedociationType The replacedociation replacedociationType.
 * @param config The metadata-defined fetch mode.
 * @param path The path to the replacedociation
 * @param lhsTable The owner table
 * @param lhsColumns The owner join columns
 * @param nullable Is the replacedociation 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(replacedociationType replacedociationType, FetchMode config, PropertyPath path, String lhsTable, String[] lhsColumns, boolean nullable, int currentDepth, CascadeStyle cascadeStyle) throws MappingException {
    if (!isJoinedFetchEnabled(replacedociationType, config, cascadeStyle)) {
        return JoinType.NONE;
    }
    if (isTooDeep(currentDepth) || (replacedociationType.isCollectionType() && isTooManyCollections())) {
        return JoinType.NONE;
    }
    if (isDuplicatereplacedociation(lhsTable, lhsColumns, replacedociationType)) {
        return JoinType.NONE;
    }
    return getJoinType(nullable, currentDepth);
}

17 Source : CriteriaJoinWalker.java
with GNU General Public License v2.0
from lamsfoundation

@Override
protected JoinType getJoinType(replacedociationType replacedociationType, FetchMode config, PropertyPath path, String lhsTable, String[] lhsColumns, boolean nullable, int currentDepth, CascadeStyle cascadeStyle) throws MappingException {
    return getJoinType(null, path, -1, replacedociationType, config, cascadeStyle, lhsTable, lhsColumns, nullable, currentDepth);
}

17 Source : CriteriaImpl.java
with GNU General Public License v2.0
from lamsfoundation

@Override
public Criteria setFetchMode(String replacedociationPath, FetchMode mode) {
    String rootAliasPathPrefix = rootAlias + ".";
    if (rootAlias != null && !replacedociationPath.startsWith(rootAliasPathPrefix)) {
        replacedociationPath = rootAliasPathPrefix + replacedociationPath;
    }
    fetchModes.put(replacedociationPath, mode);
    return this;
}

16 Source : ComponentType.java
with GNU General Public License v2.0
from lamsfoundation

/**
 * Handles "component" mappings
 *
 * @author Gavin King
 */
public clreplaced ComponentType extends AbstractType implements CompositeType, ProcedureParameterExtractionAware {

    private final TypeFactory.TypeScope typeScope;

    private final String[] propertyNames;

    private final Type[] propertyTypes;

    private final ValueGeneration[] propertyValueGenerationStrategies;

    private final boolean[] propertyNullability;

    protected final int propertySpan;

    private final CascadeStyle[] cascade;

    private final FetchMode[] joinedFetch;

    private final boolean isKey;

    private boolean hasNotNullProperty;

    private final boolean createEmptyCompositesEnabled;

    protected final EnreplacedyMode enreplacedyMode;

    protected final ComponentTuplizer componentTuplizer;

    public ComponentType(TypeFactory.TypeScope typeScope, ComponentMetamodel metamodel) {
        this.typeScope = typeScope;
        // for now, just "re-flatten" the metamodel since this is temporary stuff anyway (HHH-1907)
        this.isKey = metamodel.isKey();
        this.propertySpan = metamodel.getPropertySpan();
        this.propertyNames = new String[propertySpan];
        this.propertyTypes = new Type[propertySpan];
        this.propertyValueGenerationStrategies = new ValueGeneration[propertySpan];
        this.propertyNullability = new boolean[propertySpan];
        this.cascade = new CascadeStyle[propertySpan];
        this.joinedFetch = new FetchMode[propertySpan];
        for (int i = 0; i < propertySpan; i++) {
            StandardProperty prop = metamodel.getProperty(i);
            this.propertyNames[i] = prop.getName();
            this.propertyTypes[i] = prop.getType();
            this.propertyNullability[i] = prop.isNullable();
            this.cascade[i] = prop.getCascadeStyle();
            this.joinedFetch[i] = prop.getFetchMode();
            if (!prop.isNullable()) {
                hasNotNullProperty = true;
            }
            this.propertyValueGenerationStrategies[i] = prop.getValueGenerationStrategy();
        }
        this.enreplacedyMode = metamodel.getEnreplacedyMode();
        this.componentTuplizer = metamodel.getComponentTuplizer();
        this.createEmptyCompositesEnabled = metamodel.isCreateEmptyCompositesEnabled();
    }

    public boolean isKey() {
        return isKey;
    }

    public EnreplacedyMode getEnreplacedyMode() {
        return enreplacedyMode;
    }

    public ComponentTuplizer getComponentTuplizer() {
        return componentTuplizer;
    }

    @Override
    public int getColumnSpan(Mapping mapping) throws MappingException {
        int span = 0;
        for (int i = 0; i < propertySpan; i++) {
            span += propertyTypes[i].getColumnSpan(mapping);
        }
        return span;
    }

    @Override
    public int[] sqlTypes(Mapping mapping) throws MappingException {
        // Not called at runtime so doesn't matter if its slow :)
        int[] sqlTypes = new int[getColumnSpan(mapping)];
        int n = 0;
        for (int i = 0; i < propertySpan; i++) {
            int[] subtypes = propertyTypes[i].sqlTypes(mapping);
            for (int subtype : subtypes) {
                sqlTypes[n++] = subtype;
            }
        }
        return sqlTypes;
    }

    @Override
    public Size[] dictatedSizes(Mapping mapping) throws MappingException {
        // Not called at runtime so doesn't matter if its slow :)
        final Size[] sizes = new Size[getColumnSpan(mapping)];
        int soFar = 0;
        for (Type propertyType : propertyTypes) {
            final Size[] propertySizes = propertyType.dictatedSizes(mapping);
            System.arraycopy(propertySizes, 0, sizes, soFar, propertySizes.length);
            soFar += propertySizes.length;
        }
        return sizes;
    }

    @Override
    public Size[] defaultSizes(Mapping mapping) throws MappingException {
        // Not called at runtime so doesn't matter if its slow :)
        final Size[] sizes = new Size[getColumnSpan(mapping)];
        int soFar = 0;
        for (Type propertyType : propertyTypes) {
            final Size[] propertySizes = propertyType.defaultSizes(mapping);
            System.arraycopy(propertySizes, 0, sizes, soFar, propertySizes.length);
            soFar += propertySizes.length;
        }
        return sizes;
    }

    @Override
    public final boolean isComponentType() {
        return true;
    }

    public Clreplaced getReturnedClreplaced() {
        return componentTuplizer.getMappedClreplaced();
    }

    @Override
    public boolean isSame(Object x, Object y) throws HibernateException {
        if (x == y) {
            return true;
        }
        // null value and empty component are considered equivalent
        Object[] xvalues = getPropertyValues(x, enreplacedyMode);
        Object[] yvalues = getPropertyValues(y, enreplacedyMode);
        for (int i = 0; i < propertySpan; i++) {
            if (!propertyTypes[i].isSame(xvalues[i], yvalues[i])) {
                return false;
            }
        }
        return true;
    }

    @Override
    public boolean isEqual(final Object x, final Object y) throws HibernateException {
        if (x == y) {
            return true;
        }
        // null value and empty component are considered equivalent
        for (int i = 0; i < propertySpan; i++) {
            if (!propertyTypes[i].isEqual(getPropertyValue(x, i), getPropertyValue(y, i))) {
                return false;
            }
        }
        return true;
    }

    @Override
    public boolean isEqual(final Object x, final Object y, final SessionFactoryImplementor factory) throws HibernateException {
        if (x == y) {
            return true;
        }
        // null value and empty component are considered equivalent
        for (int i = 0; i < propertySpan; i++) {
            if (!propertyTypes[i].isEqual(getPropertyValue(x, i), getPropertyValue(y, i), factory)) {
                return false;
            }
        }
        return true;
    }

    @Override
    public int compare(final Object x, final Object y) {
        if (x == y) {
            return 0;
        }
        for (int i = 0; i < propertySpan; i++) {
            int propertyCompare = propertyTypes[i].compare(getPropertyValue(x, i), getPropertyValue(y, i));
            if (propertyCompare != 0) {
                return propertyCompare;
            }
        }
        return 0;
    }

    public boolean isMethodOf(Method method) {
        return false;
    }

    @Override
    public int getHashCode(final Object x) {
        int result = 17;
        for (int i = 0; i < propertySpan; i++) {
            Object y = getPropertyValue(x, i);
            result *= 37;
            if (y != null) {
                result += propertyTypes[i].getHashCode(y);
            }
        }
        return result;
    }

    @Override
    public int getHashCode(final Object x, final SessionFactoryImplementor factory) {
        int result = 17;
        for (int i = 0; i < propertySpan; i++) {
            Object y = getPropertyValue(x, i);
            result *= 37;
            if (y != null) {
                result += propertyTypes[i].getHashCode(y, factory);
            }
        }
        return result;
    }

    @Override
    public boolean isDirty(final Object x, final Object y, final SharedSessionContractImplementor session) throws HibernateException {
        if (x == y) {
            return false;
        }
        // null value and empty component are considered equivalent
        for (int i = 0; i < propertySpan; i++) {
            if (propertyTypes[i].isDirty(getPropertyValue(x, i), getPropertyValue(y, i), session)) {
                return true;
            }
        }
        return false;
    }

    public boolean isDirty(final Object x, final Object y, final boolean[] checkable, final SharedSessionContractImplementor session) throws HibernateException {
        if (x == y) {
            return false;
        }
        // null value and empty component are considered equivalent
        int loc = 0;
        for (int i = 0; i < propertySpan; i++) {
            int len = propertyTypes[i].getColumnSpan(session.getFactory());
            if (len <= 1) {
                final boolean dirty = (len == 0 || checkable[loc]) && propertyTypes[i].isDirty(getPropertyValue(x, i), getPropertyValue(y, i), session);
                if (dirty) {
                    return true;
                }
            } else {
                boolean[] subcheckable = new boolean[len];
                System.arraycopy(checkable, loc, subcheckable, 0, len);
                final boolean dirty = propertyTypes[i].isDirty(getPropertyValue(x, i), getPropertyValue(y, i), subcheckable, session);
                if (dirty) {
                    return true;
                }
            }
            loc += len;
        }
        return false;
    }

    @Override
    public boolean isModified(final Object old, final Object current, final boolean[] checkable, final SharedSessionContractImplementor session) throws HibernateException {
        if (old == current) {
            return false;
        }
        // null value and empty components are considered equivalent
        int loc = 0;
        for (int i = 0; i < propertySpan; i++) {
            int len = propertyTypes[i].getColumnSpan(session.getFactory());
            boolean[] subcheckable = new boolean[len];
            System.arraycopy(checkable, loc, subcheckable, 0, len);
            if (propertyTypes[i].isModified(getPropertyValue(old, i), getPropertyValue(current, i), subcheckable, session)) {
                return true;
            }
            loc += len;
        }
        return false;
    }

    @Override
    public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException {
        return resolve(hydrate(rs, names, session, owner), session, owner);
    }

    @Override
    public void nullSafeSet(PreparedStatement st, Object value, int begin, SharedSessionContractImplementor session) throws HibernateException, SQLException {
        Object[] subvalues = nullSafeGetValues(value, enreplacedyMode);
        for (int i = 0; i < propertySpan; i++) {
            propertyTypes[i].nullSafeSet(st, subvalues[i], begin, session);
            begin += propertyTypes[i].getColumnSpan(session.getFactory());
        }
    }

    @Override
    public void nullSafeSet(PreparedStatement st, Object value, int begin, boolean[] settable, SharedSessionContractImplementor session) throws HibernateException, SQLException {
        Object[] subvalues = nullSafeGetValues(value, enreplacedyMode);
        int loc = 0;
        for (int i = 0; i < propertySpan; i++) {
            int len = propertyTypes[i].getColumnSpan(session.getFactory());
            // noinspection StatementWithEmptyBody
            if (len == 0) {
            // noop
            } else if (len == 1) {
                if (settable[loc]) {
                    propertyTypes[i].nullSafeSet(st, subvalues[i], begin, session);
                    begin++;
                }
            } else {
                boolean[] subsettable = new boolean[len];
                System.arraycopy(settable, loc, subsettable, 0, len);
                propertyTypes[i].nullSafeSet(st, subvalues[i], begin, subsettable, session);
                begin += ArrayHelper.countTrue(subsettable);
            }
            loc += len;
        }
    }

    private Object[] nullSafeGetValues(Object value, EnreplacedyMode enreplacedyMode) throws HibernateException {
        if (value == null) {
            return new Object[propertySpan];
        } else {
            return getPropertyValues(value, enreplacedyMode);
        }
    }

    @Override
    public Object nullSafeGet(ResultSet rs, String name, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException {
        return nullSafeGet(rs, new String[] { name }, session, owner);
    }

    @Override
    public Object getPropertyValue(Object component, int i, SharedSessionContractImplementor session) throws HibernateException {
        return getPropertyValue(component, i);
    }

    public Object getPropertyValue(Object component, int i, EnreplacedyMode enreplacedyMode) throws HibernateException {
        return getPropertyValue(component, i);
    }

    public Object getPropertyValue(Object component, int i) throws HibernateException {
        if (component == null) {
            component = new Object[propertySpan];
        }
        if (component instanceof Object[]) {
            // A few calls to hashCode preplaced the property values already in an
            // Object[] (ex: QueryKey hash codes for cached queries).
            // It's easiest to just check for the condition here prior to
            // trying reflection.
            return ((Object[]) component)[i];
        } else {
            return componentTuplizer.getPropertyValue(component, i);
        }
    }

    @Override
    public Object[] getPropertyValues(Object component, SharedSessionContractImplementor session) throws HibernateException {
        return getPropertyValues(component, enreplacedyMode);
    }

    @Override
    public Object[] getPropertyValues(Object component, EnreplacedyMode enreplacedyMode) throws HibernateException {
        if (component == null) {
            component = new Object[propertySpan];
        }
        if (component instanceof Object[]) {
            // A few calls to hashCode preplaced the property values already in an
            // Object[] (ex: QueryKey hash codes for cached queries).
            // It's easiest to just check for the condition here prior to
            // trying reflection.
            return (Object[]) component;
        } else {
            return componentTuplizer.getPropertyValues(component);
        }
    }

    @Override
    public void setPropertyValues(Object component, Object[] values, EnreplacedyMode enreplacedyMode) throws HibernateException {
        componentTuplizer.setPropertyValues(component, values);
    }

    @Override
    public Type[] getSubtypes() {
        return propertyTypes;
    }

    public ValueGeneration[] getPropertyValueGenerationStrategies() {
        return propertyValueGenerationStrategies;
    }

    @Override
    public String getName() {
        return "component" + ArrayHelper.toString(propertyNames);
    }

    @Override
    public String toLoggableString(Object value, SessionFactoryImplementor factory) throws HibernateException {
        if (value == null) {
            return "null";
        }
        if (enreplacedyMode == null) {
            throw new ClreplacedCastException(value.getClreplaced().getName());
        }
        Map<String, String> result = new HashMap<>();
        Object[] values = getPropertyValues(value, enreplacedyMode);
        for (int i = 0; i < propertyTypes.length; i++) {
            if (values[i] == LazyPropertyInitializer.UNFETCHED_PROPERTY) {
                result.put(propertyNames[i], "<uninitialized>");
            } else {
                result.put(propertyNames[i], propertyTypes[i].toLoggableString(values[i], factory));
            }
        }
        return StringHelper.unqualify(getName()) + result.toString();
    }

    @Override
    public String[] getPropertyNames() {
        return propertyNames;
    }

    @Override
    public Object deepCopy(Object component, SessionFactoryImplementor factory) throws HibernateException {
        if (component == null) {
            return null;
        }
        Object[] values = getPropertyValues(component, enreplacedyMode);
        for (int i = 0; i < propertySpan; i++) {
            values[i] = propertyTypes[i].deepCopy(values[i], factory);
        }
        Object result = instantiate(enreplacedyMode);
        setPropertyValues(result, values, enreplacedyMode);
        // not absolutely necessary, but helps for some
        // equals()/hashCode() implementations
        if (componentTuplizer.hasParentProperty()) {
            componentTuplizer.setParent(result, componentTuplizer.getParent(component), factory);
        }
        return result;
    }

    @Override
    public Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner, Map copyCache) throws HibernateException {
        if (original == null) {
            return null;
        }
        // if ( original == target ) return target;
        final Object result = target == null ? instantiate(owner, session) : target;
        Object[] values = TypeHelper.replace(getPropertyValues(original, enreplacedyMode), getPropertyValues(result, enreplacedyMode), propertyTypes, session, owner, copyCache);
        setPropertyValues(result, values, enreplacedyMode);
        return result;
    }

    @Override
    public Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner, Map copyCache, ForeignKeyDirection foreignKeyDirection) throws HibernateException {
        if (original == null) {
            return null;
        }
        // if ( original == target ) return target;
        final Object result = target == null ? instantiate(owner, session) : target;
        Object[] values = TypeHelper.replace(getPropertyValues(original, enreplacedyMode), getPropertyValues(result, enreplacedyMode), propertyTypes, session, owner, copyCache, foreignKeyDirection);
        setPropertyValues(result, values, enreplacedyMode);
        return result;
    }

    /**
     * This method does not populate the component parent
     */
    public Object instantiate(EnreplacedyMode enreplacedyMode) throws HibernateException {
        return componentTuplizer.instantiate();
    }

    public Object instantiate(Object parent, SharedSessionContractImplementor session) throws HibernateException {
        Object result = instantiate(enreplacedyMode);
        if (componentTuplizer.hasParentProperty() && parent != null) {
            componentTuplizer.setParent(result, session.getPersistenceContext().proxyFor(parent), session.getFactory());
        }
        return result;
    }

    @Override
    public CascadeStyle getCascadeStyle(int i) {
        return cascade[i];
    }

    @Override
    public boolean isMutable() {
        return true;
    }

    @Override
    public Serializable disreplacedemble(Object value, SharedSessionContractImplementor session, Object owner) throws HibernateException {
        if (value == null) {
            return null;
        } else {
            Object[] values = getPropertyValues(value, enreplacedyMode);
            for (int i = 0; i < propertyTypes.length; i++) {
                values[i] = propertyTypes[i].disreplacedemble(values[i], session, owner);
            }
            return values;
        }
    }

    @Override
    public Object replacedemble(Serializable object, SharedSessionContractImplementor session, Object owner) throws HibernateException {
        if (object == null) {
            return null;
        } else {
            Object[] values = (Object[]) object;
            Object[] replacedembled = new Object[values.length];
            for (int i = 0; i < propertyTypes.length; i++) {
                replacedembled[i] = propertyTypes[i].replacedemble((Serializable) values[i], session, owner);
            }
            Object result = instantiate(owner, session);
            setPropertyValues(result, replacedembled, enreplacedyMode);
            return result;
        }
    }

    @Override
    public FetchMode getFetchMode(int i) {
        return joinedFetch[i];
    }

    @Override
    public Object hydrate(final ResultSet rs, final String[] names, final SharedSessionContractImplementor session, final Object owner) throws HibernateException, SQLException {
        int begin = 0;
        boolean notNull = false;
        Object[] values = new Object[propertySpan];
        for (int i = 0; i < propertySpan; i++) {
            int length = propertyTypes[i].getColumnSpan(session.getFactory());
            // cache this
            String[] range = ArrayHelper.slice(names, begin, length);
            Object val = propertyTypes[i].hydrate(rs, range, session, owner);
            if (val == null) {
                if (isKey) {
                    // different nullability rules for pk/fk
                    return null;
                }
            } else {
                notNull = true;
            }
            values[i] = val;
            begin += length;
        }
        return notNull ? values : null;
    }

    @Override
    public Object resolve(Object value, SharedSessionContractImplementor session, Object owner) throws HibernateException {
        if (value != null) {
            Object result = instantiate(owner, session);
            Object[] values = (Object[]) value;
            // only really need new array during semiresolve!
            Object[] resolvedValues = new Object[values.length];
            for (int i = 0; i < values.length; i++) {
                resolvedValues[i] = propertyTypes[i].resolve(values[i], session, owner);
            }
            setPropertyValues(result, resolvedValues, enreplacedyMode);
            return result;
        } else if (isCreateEmptyCompositesEnabled()) {
            return instantiate(owner, session);
        } else {
            return null;
        }
    }

    @Override
    public Object semiResolve(Object value, SharedSessionContractImplementor session, Object owner) throws HibernateException {
        // note that this implementation is kinda broken
        // for components with many-to-one replacedociations
        return resolve(value, session, owner);
    }

    @Override
    public boolean[] getPropertyNullability() {
        return propertyNullability;
    }

    @Override
    public boolean[] toColumnNullness(Object value, Mapping mapping) {
        boolean[] result = new boolean[getColumnSpan(mapping)];
        if (value == null) {
            return result;
        }
        // TODO!!!!!!!
        Object[] values = getPropertyValues(value, EnreplacedyMode.POJO);
        int loc = 0;
        for (int i = 0; i < propertyTypes.length; i++) {
            boolean[] propertyNullness = propertyTypes[i].toColumnNullness(values[i], mapping);
            System.arraycopy(propertyNullness, 0, result, loc, propertyNullness.length);
            loc += propertyNullness.length;
        }
        return result;
    }

    @Override
    public boolean isEmbedded() {
        return false;
    }

    @Override
    public int getPropertyIndex(String name) {
        String[] names = getPropertyNames();
        for (int i = 0, max = names.length; i < max; i++) {
            if (names[i].equals(name)) {
                return i;
            }
        }
        throw new PropertyNotFoundException("Unable to locate property named " + name + " on " + getReturnedClreplaced().getName());
    }

    private Boolean canDoExtraction;

    @Override
    public boolean canDoExtraction() {
        if (canDoExtraction == null) {
            canDoExtraction = determineIfProcedureParamExtractionCanBePerformed();
        }
        return canDoExtraction;
    }

    private boolean determineIfProcedureParamExtractionCanBePerformed() {
        for (Type propertyType : propertyTypes) {
            if (!ProcedureParameterExtractionAware.clreplaced.isInstance(propertyType)) {
                return false;
            }
            if (!((ProcedureParameterExtractionAware) propertyType).canDoExtraction()) {
                return false;
            }
        }
        return true;
    }

    @Override
    public Object extract(CallableStatement statement, int startIndex, SharedSessionContractImplementor session) throws SQLException {
        Object[] values = new Object[propertySpan];
        int currentIndex = startIndex;
        boolean notNull = false;
        for (int i = 0; i < propertySpan; i++) {
            // we know this cast is safe from canDoExtraction
            final Type propertyType = propertyTypes[i];
            final Object value = ((ProcedureParameterExtractionAware) propertyType).extract(statement, currentIndex, session);
            if (value == null) {
                if (isKey) {
                    // different nullability rules for pk/fk
                    return null;
                }
            } else {
                notNull = true;
            }
            values[i] = value;
            currentIndex += propertyType.getColumnSpan(session.getFactory());
        }
        if (!notNull) {
            values = null;
        }
        return resolve(values, session, null);
    }

    @Override
    public Object extract(CallableStatement statement, String[] paramNames, SharedSessionContractImplementor session) throws SQLException {
        // for this form to work all sub-property spans must be one (1)...
        Object[] values = new Object[propertySpan];
        int indx = 0;
        boolean notNull = false;
        for (String paramName : paramNames) {
            // we know this cast is safe from canDoExtraction
            final ProcedureParameterExtractionAware propertyType = (ProcedureParameterExtractionAware) propertyTypes[indx];
            final Object value = propertyType.extract(statement, new String[] { paramName }, session);
            if (value == null) {
                if (isKey) {
                    // different nullability rules for pk/fk
                    return null;
                }
            } else {
                notNull = true;
            }
            values[indx] = value;
        }
        if (!notNull) {
            values = null;
        }
        return resolve(values, session, null);
    }

    @Override
    public boolean hasNotNullProperty() {
        return hasNotNullProperty;
    }

    private boolean isCreateEmptyCompositesEnabled() {
        return createEmptyCompositesEnabled;
    }
}

15 Source : Collection.java
with GNU General Public License v2.0
from lamsfoundation

/**
 * Mapping for a collection. Subclreplacedes specialize to particular collection styles.
 *
 * @author Gavin King
 */
public abstract clreplaced Collection implements Fetchable, Value, Filterable {

    public static final String DEFAULT_ELEMENT_COLUMN_NAME = "elt";

    public static final String DEFAULT_KEY_COLUMN_NAME = "id";

    private final MetadataImplementor metadata;

    private MetadataBuildingContext buildingContext;

    private PersistentClreplaced owner;

    private KeyValue key;

    private Value element;

    private Table collectionTable;

    private String role;

    private boolean lazy;

    private boolean extraLazy;

    private boolean inverse;

    private boolean mutable = true;

    private boolean subselectLoadable;

    private String cacheConcurrencyStrategy;

    private String cacheRegionName;

    private String orderBy;

    private String where;

    private String manyToManyWhere;

    private String manyToManyOrderBy;

    private String referencedPropertyName;

    private String mappedByProperty;

    private boolean sorted;

    private Comparator comparator;

    private String comparatorClreplacedName;

    private boolean orphanDelete;

    private int batchSize = -1;

    private FetchMode fetchMode;

    private boolean embedded = true;

    private boolean optimisticLocked = true;

    private Clreplaced collectionPersisterClreplaced;

    private String typeName;

    private Properties typeParameters;

    private final java.util.List filters = new ArrayList();

    private final java.util.List manyToManyFilters = new ArrayList();

    private final java.util.Set<String> synchronizedTables = new HashSet<String>();

    private String customSQLInsert;

    private boolean customInsertCallable;

    private ExecuteUpdateResultCheckStyle insertCheckStyle;

    private String customSQLUpdate;

    private boolean customUpdateCallable;

    private ExecuteUpdateResultCheckStyle updateCheckStyle;

    private String customSQLDelete;

    private boolean customDeleteCallable;

    private ExecuteUpdateResultCheckStyle deleteCheckStyle;

    private String customSQLDeleteAll;

    private boolean customDeleteAllCallable;

    private ExecuteUpdateResultCheckStyle deleteAllCheckStyle;

    private String loaderName;

    protected Collection(MetadataBuildingContext buildingContext, PersistentClreplaced owner) {
        this(buildingContext.getMetadataCollector(), owner);
        this.buildingContext = buildingContext;
    }

    /**
     * @deprecated Use {@link Collection#Collection(MetadataBuildingContext, PersistentClreplaced)} instead.
     */
    @Deprecated
    protected Collection(MetadataImplementor metadata, PersistentClreplaced owner) {
        this.metadata = metadata;
        this.owner = owner;
    }

    public MetadataImplementor getMetadata() {
        return metadata;
    }

    @Override
    public ServiceRegistry getServiceRegistry() {
        return getMetadata().getMetadataBuildingOptions().getServiceRegistry();
    }

    public boolean isSet() {
        return false;
    }

    public KeyValue getKey() {
        return key;
    }

    public Value getElement() {
        return element;
    }

    public boolean isIndexed() {
        return false;
    }

    public Table getCollectionTable() {
        return collectionTable;
    }

    public void setCollectionTable(Table table) {
        this.collectionTable = table;
    }

    public boolean isSorted() {
        return sorted;
    }

    public Comparator getComparator() {
        if (comparator == null && comparatorClreplacedName != null) {
            try {
                final ClreplacedLoaderService clreplacedLoaderService = getMetadata().getMetadataBuildingOptions().getServiceRegistry().getService(ClreplacedLoaderService.clreplaced);
                setComparator((Comparator) clreplacedLoaderService.clreplacedForName(comparatorClreplacedName).newInstance());
            } catch (Exception e) {
                throw new MappingException("Could not instantiate comparator clreplaced [" + comparatorClreplacedName + "] for collection " + getRole());
            }
        }
        return comparator;
    }

    public boolean isLazy() {
        return lazy;
    }

    public void setLazy(boolean lazy) {
        this.lazy = lazy;
    }

    public String getRole() {
        return role;
    }

    public abstract CollectionType getDefaultCollectionType() throws MappingException;

    public boolean isPrimitiveArray() {
        return false;
    }

    public boolean isArray() {
        return false;
    }

    public boolean hasFormula() {
        return false;
    }

    public boolean isOneToMany() {
        return element instanceof OneToMany;
    }

    public boolean isInverse() {
        return inverse;
    }

    public String getOwnerEnreplacedyName() {
        return owner.getEnreplacedyName();
    }

    public String getOrderBy() {
        return orderBy;
    }

    public void setComparator(Comparator comparator) {
        this.comparator = comparator;
    }

    public void setElement(Value element) {
        this.element = element;
    }

    public void setKey(KeyValue key) {
        this.key = key;
    }

    public void setOrderBy(String orderBy) {
        this.orderBy = orderBy;
    }

    public void setRole(String role) {
        this.role = role;
    }

    public void setSorted(boolean sorted) {
        this.sorted = sorted;
    }

    public void setInverse(boolean inverse) {
        this.inverse = inverse;
    }

    public PersistentClreplaced getOwner() {
        return owner;
    }

    /**
     * @param owner The owner
     *
     * @deprecated Inject the owner into constructor.
     */
    @Deprecated
    public void setOwner(PersistentClreplaced owner) {
        this.owner = owner;
    }

    public String getWhere() {
        return where;
    }

    public void setWhere(String where) {
        this.where = where;
    }

    public String getManyToManyWhere() {
        return manyToManyWhere;
    }

    public void setManyToManyWhere(String manyToManyWhere) {
        this.manyToManyWhere = manyToManyWhere;
    }

    public String getManyToManyOrdering() {
        return manyToManyOrderBy;
    }

    public void setManyToManyOrdering(String orderFragment) {
        this.manyToManyOrderBy = orderFragment;
    }

    public boolean isIdentified() {
        return false;
    }

    public boolean hasOrphanDelete() {
        return orphanDelete;
    }

    public void setOrphanDelete(boolean orphanDelete) {
        this.orphanDelete = orphanDelete;
    }

    public int getBatchSize() {
        return batchSize;
    }

    public void setBatchSize(int i) {
        batchSize = i;
    }

    public FetchMode getFetchMode() {
        return fetchMode;
    }

    public void setFetchMode(FetchMode fetchMode) {
        this.fetchMode = fetchMode;
    }

    public void setCollectionPersisterClreplaced(Clreplaced persister) {
        this.collectionPersisterClreplaced = persister;
    }

    public Clreplaced getCollectionPersisterClreplaced() {
        return collectionPersisterClreplaced;
    }

    public void validate(Mapping mapping) throws MappingException {
        replacedert getKey() != null : "Collection key not bound : " + getRole();
        replacedert getElement() != null : "Collection element not bound : " + getRole();
        if (!getKey().isValid(mapping)) {
            throw new MappingException("collection foreign key mapping has wrong number of columns: " + getRole() + " type: " + getKey().getType().getName());
        }
        if (!getElement().isValid(mapping)) {
            throw new MappingException("collection element mapping has wrong number of columns: " + getRole() + " type: " + getElement().getType().getName());
        }
        checkColumnDuplication();
    }

    private void checkColumnDuplication(java.util.Set distinctColumns, Value value) throws MappingException {
        final boolean[] insertability = value.getColumnInsertability();
        final boolean[] updatability = value.getColumnUpdateability();
        final Iterator<Selectable> iterator = value.getColumnIterator();
        int i = 0;
        while (iterator.hasNext()) {
            Selectable s = iterator.next();
            // exclude formulas and coluns that are not insertable or updatable
            // since these values can be be repeated (HHH-5393)
            if (!s.isFormula() && (insertability[i] || updatability[i])) {
                Column col = (Column) s;
                if (!distinctColumns.add(col.getName())) {
                    throw new MappingException("Repeated column in mapping for collection: " + getRole() + " column: " + col.getName());
                }
            }
            i++;
        }
    }

    private void checkColumnDuplication() throws MappingException {
        HashSet cols = new HashSet();
        checkColumnDuplication(cols, getKey());
        if (isIndexed()) {
            checkColumnDuplication(cols, ((IndexedCollection) this).getIndex());
        }
        if (isIdentified()) {
            checkColumnDuplication(cols, ((IdentifierCollection) this).getIdentifier());
        }
        if (!isOneToMany()) {
            checkColumnDuplication(cols, getElement());
        }
    }

    public Iterator<Selectable> getColumnIterator() {
        return Collections.<Selectable>emptyList().iterator();
    }

    public int getColumnSpan() {
        return 0;
    }

    public Type getType() throws MappingException {
        return getCollectionType();
    }

    public CollectionType getCollectionType() {
        if (typeName == null) {
            return getDefaultCollectionType();
        } else {
            return getMetadata().getTypeConfiguration().getTypeResolver().getTypeFactory().customCollection(typeName, typeParameters, role, referencedPropertyName);
        }
    }

    public boolean isNullable() {
        return true;
    }

    public boolean isAlternateUniqueKey() {
        return false;
    }

    public Table getTable() {
        return owner.getTable();
    }

    public void createForeignKey() {
    }

    public boolean isSimpleValue() {
        return false;
    }

    public boolean isValid(Mapping mapping) throws MappingException {
        return true;
    }

    @Override
    public boolean isSame(Value other) {
        return this == other || other instanceof Collection && isSame((Collection) other);
    }

    protected static boolean isSame(Value v1, Value v2) {
        return v1 == v2 || v1 != null && v2 != null && v1.isSame(v2);
    }

    public boolean isSame(Collection other) {
        return this == other || isSame(key, other.key) && isSame(element, other.element) && Objects.equals(collectionTable, other.collectionTable) && Objects.equals(where, other.where) && Objects.equals(manyToManyWhere, other.manyToManyWhere) && Objects.equals(referencedPropertyName, other.referencedPropertyName) && Objects.equals(mappedByProperty, other.mappedByProperty) && Objects.equals(typeName, other.typeName) && Objects.equals(typeParameters, other.typeParameters);
    }

    private void createForeignKeys() throws MappingException {
        // if ( !isInverse() ) { // for inverse collections, let the "other end" handle it
        if (referencedPropertyName == null) {
            getElement().createForeignKey();
            key.createForeignKeyOfEnreplacedy(getOwner().getEnreplacedyName());
        }
    // }
    }

    abstract void createPrimaryKey();

    public void createAllKeys() throws MappingException {
        createForeignKeys();
        if (!isInverse()) {
            createPrimaryKey();
        }
    }

    public String getCacheConcurrencyStrategy() {
        return cacheConcurrencyStrategy;
    }

    public void setCacheConcurrencyStrategy(String cacheConcurrencyStrategy) {
        this.cacheConcurrencyStrategy = cacheConcurrencyStrategy;
    }

    public void setTypeUsingReflection(String clreplacedName, String propertyName) {
    }

    public String getCacheRegionName() {
        return cacheRegionName == null ? role : cacheRegionName;
    }

    public void setCacheRegionName(String cacheRegionName) {
        this.cacheRegionName = StringHelper.nullIfEmpty(cacheRegionName);
    }

    public void setCustomSQLInsert(String customSQLInsert, boolean callable, ExecuteUpdateResultCheckStyle checkStyle) {
        this.customSQLInsert = customSQLInsert;
        this.customInsertCallable = callable;
        this.insertCheckStyle = checkStyle;
    }

    public String getCustomSQLInsert() {
        return customSQLInsert;
    }

    public boolean isCustomInsertCallable() {
        return customInsertCallable;
    }

    public ExecuteUpdateResultCheckStyle getCustomSQLInsertCheckStyle() {
        return insertCheckStyle;
    }

    public void setCustomSQLUpdate(String customSQLUpdate, boolean callable, ExecuteUpdateResultCheckStyle checkStyle) {
        this.customSQLUpdate = customSQLUpdate;
        this.customUpdateCallable = callable;
        this.updateCheckStyle = checkStyle;
    }

    public String getCustomSQLUpdate() {
        return customSQLUpdate;
    }

    public boolean isCustomUpdateCallable() {
        return customUpdateCallable;
    }

    public ExecuteUpdateResultCheckStyle getCustomSQLUpdateCheckStyle() {
        return updateCheckStyle;
    }

    public void setCustomSQLDelete(String customSQLDelete, boolean callable, ExecuteUpdateResultCheckStyle checkStyle) {
        this.customSQLDelete = customSQLDelete;
        this.customDeleteCallable = callable;
        this.deleteCheckStyle = checkStyle;
    }

    public String getCustomSQLDelete() {
        return customSQLDelete;
    }

    public boolean isCustomDeleteCallable() {
        return customDeleteCallable;
    }

    public ExecuteUpdateResultCheckStyle getCustomSQLDeleteCheckStyle() {
        return deleteCheckStyle;
    }

    public void setCustomSQLDeleteAll(String customSQLDeleteAll, boolean callable, ExecuteUpdateResultCheckStyle checkStyle) {
        this.customSQLDeleteAll = customSQLDeleteAll;
        this.customDeleteAllCallable = callable;
        this.deleteAllCheckStyle = checkStyle;
    }

    public String getCustomSQLDeleteAll() {
        return customSQLDeleteAll;
    }

    public boolean isCustomDeleteAllCallable() {
        return customDeleteAllCallable;
    }

    public ExecuteUpdateResultCheckStyle getCustomSQLDeleteAllCheckStyle() {
        return deleteAllCheckStyle;
    }

    public void addFilter(String name, String condition, boolean autoAliasInjection, java.util.Map<String, String> aliasTableMap, java.util.Map<String, String> aliasEnreplacedyMap) {
        filters.add(new FilterConfiguration(name, condition, autoAliasInjection, aliasTableMap, aliasEnreplacedyMap, null));
    }

    public java.util.List getFilters() {
        return filters;
    }

    public void addManyToManyFilter(String name, String condition, boolean autoAliasInjection, java.util.Map<String, String> aliasTableMap, java.util.Map<String, String> aliasEnreplacedyMap) {
        manyToManyFilters.add(new FilterConfiguration(name, condition, autoAliasInjection, aliasTableMap, aliasEnreplacedyMap, null));
    }

    public java.util.List getManyToManyFilters() {
        return manyToManyFilters;
    }

    @Override
    public String toString() {
        return getClreplaced().getName() + '(' + getRole() + ')';
    }

    public java.util.Set<String> getSynchronizedTables() {
        return synchronizedTables;
    }

    public String getLoaderName() {
        return loaderName;
    }

    public void setLoaderName(String name) {
        this.loaderName = name;
    }

    public String getReferencedPropertyName() {
        return referencedPropertyName;
    }

    public void setReferencedPropertyName(String propertyRef) {
        this.referencedPropertyName = propertyRef;
    }

    public boolean isOptimisticLocked() {
        return optimisticLocked;
    }

    public void setOptimisticLocked(boolean optimisticLocked) {
        this.optimisticLocked = optimisticLocked;
    }

    public boolean isMap() {
        return false;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public Properties getTypeParameters() {
        return typeParameters;
    }

    public void setTypeParameters(Properties parameterMap) {
        this.typeParameters = parameterMap;
    }

    public void setTypeParameters(java.util.Map parameterMap) {
        if (parameterMap instanceof Properties) {
            this.typeParameters = (Properties) parameterMap;
        } else {
            this.typeParameters = new Properties();
            typeParameters.putAll(parameterMap);
        }
    }

    public boolean[] getColumnInsertability() {
        return ArrayHelper.EMPTY_BOOLEAN_ARRAY;
    }

    public boolean[] getColumnUpdateability() {
        return ArrayHelper.EMPTY_BOOLEAN_ARRAY;
    }

    public boolean isSubselectLoadable() {
        return subselectLoadable;
    }

    public void setSubselectLoadable(boolean subqueryLoadable) {
        this.subselectLoadable = subqueryLoadable;
    }

    public boolean isMutable() {
        return mutable;
    }

    public void setMutable(boolean mutable) {
        this.mutable = mutable;
    }

    public boolean isExtraLazy() {
        return extraLazy;
    }

    public void setExtraLazy(boolean extraLazy) {
        this.extraLazy = extraLazy;
    }

    public boolean hasOrder() {
        return orderBy != null || manyToManyOrderBy != null;
    }

    public void setComparatorClreplacedName(String comparatorClreplacedName) {
        this.comparatorClreplacedName = comparatorClreplacedName;
    }

    public String getComparatorClreplacedName() {
        return comparatorClreplacedName;
    }

    public String getMappedByProperty() {
        return mappedByProperty;
    }

    public void setMappedByProperty(String mappedByProperty) {
        this.mappedByProperty = mappedByProperty;
    }
}

15 Source : BasicCollectionJoinWalker.java
with GNU General Public License v2.0
from lamsfoundation

protected JoinType getJoinType(OuterJoinLoadable persister, PropertyPath path, int propertyNumber, replacedociationType replacedociationType, FetchMode metadataFetchMode, CascadeStyle metadataCascadeStyle, String lhsTable, String[] lhsColumns, boolean nullable, int currentDepth) throws MappingException {
    JoinType joinType = super.getJoinType(persister, path, propertyNumber, replacedociationType, metadataFetchMode, metadataCascadeStyle, lhsTable, lhsColumns, nullable, currentDepth);
    // we can use an inner join for the many-to-many
    if (joinType == JoinType.LEFT_OUTER_JOIN && path.isRoot()) {
        joinType = JoinType.INNER_JOIN;
    }
    return joinType;
}

14 Source : EntityJoinWalker.java
with GNU General Public License v2.0
from lamsfoundation

protected JoinType getJoinType(OuterJoinLoadable persister, PropertyPath path, int propertyNumber, replacedociationType replacedociationType, FetchMode metadataFetchMode, CascadeStyle metadataCascadeStyle, String lhsTable, String[] lhsColumns, boolean nullable, int currentDepth) throws MappingException {
    // NOTE : we override this form here specifically to account for
    // fetch profiles.
    // TODO : how to best handle criteria queries?
    if (lockOptions.getLockMode().greaterThan(LockMode.READ)) {
        return JoinType.NONE;
    }
    if (isTooDeep(currentDepth) || (replacedociationType.isCollectionType() && isTooManyCollections())) {
        return JoinType.NONE;
    }
    if (!isJoinedFetchEnabledInMapping(metadataFetchMode, replacedociationType) && !isJoinFetchEnabledByProfile(persister, path, propertyNumber)) {
        return JoinType.NONE;
    }
    if (isDuplicatereplacedociation(lhsTable, lhsColumns, replacedociationType)) {
        return JoinType.NONE;
    }
    return getJoinType(nullable, currentDepth);
}

14 Source : CriteriaJoinWalker.java
with GNU General Public License v2.0
from lamsfoundation

@Override
protected JoinType getJoinType(OuterJoinLoadable persister, final PropertyPath path, int propertyNumber, replacedociationType replacedociationType, 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 {
            String fullPathWithAlias = path.getFullPath();
            String rootAlias = translator.getRootCriteria().getAlias();
            String rootAliasPathPrefix = rootAlias + ".";
            if (rootAlias != null && !fullPathWithAlias.startsWith(rootAliasPathPrefix)) {
                fullPathWithAlias = rootAliasPathPrefix + fullPathWithAlias;
            }
            FetchMode fetchMode = translator.getRootCriteria().getFetchMode(fullPathWithAlias);
            if (isDefaultFetchMode(fetchMode)) {
                if (persister != null) {
                    if (isJoinFetchEnabledByProfile(persister, path, propertyNumber)) {
                        if (isDuplicatereplacedociation(lhsTable, lhsColumns, replacedociationType)) {
                            resolvedJoinType = JoinType.NONE;
                        } else if (isTooDeep(currentDepth) || (replacedociationType.isCollectionType() && isTooManyCollections())) {
                            resolvedJoinType = JoinType.NONE;
                        } else {
                            resolvedJoinType = getJoinType(nullable, currentDepth);
                        }
                    } else {
                        resolvedJoinType = super.getJoinType(persister, path, propertyNumber, replacedociationType, metadataFetchMode, metadataCascadeStyle, lhsTable, lhsColumns, nullable, currentDepth);
                    }
                } else {
                    resolvedJoinType = super.getJoinType(replacedociationType, metadataFetchMode, path, lhsTable, lhsColumns, nullable, currentDepth, metadataCascadeStyle);
                }
            } else {
                if (fetchMode == FetchMode.JOIN) {
                    isDuplicatereplacedociation(lhsTable, lhsColumns, replacedociationType);
                    // deliberately ignore return value!
                    resolvedJoinType = getJoinType(nullable, currentDepth);
                } else {
                    resolvedJoinType = JoinType.NONE;
                }
            }
        }
    }
    return resolvedJoinType;
}

12 Source : FetchStrategyHelper.java
with GNU General Public License v2.0
from lamsfoundation

/**
 * @param mappingFetchMode The mapping defined fetch mode
 * @param type The replacedociation type
 * @param sessionFactory The session factory
 *
 * @return the fetch style
 */
public static FetchStyle determineFetchStyleByMetadata(FetchMode mappingFetchMode, replacedociationType type, SessionFactoryImplementor sessionFactory) {
    if (!type.isEnreplacedyType() && !type.isCollectionType()) {
        return FetchStyle.SELECT;
    }
    if (mappingFetchMode == FetchMode.JOIN) {
        return FetchStyle.JOIN;
    }
    if (type.isEnreplacedyType()) {
        EnreplacedyPersister persister = (EnreplacedyPersister) type.getreplacedociatedJoinable(sessionFactory);
        if (persister.isBatchLoadable()) {
            return FetchStyle.BATCH;
        } else if (mappingFetchMode == FetchMode.SELECT) {
            return FetchStyle.SELECT;
        } else if (!persister.hasProxy()) {
            return FetchStyle.JOIN;
        }
    } else {
        CollectionPersister persister = (CollectionPersister) type.getreplacedociatedJoinable(sessionFactory);
        if (persister instanceof AbstractCollectionPersister && ((AbstractCollectionPersister) persister).isSubselectLoadable()) {
            return FetchStyle.SUBSELECT;
        } else if (persister.getBatchSize() > 0) {
            return FetchStyle.BATCH;
        }
    }
    return FetchStyle.SELECT;
}