protected void createTables(boolean dropTables, boolean dropUnused) { for (TableMetadata table : session.getCluster().getMetadata().getKeyspace(keyspaceName).getTables()) { if (dropTables) { if (dropUnused || mappingContext.usesTable(table)) { admin.dropTable(table.getName()); } } } Collection<? extends CassandraPersistentEntity<?>> entities = converter.getMappingContext().getPersistentEntities(); for (CassandraPersistentEntity<?> entity : entities) { admin.createTable(false, entity.getTableName(), entity.getType(), null /* TODO */); } }
@Override public CassandraPersistentProperty createPersistentProperty( Field field, PropertyDescriptor descriptor, CassandraPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) { PersistentEntity gormEntity = gormCassandraMappingContext.getPersistentEntity(owner.getName()); final CassandraPersistentProperty property = super.createPersistentProperty(field, descriptor, owner, simpleTypeHolder); final CassandraPersistentProperty transientProperty = new BasicCassandraPersistentProperty( field, descriptor, owner, (CassandraSimpleTypeHolder) simpleTypeHolder) { public boolean isTransient() { return true; } }; if (field == null && !property.usePropertyAccess()) { return transientProperty; } if (field != null && Modifier.isTransient(field.getModifiers())) { return transientProperty; } if (field != null && grails.core.GrailsDomainClassProperty.ERRORS.equals(field.getName())) { return transientProperty; } if (field != null && field.getType().equals(Errors.class)) { return transientProperty; } if (field != null && (field.getName().contains(INTERNAL_MARKER) || field.getName().startsWith(INTERNAL_GRAILS_FIELD_MARKER))) { return transientProperty; } if (descriptor != null && descriptor.getWriteMethod() == null && descriptor.getReadMethod() == null) { return transientProperty; } Class<?> rawType = field != null ? field.getType() : descriptor != null ? descriptor.getPropertyType() : null; if (rawType == null) { return transientProperty; } if (rawType.isEnum()) { // persist as a string return new BasicCassandraPersistentProperty( field, descriptor, owner, (CassandraSimpleTypeHolder) simpleTypeHolder) { public com.datastax.driver.core.DataType getDataType() { return CassandraSimpleTypeHolder.getDataTypeFor(String.class); }; public java.lang.Class<?> getType() { return String.class; }; public boolean usePropertyAccess() { return true; }; }; } else if (URL.class.isAssignableFrom(rawType) || TimeZone.class.isAssignableFrom(rawType) || Locale.class.isAssignableFrom(rawType) || Currency.class.isAssignableFrom(rawType) || Calendar.class.isAssignableFrom(rawType)) { // persist as a string return new BasicCassandraPersistentProperty( field, descriptor, owner, (CassandraSimpleTypeHolder) simpleTypeHolder) { public com.datastax.driver.core.DataType getDataType() { return CassandraSimpleTypeHolder.getDataTypeFor(String.class); }; public java.lang.Class<?> getType() { return String.class; }; public boolean isEntity() { return false; }; public boolean usePropertyAccess() { return true; }; }; } else if (field != null && GrailsDomainClassProperty.VERSION.equals(field.getName()) && !gormEntity.isVersioned()) { return transientProperty; } // for collections or maps of non-primitive types, i.e associations, // return transient property as spring data cassandra doesn't support if (!property.isTransient()) { if (property.isMap() || property.isCollectionLike()) { try { property.getDataType(); } catch (InvalidDataAccessApiUsageException e) { return transientProperty; } } } return property; }