Reputation: 512
I have started developing a spring boot data cassandra application. I am configuring in a SpringConfigurationClass with Cassandra. When I start the app, it throws SyntaxError and CassandraQuerySyntaxException. While starting, creating a cql for a table that is Account Entity. It has a timestamp field that is "private Date createdAt".
Normally, timestamp has a "i" character but cql has "ı" so it try to run a cql has "tımestamp".
Caused by: org.springframework.data.cassandra.CassandraQuerySyntaxException:
Query; CQL [CREATE TABLE IF NOT EXISTS accounts (created_at tımestamp, email text, id text,
is_active boolean, passwd text, uname text, PRIMARY KEY (id));];
line 1:49 no viable alternative at character 'ı'; nested exception is
com.datastax.oss.driver.api.core.servererrors.SyntaxError:
line 1:49 no viable alternative at character 'ı'
How Can I solve this problem and proceed?
My Configuration Class:
@Configuration
@EnableCassandraRepositories
public class CassandraConfiguration extends AbstractCassandraConfiguration {
@Value("${accountservice.cassandra.keyspace.name}")
private String keyspaceName;
@Value("${accountservice.cassandra.port}")
private int port;
@Value("${accountservice.cassandra.contact.point}")
private String contactPoint;
@Value("${accountservice.cassandra.uname}")
private String uname;
@Value("${accountservice.cassandra.passwd}")
private String passwd;
@Override
protected String getKeyspaceName() {
return keyspaceName;
}
public String getPasswd() {
return passwd;
}
public String getUname() {
return uname;
}
@Override
protected String getContactPoints() {
return contactPoint;
}
@Override
protected int getPort() {
return port;
}
@Override
public String[] getEntityBasePackages() {
return new String[] {"com.trius.accountservice"};
}
@Override
public SchemaAction getSchemaAction() {
return SchemaAction.CREATE_IF_NOT_EXISTS;
}
@Override
public CqlSessionFactoryBean cassandraSession() {
CqlSessionFactoryBean cqlSessionFactoryBean = super.cassandraSession();
cqlSessionFactoryBean.setPassword(getPasswd());
cqlSessionFactoryBean.setUsername(getUname());
return cqlSessionFactoryBean;
}
}
My Table:
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(of = {"id"})
@ToString
@Table(value = "accounts")
public class Account implements Serializable {
@PrimaryKey
private String id = UUID.randomUUID().toString();
@Column(value="uname")
private String username;
@Column(value="email")
private String email;
@Column(value="passwd")
private String passwd;
@Column(value="is_active")
private Boolean active;
@Column(value="created_at")
private Date createdAt;
}
Upvotes: 1
Views: 306
Reputation: 16293
It looks like an extended or special character has been inadvertently included in the CQL statement.
If you've copied and pasted the schema definition on a Windows machine from a file such as a Word document, make sure you clean it up first. For example, you can paste the schema into Notepad and save it as a text file then use that file as your source. Cheers!
Upvotes: 1