通过spring-data-rest将数据插入cassandradb时的示例

时间:2018-11-20 13:57:14

标签: cassandra spring-data-jpa spring-data-rest

每当我尝试通过rest请求将数据插入cassandradb时,我都会得到以下证据

org.springframework.data.cassandra.core.mapping.UnsupportedCassandraOperationE
xception: Cassandra does not support associations

cassandraRepo.java

@RepositoryRestResource(collectionResourceRel = "datapool",path = "datapool")
public interface cassandraRepo extends CassandraRepository<Datapool, String> {

    List<Datapool> findByName(@Param("name") String name);
}

Datapool.java

@Table
public class Datapool {

    @Id
    private String id;

    private String name;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

依赖项

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-cassandra</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-rest</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

请求

curl -i -X POST -H“ Content-Type:application / json” -d'{“ id”:“ drei”,“ name”:“ darn”}'http://localhost:8080/datapool/

奇怪的是,它仍在将数据插入表中。 但是,我想说明导致该原因的原因。

0 个答案:

没有答案