Get Embedded column info.

@param embeddableType
@param embeddableColName
@param embeddedEntityClass
@param field
@return
182664
private EmbeddedColumnInfo getEmbeddedColumn(TableInfo tableInfo, EmbeddableType embeddableType,
            String embeddableColName, Class embeddedEntityClass, Field field)
    {

        String[] orderByColumns = null;
        if (field.isAnnotationPresent(OrderBy.class))
        {
            OrderBy order = (OrderBy) field.getAnnotation(OrderBy.class);
            orderByColumns = order.value().split("\\s*,\\s*");
        }
        EmbeddedColumnInfo embeddedColumnInfo = new EmbeddedColumnInfo(embeddableType);
        embeddedColumnInfo.setEmbeddedColumnName(embeddableColName);
        Map<String, PropertyIndex> indexedColumns = IndexProcessor.getIndexesOnEmbeddable(embeddedEntityClass);
        List<ColumnInfo> columns = new ArrayList<ColumnInfo>();

        Set attributes = embeddableType.getAttributes();
        Iterator<Attribute> iter = attributes.iterator();

        while (iter.hasNext())
        {
            Attribute attr = iter.next();
            columns.add(getColumn(tableInfo, attr, indexedColumns.get(attr.getName()), orderByColumns));
        }
        embeddedColumnInfo.setColumns(columns);
        return embeddedColumnInfo;
    }
678075
protected void createSuperColumnDocument(EntityMetadata metadata, Object object, Document currentDoc,
        Object embeddedObject, EmbeddableType superColumn, MetamodelImpl metamodel) {

        // Add all super column fields into document
        Set<Attribute> attributes = superColumn.getAttributes();
        Iterator<Attribute> iter = attributes.iterator();
        while (iter.hasNext()) {
            Attribute attr = iter.next();
            java.lang.reflect.Field field = (java.lang.reflect.Field) attr.getJavaMember();
            String colName = field.getName();
            String indexName = metadata.getIndexName();
            addFieldToDocument(embeddedObject, currentDoc, field, colName, indexName);
        }

        // Add all entity fields to document
        addEntityFieldsToDocument(metadata, object, currentDoc, metamodel);

    }
932401
private static void onEmbeddable(EntityType entityType, Attribute column, Object entity,
            EmbeddableType embeddableType, JsonObject jsonObject)
    {
        Object embeddedObject = PropertyAccessorHelper.getObject(entity, (Field) column.getJavaMember());
        String embeddedColumnName = ((AbstractAttribute) column).getJPAColumnName();
        Set<Attribute> embeddableAttributes = embeddableType.getAttributes();
        jsonObject.add(embeddedColumnName, getJsonObject(embeddableAttributes, embeddedObject));
    }
511536
private static Pair<String, String> getColumnName(Field field) {
        String fieldName = field.getName();
        Column column    = field.getAnnotation(Column.class);
        if (null != column && StringUtils.isNotBlank(column.name())) {
            fieldName = column.name();
        }
        String columnName = NameUtils.getUnderlineName(fieldName);
        return new Pair<>(columnName, fieldName);
    }
1304166
public Map<String, EmbeddableType> getEmbeddables(Class clazz)
    {
        Map<String, EmbeddableType> embeddableAttibutes = new HashMap<String, EmbeddableType>();

        if (entityTypes != null)
        {
            EntityType entity = entityTypes.get(clazz);
            Iterator<Attribute> iter = entity.getAttributes().iterator();
            while (iter.hasNext())
            {
                Attribute attribute = iter.next();
                if (isEmbeddable(((AbstractAttribute) attribute).getBindableJavaType()))
                {
                    embeddableAttibutes.put(attribute.getName(),
                            embeddable(((AbstractAttribute) attribute).getBindableJavaType()));
                }
            }
        }
        return embeddableAttibutes;
    }
61409
private void addPrimaryKeyToRow(PartialRow row, EmbeddableType embeddable, Field[] fields, MetamodelImpl metaModel,
            Object key)
    {
        for (Field f : fields)
        {
            if (!ReflectUtils.isTransientOrStatic(f))
            {
                Object value = PropertyAccessorHelper.getObject(key, f);
                if (f.getType().isAnnotationPresent(Embeddable.class))
                {
                    // nested
                    addPrimaryKeyToRow(row, (EmbeddableType) metaModel.embeddable(f.getType()),
                            f.getType().getDeclaredFields(), metaModel, value);
                }
                else
                {
                    Attribute attribute = embeddable.getAttribute(f.getName());
                    Type type = KuduDBValidationClassMapper.getValidTypeForClass(f.getType());
                    KuduDBDataHandler.addToRow(row, ((AbstractAttribute) attribute).getJPAColumnName(), value, type);
                }

            }
        }

    }
1373721
private void readEmbeddable(Object key, List<String> columnsToSelect, EntityMetadata entityMetadata,
            MetamodelImpl metamodel, Table schemaTable, RecordValue value, Attribute attribute)
    {
        EmbeddableType embeddableId = metamodel.embeddable(((AbstractAttribute) attribute).getBindableJavaType());
        Set<Attribute> embeddedAttributes = embeddableId.getAttributes();

        for (Attribute embeddedAttrib : embeddedAttributes)
        {
            String columnName = ((AbstractAttribute) embeddedAttrib).getJPAColumnName();
            Object embeddedColumn = PropertyAccessorHelper.getObject(key, (Field) embeddedAttrib.getJavaMember());

            // either null or empty or contains that column
            if (eligibleToFetch(columnsToSelect, columnName))
            {
                NoSqlDBUtils.add(schemaTable.getField(columnName), value, embeddedColumn, columnName);
            }
        }
    }
368854
private void marshalEmbeddedFields() {
    for (EmbeddedMetadata embeddedMetadata : entityMetadata.getEmbeddedMetadataCollection()) {
      if (embeddedMetadata.getStorageStrategy() == StorageStrategy.EXPLODED) {
        marshalWithExplodedStrategy(embeddedMetadata, entity);
      } else {
        ValueBuilder<?, ?, ?> embeddedEntityBuilder = marshalWithImplodedStrategy(embeddedMetadata,
            entity);
        if (embeddedEntityBuilder != null) {
          entityBuilder.set(embeddedMetadata.getMappedName(), embeddedEntityBuilder.build());
        }
      }
    }

  }
582177
public function inlineEmbeddable($property, ClassMetadataInfo $embeddable)
    {
        foreach ($embeddable->fieldMappings as $fieldMapping) {
            $fieldMapping['originalClass'] = isset($fieldMapping['originalClass'])
                ? $fieldMapping['originalClass']
                : $embeddable->name;
            $fieldMapping['declaredField'] = isset($fieldMapping['declaredField'])
                ? $property . '.' . $fieldMapping['declaredField']
                : $property;
            $fieldMapping['originalField'] = isset($fieldMapping['originalField'])
                ? $fieldMapping['originalField']
                : $fieldMapping['fieldName'];
            $fieldMapping['fieldName'] = $property . "." . $fieldMapping['fieldName'];

            if (! empty($this->embeddedClasses[$property]['columnPrefix'])) {
                $fieldMapping['columnName'] = $this->embeddedClasses[$property]['columnPrefix'] . $fieldMapping['columnName'];
            } elseif ($this->embeddedClasses[$property]['columnPrefix'] !== false) {
                $fieldMapping['columnName'] = $this->namingStrategy
                    ->embeddedFieldToColumnName(
                        $property,
                        $fieldMapping['columnName'],
                        $this->reflClass->name,
                        $embeddable->reflClass->name
                    );
            }

            $this->mapField($fieldMapping);
        }
    }
49680
private void setField(Row row, Table schemaTable, Object embeddedObject, Attribute embeddedAttrib)
    {
        Field field = (Field) embeddedAttrib.getJavaMember();
        FieldDef fieldDef = schemaTable.getField(((AbstractAttribute) embeddedAttrib).getJPAColumnName());

        Object valueObj = PropertyAccessorHelper.getObject(embeddedObject, field);

        if (valueObj != null)
            NoSqlDBUtils.add(fieldDef, row, valueObj, ((AbstractAttribute) embeddedAttrib).getJPAColumnName());

    }
1165312
private String initUpdateEmbeddedColumnQuery(Object[] keyValues, String embeddedColumn) {
		StringBuilder queryBuilder = new StringBuilder( getUpdateEmbeddedNodeQuery() );
		String[] columns = appendEmbeddedNodes( embeddedColumn, queryBuilder );
		queryBuilder.append( " ON CREATE SET e." );
		escapeIdentifier( queryBuilder, columns[columns.length - 1] );
		queryBuilder.append( " = {" );
		queryBuilder.append( keyValues.length );
		queryBuilder.append( "}" );
		queryBuilder.append( " ON MATCH SET e." );
		escapeIdentifier( queryBuilder, columns[columns.length - 1] );
		queryBuilder.append( " = {" );
		queryBuilder.append( keyValues.length + 1 );
		queryBuilder.append( "}" );
		return queryBuilder.toString();
	}
903865
private void unmarshalEmbeddedFields() throws Throwable {
    for (EmbeddedMetadata embeddedMetadata : entityMetadata.getEmbeddedMetadataCollection()) {
      if (embeddedMetadata.getStorageStrategy() == StorageStrategy.EXPLODED) {
        unmarshalWithExplodedStrategy(embeddedMetadata, entity);
      } else {
        unmarshalWithImplodedStrategy(embeddedMetadata, entity, nativeEntity);
      }
    }
  }
867775
private AttributeWrapper wrap(EntityMetadata entityMetadata, Object entity)
    {
        MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
                entityMetadata.getPersistenceUnit());

        EntityType entityType = metaModel.entity(entityMetadata.getEntityClazz());
        Set<Attribute> attributes = entityType.getAttributes();

        // attributes can be null??? i guess NO
        AttributeWrapper wrapper = new AttributeWrapper(attributes.size());

        List<String> relationNames = entityMetadata.getRelationNames();

        // PropertyAccessorHelper.get(entity,
        for (Attribute attr : attributes)
        {
            if (/* !entityMetadata.getIdAttribute().equals(attr) && */!attr.isAssociation())
            {
                if (metaModel.isEmbeddable(((AbstractAttribute) attr).getBindableJavaType()))
                {
                    EmbeddableType embeddableAttribute = metaModel.embeddable(((AbstractAttribute) attr)
                            .getBindableJavaType());

                    Object embeddedObject = PropertyAccessorHelper.getObject(entity, (Field) attr.getJavaMember());

                    Set<Attribute> embeddedAttributes = embeddableAttribute.getAttributes();

                    for (Attribute attrib : embeddedAttributes)
                    {
                        addToWrapper(entityMetadata, wrapper, embeddedObject, attrib, attr);
                    }

                }
                else
                {
                    addToWrapper(entityMetadata, wrapper, entity, attr);
                }
            }
            else if (attributes.size() == 1) // means it is only a key! weird
                                             // but possible negative
                                             // scenario
            {
                byte[] value = PropertyAccessorHelper.get(entity, (Field) attr.getJavaMember());
                byte[] name;
                name = getEncodedBytes(((AbstractAttribute) attr).getJPAColumnName());

                // add column name as key and value as value
                wrapper.addColumn(name, value);

            }
        }

        return wrapper;
    }
1227449
private void populateEmbeddedColumn(Object entity, RowResult result, EmbeddableType embeddable,
            MetamodelImpl metaModel)
    {
        Set<Attribute> attributes = embeddable.getAttributes();
        Iterator<Attribute> iterator = attributes.iterator();

        iterateAndPopulateEntity(entity, result, metaModel, iterator);
    }
235652
public static BasicDBObject getCompoundKeyColumns(EntityMetadata m, Object id, EmbeddableType compoundKey,
            MetamodelImpl metaModel)
    {
        BasicDBObject compoundKeyObj = new BasicDBObject();

        Set<Attribute> attribs = compoundKey.getDeclaredAttributes();

        Field[] fields = m.getIdAttribute().getBindableJavaType().getDeclaredFields();

        // To ensure order.
        for (Attribute attr : attribs)
        {
            Field f = (Field) attr.getJavaMember();
            if (!ReflectUtils.isTransientOrStatic(f))
            {
                if (f.getAnnotation(Embedded.class) != null)
                {
                    EmbeddableType emb = metaModel.embeddable(f.getType());
                    Object val = PropertyAccessorHelper.getObject(id, f);
                    BasicDBObject dbVal = getCompoundKeyColumns(m, val, emb, metaModel);
                    compoundKeyObj.put(((AbstractAttribute) attr).getJPAColumnName(), dbVal);
                }
                else
                {
                    compoundKeyObj.put(
                            ((AbstractAttribute) attr).getJPAColumnName(),
                            populateValue(PropertyAccessorHelper.getObject(id, (Field) attr.getJavaMember()),
                                    ((AbstractAttribute) attr).getBindableJavaType()));

                }
            }
        }
        return compoundKeyObj;
    }
601091
private void onValidateEmbeddable(Object embeddedObject, EmbeddableType embeddedColumn)
    {
        if (embeddedObject instanceof Collection)
        {
           
            for (Object obj : (Collection) embeddedObject)
            {
                for (Object column : embeddedColumn.getAttributes())
                {

                    Attribute columnAttribute = (Attribute) column;
                    Field f = (Field) columnAttribute.getJavaMember();
                    this.factory.validate(f, embeddedObject, new AttributeConstraintRule());
                }
            }
        }
        else
        {
            for (Object column : embeddedColumn.getAttributes())
            {

                Attribute columnAttribute = (Attribute) column;
                Field f = (Field) ((Field) columnAttribute.getJavaMember());
                this.factory.validate(f, embeddedObject, new AttributeConstraintRule());

            }
        }

    }
1178052
private void processEmbeddable(Object entity, HBaseDataWrapper hbaseData, EntityMetadata m,
            MetamodelImpl metaModel, int count, String prefix, Attribute attribute, Class javaType)
    {
        Set<Attribute> attribEmbeddables = metaModel.embeddable(javaType).getAttributes();
        Object embeddedField = KunderaCoreUtils.createNewInstance(javaType);
        if (!attribute.isCollection())
        {
            String newPrefix = prefix != "" ? prefix + ((AbstractAttribute) attribute).getJPAColumnName()
                    + HBaseUtils.DOT : ((AbstractAttribute) attribute).getJPAColumnName() + HBaseUtils.DOT;
            writeValuesToEntity(embeddedField, hbaseData, m, metaModel, attribEmbeddables, null, null, count, newPrefix);
            PropertyAccessorHelper.set(entity, (Field) attribute.getJavaMember(), embeddedField);
        }
        else
        {
            int newCount = count + 1;
            String newPrefix = prefix != "" ? prefix + ((AbstractAttribute) attribute).getJPAColumnName()
                    + HBaseUtils.DELIM : ((AbstractAttribute) attribute).getJPAColumnName() + HBaseUtils.DELIM;
            List embeddedCollection = new ArrayList();
            byte[] columnValue = hbaseData.getColumnValue(HBaseUtils.getColumnDataKey(m.getTableName(), newPrefix
                    + HBaseUtils.SIZE));
            int size = 0;
            if (columnValue != null)
            {
                size = Bytes.toInt(columnValue);
            }
            while (size != newCount)
            {
                embeddedField = KunderaCoreUtils.createNewInstance(javaType);
                writeValuesToEntity(embeddedField, hbaseData, m, metaModel, attribEmbeddables, null, null, newCount++,
                        newPrefix);
                embeddedCollection.add(embeddedField);
            }
            PropertyAccessorHelper.set(entity, (Field) attribute.getJavaMember(), embeddedCollection);
        }
    }