@Override public Object hydrate( final ResultSet rs, final String[] names, final SessionImplementor 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()); String[] range = ArrayHelper.slice(names, begin, length); // cache this Object val = propertyTypes[i].hydrate(rs, range, session, owner); if (val == null) { if (isKey) { return null; // different nullability rules for pk/fk } } else { notNull = true; } values[i] = val; begin += length; } return notNull ? values : null; }
/** For a composite element, add to a list of associations to be fetched by outerjoin */ private void walkCompositeElementTree( final CompositeType compositeType, final String[] cols, final QueryableCollection persister, final String alias, final PropertyPath path, final int currentDepth) throws MappingException { Type[] types = compositeType.getSubtypes(); String[] propertyNames = compositeType.getPropertyNames(); int begin = 0; for (int i = 0; i < types.length; i++) { int length = types[i].getColumnSpan(getFactory()); String[] lhsColumns = ArrayHelper.slice(cols, begin, length); if (types[i].isAssociationType()) { AssociationType associationType = (AssociationType) types[i]; // simple, because we can't have a one-to-one or a collection // (or even a property-ref) in a composite-element: String[] aliasedLhsColumns = StringHelper.qualify(alias, lhsColumns); final PropertyPath subPath = path.append(propertyNames[i]); final boolean[] propertyNullability = compositeType.getPropertyNullability(); final JoinType joinType = getJoinType( associationType, compositeType.getFetchMode(i), subPath, persister.getTableName(), lhsColumns, propertyNullability == null || propertyNullability[i], currentDepth, compositeType.getCascadeStyle(i)); addAssociationToJoinTreeIfNecessary( associationType, aliasedLhsColumns, alias, subPath, currentDepth, joinType); } else if (types[i].isComponentType()) { final PropertyPath subPath = path.append(propertyNames[i]); walkCompositeElementTree( (CompositeType) types[i], lhsColumns, persister, alias, subPath, currentDepth); } begin += length; } }