2015-09-02 67 views
1

我能夠通過重寫功能春數據卡桑德拉支持模式同步的列家庭

@Override 
public SchemaAction getSchemaAction() { 
    return SchemaAction.RECREATE_DROP_UNUSED; 
} 

@Override 
public String[] getEntityBasePackages() { 
    return new String[] {"com.example"}; //com.example package contains the bean with @table annotation 
} 

使用Spring數據卡桑德拉延伸AbstractCassandraConfiguration配置文件來創建表,但它首先丟棄在密鑰空間中的所有表創建表然後創建表格。在這個過程中,我失去了我現有的數據。我希望實現類似SchemaSync的操作:https://github.com/valchkou/cassandra-driver-mapping/blob/master/src/main/java/com/datastax/driver/mapping/schemasync/SchemaSync.java

因此,無論何時在添加新列時我的列族架構發生更改,表都會更新爲新列,而不會刪除表中的現有條目。

回答

1

這是SchemaAction枚舉包含可用選項的當前狀態:

public enum SchemaAction { 

    /** 
    * Take no schema actions. 
    */ 
    NONE, 

    /** 
    * Create each table as necessary. Fail if a table already exists. 
    */ 
    CREATE, 

    /** 
    * Create each table as necessary, dropping the table first if it exists. 
    */ 
    RECREATE, 

    /** 
    * Drop <em>all</em> tables in the keyspace, then create each table as necessary. 
    */ 
    RECREATE_DROP_UNUSED; 

    // TODO: 
    // /** 
    // * Validate that each required table and column exists. Fail if any required table or column does not exists. 
    // */ 
    // VALIDATE, 
    // 
    // /** 
    // * Alter or create each table and column as necessary, leaving unused tables and columns untouched. 
    // */ 
    // UPDATE, 
    // 
    // /** 
    // * Alter or create each table and column as necessary, removing unused tables and columns. 
    // */ 
    // UPDATE_DROP_UNUNSED; 
} 

正如你所看到的,你問功能仍然沒有實現。如果你覺得它很重要,也許你可以把它貢獻給這個項目。