Example usage for javax.persistence.metamodel EmbeddableType getAttribute

List of usage examples for javax.persistence.metamodel EmbeddableType getAttribute

Introduction

In this page you can find the example usage for javax.persistence.metamodel EmbeddableType getAttribute.

Prototype

Attribute<? super X, ?> getAttribute(String name);

Source Link

Document

Return the attribute of the managed type that corresponds to the specified name.

Usage

From source file:com.impetus.client.cassandra.schemamanager.CassandraSchemaManager.java

/**
 * Append primary key./*from   w ww.j a v  a 2 s .c  o m*/
 * 
 * @param translator
 *            the translator
 * @param compoEmbeddableType
 *            the compo embeddable type
 * @param fields
 *            the fields
 * @param queryBuilder
 *            the query builder
 */
private void appendPrimaryKey(CQLTranslator translator, EmbeddableType compoEmbeddableType, Field[] fields,
        StringBuilder queryBuilder) {
    for (Field f : fields) {
        if (!ReflectUtils.isTransientOrStatic(f)) {
            if (f.getType().isAnnotationPresent(Embeddable.class)) { // compound partition key
                MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata()
                        .getMetamodel(puMetadata.getPersistenceUnitName());
                queryBuilder.append(translator.OPEN_BRACKET);
                queryBuilder.append(translator.SPACE_STRING);
                appendPrimaryKey(translator, (EmbeddableType) metaModel.embeddable(f.getType()),
                        f.getType().getDeclaredFields(), queryBuilder);
                queryBuilder.deleteCharAt(queryBuilder.length() - 1);
                queryBuilder.append(translator.CLOSE_BRACKET);
                queryBuilder.append(Constants.SPACE_COMMA);

            } else {
                Attribute attribute = compoEmbeddableType.getAttribute(f.getName());
                translator.appendColumnName(queryBuilder, ((AbstractAttribute) attribute).getJPAColumnName());
                queryBuilder.append(Constants.SPACE_COMMA);
            }
        }
    }
}