我有一个springboot应用程序,我和cassandra连接在一起。我试图创建一个Map内的Map,但得到以下例外。在我看来即使我用 @FrozenValue
,它仍在发送没有关键字的cal frozen
错误
Caused by: org.springframework.data.cassandra.CassandraInvalidQueryException: Query; CQL [CREATE TABLE IF NOT EXISTS assessmentsubmissionentity (studentid text, assessmentid text, values map<text, map<text, text>>, PRIMARY KEY ((studentid, assessmentid)));]; Non-frozen collections are not allowed inside collections: map<text, map<text, text>>; nested exception is com.datastax.driver.core.exceptions.InvalidQueryException: Non-frozen collections are not allowed inside collections: map<text, map<text, text>>
at org.springframework.data.cassandra.core.cql.CassandraExceptionTranslator.translate(CassandraExceptionTranslator.java:139) ~[spring-data-cassandra-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.data.cassandra.core.cql.CassandraAccessor.translate(CassandraAccessor.java:334) ~[spring-data-cassandra-2.1.2.RELEASE.jar:2.1.2.RELEASE]
Caused by: com.datastax.driver.core.exceptions.InvalidQueryException: Non-frozen collections are not allowed inside collections: map<text, map<text, text>>
at com.datastax.driver.core.exceptions.InvalidQueryException.copy(InvalidQueryException.java:49) ~[cassandra-driver-core-3.6.0.jar:na]
代码
@Table
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class AssessmentSubmissionEntity implements Serializable {
@PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED)
private String studentId;
@PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED)
private String assessmentId;
@FrozenValue
@Column
private Map <String, Map<String, String>> values;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AssessmentSubmissionEntity that = (AssessmentSubmissionEntity) o;
return Objects.equals(studentId, that.studentId) &&
Objects.equals(assessmentId, that.assessmentId) &&
Objects.equals(values, that.values);
}
@Override
public int hashCode() {
return Objects.hash(studentId, assessmentId, values);
}
}
Maven
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-cassandra</artifactId>
<exclusions>
<exclusion>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
</dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-mapping</artifactId>
</dependency>
1条答案
按热度按时间0h4hbjxa1#
cassandra的spring数据有一个问题——它们没有冻结集合的Map。见datacass-465在他们的jira-这是一年多前提出的,但没有任何进展。。。
我认为唯一的解决方案是使用datastax的java驱动程序中的对象Map器,或者通过cql管理表。