String joinColumnName = joinTableData.getJoinColumnName();
String invJoinColumnName = joinTableData.getInverseJoinColumnName();
Map<Key, List<TableOperation>> operations = new HashMap<Key, List<TableOperation>>();
// String schema = joinTableData.getSchemaName();
Table schemaTable = tableAPI.getTable(joinTableName);
Row row = schemaTable.createRow();
String primaryKey = joinColumnName + SEPERATOR + invJoinColumnName;
KunderaCoreUtils.printQuery("Persist Join Table:" + joinTableName, showQuery);
Map<Object, Set<Object>> joinTableRecords = joinTableData.getJoinTableRecords();
try
{
for (Object pk : joinTableRecords.keySet())
{
// here pk is join column name and it's values would become
// inverse join columns
NoSqlDBUtils.add(schemaTable.getField(joinColumnName), row, pk, joinColumnName);
Set<Object> values = joinTableRecords.get(pk);
for (Object childId : values)
{
// what if join or inverse join column is null? Not handling
// as ideally it should be handled in core itself!
NoSqlDBUtils.add(schemaTable.getField(invJoinColumnName), row, childId, invJoinColumnName);
NoSqlDBUtils.add(schemaTable.getField(primaryKey), row,
pk.toString() + SEPERATOR + childId.toString(), primaryKey);
addOps(operations, schemaTable, row);
}
}