Map<String, Object> columnNameToValue = new HashMap<String, Object>();
if (column.isCollection())
{
String dynamicCFName = null;
ElementCollectionCacheManager ecCacheHandler = ElementCollectionCacheManager.getInstance();
// Check whether it's first time insert or updation
if (ecCacheHandler.isCacheEmpty())
{ // First time insert
int count = 0;
for (Object obj : (Collection) columnFamilyObject)
{
String embeddableColumFamilyName = columFamilyTableName;
Map<Map<String, Class<?>>, HBaseDataWrapper> embeDaableDataWrappers = new HashMap<Map<String, Class<?>>, HBaseDataWrapper>();
for (Attribute attribute : columns)
{
embeddableColumFamilyName = ((AbstractAttribute) attribute).getTableName() != null ? ((AbstractAttribute) attribute)
.getTableName() : columFamilyTableName;
String columnName = columnFamilyName + Constants.EMBEDDED_COLUMN_NAME_DELIMITER
+ ((AbstractAttribute) attribute).getJPAColumnName()
+ Constants.EMBEDDED_COLUMN_NAME_DELIMITER + count;
Map<String, Class<?>> embeddableMap = new HashMap<String, Class<?>>();
embeddableMap.put(embeddableColumFamilyName, obj.getClass());
embeDaableDataWrappers = getEmbeddableHBaseWrapperObj(rowId, obj,
embeddableColumFamilyName, embeDaableDataWrappers, persistentData,
embeddableMap);
HBaseDataWrapper embeddableColumnWrapper = embeDaableDataWrappers
.get(embeddableMap);
embeddableColumnWrapper.setColumnFamily(embeddableColumFamilyName);
embeddableColumnWrapper.addColumn(columnName, attribute);
embeddableColumnWrapper.addValue(columnName,
PropertyAccessorHelper.getObject(obj, (Field) attribute.getJavaMember()));
}
count++;
}
}
else
{
// Updation
// Check whether this object is already in cache,
// which
// means we already have a column family with that
// name
// Otherwise we need to generate a fresh column
// family
// name
int lastEmbeddedObjectCount = ecCacheHandler.getLastElementCollectionObjectCount(rowId);
for (Object obj : (Collection) columnFamilyObject)
{
String embeddableColumFamilyName = columFamilyTableName;
dynamicCFName = ecCacheHandler.getElementCollectionObjectName(rowId, obj);
if (dynamicCFName == null)
{ // Fresh row
++lastEmbeddedObjectCount;
Map<Map<String, Class<?>>, HBaseDataWrapper> embeDaableDataWrappers = new HashMap<Map<String, Class<?>>, HBaseDataWrapper>();
for (Attribute attribute : columns)
{
embeddableColumFamilyName = ((AbstractAttribute) attribute).getTableName() != null ? ((AbstractAttribute) attribute)
.getTableName() : columFamilyTableName;
String columnName = columnFamilyName + Constants.EMBEDDED_COLUMN_NAME_DELIMITER
+ ((AbstractAttribute) attribute).getJPAColumnName()
+ Constants.EMBEDDED_COLUMN_NAME_DELIMITER + (lastEmbeddedObjectCount);
Map<String, Class<?>> embeddableMap = new HashMap<String, Class<?>>();
embeddableMap.put(embeddableColumFamilyName, obj.getClass());
embeDaableDataWrappers = getEmbeddableHBaseWrapperObj(rowId, obj,
embeddableColumFamilyName, embeDaableDataWrappers, persistentData,
embeddableMap);
HBaseDataWrapper embeddableColumnWrapper = embeDaableDataWrappers
.get(embeddableMap);
embeddableColumnWrapper.setColumnFamily(embeddableColumFamilyName);
embeddableColumnWrapper.addColumn(columnName, attribute);
embeddableColumnWrapper.addValue(columnName, PropertyAccessorHelper.getObject(
obj, (Field) attribute.getJavaMember()));
}
}
}
// Clear embedded collection cache for GC
ecCacheHandler.clearCache();
}
}
else
{