}
// Populate columns data
MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
m.getPersistenceUnit());
EntityType entityType = metaModel.entity(m.getEntityClazz());
Set<Attribute> attributes = entityType.getAttributes();
String discrColumn = ((AbstractManagedType) entityType).getDiscriminatorColumn();
String discrValue = ((AbstractManagedType) entityType).getDiscriminatorValue();
if (discrColumn != null && hbaseData.getColumnValue(discrColumn) != null && discrValue != null)
{
byte[] discrimnatorValue = hbaseData.getColumnValue(discrColumn);
String actualDiscriminatorValue = Bytes.toString(discrimnatorValue);
if (actualDiscriminatorValue != null && !actualDiscriminatorValue.equals(discrValue))
{
entity = null;
return entity;
}
}
for (Attribute attribute : attributes)
{
Class javaType = ((AbstractAttribute) attribute).getBindableJavaType();
String key = ((AbstractAttribute) attribute).getJPAColumnName();
if (metaModel.isEmbeddable(javaType))
{
EmbeddableType columnFamily = metaModel.embeddable(javaType);
Field columnFamilyFieldInEntity = (Field) attribute.getJavaMember();
Class<?> columnFamilyClass = columnFamilyFieldInEntity.getType();
// Get a name->field map for columns in this column family
Map<String, Field> columnNameToFieldMap = MetadataUtils.createColumnsFieldMap(m, columnFamily);
// Column family can be either @Embedded or
// @EmbeddedCollection
if (Collection.class.isAssignableFrom(columnFamilyClass))
{
Map<Integer, Object> elementCollectionObjects = new HashMap<Integer, Object>();
Field embeddedCollectionField = (Field) attribute.getJavaMember();
Object[] embeddedObjectArr = new Object[hbaseData.getColumns().size()];
Object embeddedObject = MetadataUtils.getEmbeddedGenericObjectInstance(embeddedCollectionField);
Map<String, byte[]> hbaseValues = hbaseData.getColumns();
Set<String> columnNames = hbaseValues.keySet();
for (String columnName : columnNames)
{
byte[] columnValue = hbaseData.getColumnValue(columnName);
if (columnName.startsWith(((AbstractAttribute) attribute).getJPAColumnName()))
{
String cfNamePostfix = MetadataUtils.getEmbeddedCollectionPostfix(columnName);
int cfNameCounter = Integer.parseInt(cfNamePostfix);
embeddedObject = elementCollectionObjects.get(cfNameCounter);
if (embeddedObject == null)
{
embeddedObject = MetadataUtils
.getEmbeddedGenericObjectInstance(embeddedCollectionField);
}
// Set Hbase data into the embedded object
setHBaseDataIntoObject(columnName, columnValue, columnNameToFieldMap, embeddedObject,
metaModel.isEmbeddable(javaType));
elementCollectionObjects.put(cfNameCounter, embeddedObject);
}