@Override
  @SuppressWarnings({"rawtypes", "unchecked"})
  public Family createMappedForm(PersistentEntity entity) {
    ClassPropertyFetcher cpf = ClassPropertyFetcher.forClass(entity.getJavaClass());
    final Closure value = cpf.getStaticPropertyValue(GormProperties.MAPPING, Closure.class);
    if (value == null) {
      return new Region();
    }

    final Region family = new Region();
    AttributesFactory factory =
        new AttributesFactory() {
          @SuppressWarnings("unused")
          public void setRegion(String name) {
            family.setRegion(name);
          }
        };
    factory.setDataPolicy(defaultDataPolicy);

    MappingConfigurationBuilder builder = new MappingConfigurationBuilder(factory, KeyValue.class);
    builder.evaluate(value);
    entityToPropertyMap.put(entity, builder.getProperties());
    final RegionAttributes regionAttributes = factory.create();
    family.setRegionAttributes(regionAttributes);
    family.setCacheListeners(regionAttributes.getCacheListeners());
    family.setDataPolicy(regionAttributes.getDataPolicy());
    family.setCacheLoader(regionAttributes.getCacheLoader());
    family.setCacheWriter(regionAttributes.getCacheWriter());

    builder = new MappingConfigurationBuilder(family, KeyValue.class);
    builder.evaluate(value);
    return family;
  }
  @SuppressWarnings("unchecked")
  @Override
  public Table createMappedForm(PersistentEntity entity) {
    Table table = super.createMappedForm(entity);
    CassandraPersistentEntity cassandraPersistentEntity = (CassandraPersistentEntity) entity;
    // read tableOptions
    ClassPropertyFetcher cpf = ClassPropertyFetcher.forClass(entity.getJavaClass());
    final Closure value = cpf.getStaticPropertyValue(TABLE_PROPERTIES, Closure.class);
    if (value != null) {
      MapConfigurationBuilder builder = new MapConfigurationBuilder();
      try {
        builder.evaluate(value);
      } catch (Exception e) {
        throw new IllegalMappingException(
            String.format("Error reading %s : %s", TABLE_PROPERTIES, e.toString()));
      }
      table.setTableProperties(builder.getProperties());
    }

    if (table.getKeyspace() == null) {
      table.setKeyspace(keyspace);
    }

    // additional static mapping block handling
    Map<String, Column> properties = entityToPropertyMap.get(entity);
    Object version = properties.get(MappingConfigurationBuilder.VERSION_KEY);
    if (version instanceof Boolean) {
      cassandraPersistentEntity.setVersion((Boolean) version);
    }

    Column idProperty = properties.get(IDENTITY_PROPERTY);
    Iterator<Entry<String, Column>> propertyIterator = properties.entrySet().iterator();

    while (propertyIterator.hasNext()) {
      Entry<String, Column> entry = propertyIterator.next();
      if (entry.getValue() instanceof Column) {
        String name = entry.getKey();
        Column column = entry.getValue();
        if (idProperty != null
            && idProperty.getName() != null
            && idProperty.getName().equals(name)) {
          // remove extra column created if id property in constraints block, as it conflicts with
          // the column created in mapping block.
          // constraints will be handled elsewhere in GORM
          propertyIterator.remove();
          continue;
        }

        if (column.getName() == null) {
          column.setName(name);
        }
        table.addColumn(column);
      }
    }

    return table;
  }