valchkou / cassandra-driver-mapping

JPA addon for DataStax Java Driver for Cassandra
57 stars 24 forks source link

Alter table on an entity field fails when changed from "list<text>" to map<text,text> #61

Closed ChandanNM closed 8 years ago

ChandanNM commented 9 years ago

Below block of code in SchemaSync class fails when a field of type list in an entity is changed to map datatype : map<text,text>

public static synchronized void sync(String keyspace, Session session, Class<?> clazz, SyncOptions syncOptions) {

    EntityTypeMetadata entityMetadata = EntityTypeParser.getEntityMetadata(clazz);
    if (entityMetadata.isSynced(keyspace)) return;

    List<RegularStatement> statements = buildSyncStatements(keyspace, session, entityMetadata, syncOptions);

    for (RegularStatement stmt: statements) {
        session.execute(stmt);
    }

    entityMetadata.markSynced(keyspace);
}

Error :

com.datastax.driver.core.exceptions.InvalidQueryException: Unknown type .map at com.datastax.driver.core.exceptions.InvalidQueryException.copy(InvalidQueryException.java:35) at com.datastax.driver.core.DefaultResultSetFuture.extractCauseFromExecutionException(DefaultResultSetFuture.java:291) at com.datastax.driver.core.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:205) at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:52) at com.datastax.driver.mapping.schemasync.SchemaSync.sync(SchemaSync.java:51)

ChandanNM commented 8 years ago

This seems to be cassandra limitation