I am using Spring data Cassandra, to connect with Cassandra database, with configuration file extending AbstractCassandraConfiguration and overriding functions -
@Override
public SchemaAction getSchemaAction() {
return SchemaAction.RECREATE_DROP_UNUSED;
}
@Override
public String[] getEntityBasePackages() {
return new String[] {"com.example"};
}
My aim is to create tables automatically in Cassandra from the mentioned entities in com.example package with @Table annotation. For example -
package com.example;
import org.springframework.data.cassandra.mapping.PrimaryKey;
import org.springframework.data.cassandra.mapping.Table;
@Table(value="goal")
public class Goal {
@PrimaryKey
private int id;
private String description;
public Goal(int id, String description) {
this.id = id;
this.description = description;
}
public Goal() {
}
public int getId() {
return id;
}
public String getDescription() {
return description;
}
public void setId(int id) {
this.id = id;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public String toString() {
return "Goals [id=" + id + ", description=" + description + "]";
}
}
For this entity, with the given configuration, one table should get created during spring initialization, But it fails to do so. No exception though, It just doesn't create anything in Cassandra. Any help would be appreciated. Thanks.