// If partition key part age given in query, i.e. restriction on
// id.compositekey.compositePartitionkey.partitionkeyColumn.
if (fieldName.indexOf(".") > 0)
{
String compositePartitionkeyName = fieldName.substring(0, fieldName.indexOf("."));
AbstractAttribute attribute = (AbstractAttribute) keyObj.getAttribute(compositePartitionkeyName);
fieldName = fieldName.substring(fieldName.indexOf(".") + 1);
EmbeddableType compositePartitionkey = metamodel.embeddable(attribute.getBindableJavaType());
attribute = (AbstractAttribute) compositePartitionkey.getAttribute(fieldName);
String columnName = attribute.getJPAColumnName();
isPresent = buildWhereClause(builder, isPresent, translator, condition, value, useInClause, attribute,
columnName, false);
}
// if composite partition key object is given in query, i.e. restriction
// on id.compositekey.compositePartitionkey
else if (metamodel.isEmbeddable(((AbstractAttribute) keyObj.getAttribute(fieldName)).getBindableJavaType()))
{
AbstractAttribute attribute = (AbstractAttribute) keyObj.getAttribute(fieldName);
Set<Attribute> attributes = metamodel.embeddable(attribute.getBindableJavaType()).getAttributes();
if (!useInClause)
{
// Iterating and appending each column of composite partition
// key in query builder.
for (Attribute nestedAttribute : attributes)
{
String columnName = ((AbstractAttribute) nestedAttribute).getJPAColumnName();
Object valueObject = PropertyAccessorHelper.getObject(value.isEmpty() ? null : value.get(0),
(Field) nestedAttribute.getJavaMember());
translator.buildWhereClause(builder, nestedAttribute.getJavaType(), columnName, valueObject,
condition, false);
}
}
else
{
throw new IllegalArgumentException("In clause is not supported on first part of partition key.");
}
isPresent = true;
}
// if Not a composite partition key,
// id.compositekey.partitionkey/clusterKey.
else
{
AbstractAttribute attribute = (AbstractAttribute) keyObj.getAttribute(fieldName);
String columnName = attribute.getJPAColumnName();
isPresent = buildWhereClause(builder, isPresent, translator, condition, value, useInClause, attribute,
columnName, false);
}
return isPresent;
}