2017-04-21 8 views
0

Cassandraデータベースを使用しているスプリングブートデータに関連するヘルプを探しています。
私のpom.xmlに次の依存関係があります。springbootデータを使用してcassandraにユーザーデータ型をマッピングする方法

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

     <dependency> 
      <groupId>com.datastax.cassandra</groupId> 
      <artifactId>cassandra-driver-core</artifactId> 
      <version>2.1.10.3</version> 
     </dependency> 
     <dependency> 
      <groupId>com.datastax.cassandra</groupId> 
      <artifactId>cassandra-driver-mapping</artifactId> 
      <version>2.1.10.3</version> 
     </dependency> 

The table structure looks like: 

@Table(value = "TEST_ORDERS") 
public class OrderDTO { 

    @PrimaryKey 
    @Column(value = "email") 
    private String emailId; 

    @Column(value = "order_id") 
    private int orderId; 

    @Column(value = "creation_date") 
    private Timestamp creationDate; 

    @Column(value = "discount_total") 
    private double discountTotal; 

    @Column(name = "shipments") 
    //This is a UDT type 
    private Set<ShippingDetails> shipments; 

    //getters and setters here 
} 

The ShippingDetails object is a UDT with following declartion and i defined as a frozen collection in the cassandra CQL sripts 

@UDT(name = "shipping", keyspace = "mc_checkout") 
public class ShippingDetails { 

    @Field(name = "name") 
    private FullName name; 

    @Field(name = "quantity_shipped") 
    private int quantityShipped; 

    @Field(name = "shipping_address") 
    private CheckoutAddress shippingAddress; 
    //so on 
} 

There is a repository created for the basic CRUD operations: 
@Repository 
public interface OrderRepository extends CrudRepository<OrderDTO, String> { 

} 

    When i try to invoke findOne API of this repository in my Service class 

私はエラーの下に取得:ApacheのカサンドラとDatastax」マッピングの カサンドラ実体は@Table、@Persistentまたは@PrimaryKeyClass注釈を持っている必要があります

答えて

1

春データは、同じことを達成しようとする二つの独立したツールです。どちらか一方を使用してくださいが、これらを混ぜないでください。

CrudRepositoryはSpringデータタイプで、@Fieldおよび@UDTはDatastaxマッピングからのものです。

Apache Cassandra用のSpringデータのUDTサポートは、バージョン1.5から利用できます。reference docsを参照してください。 Apache Cassandra 1.5のSpringデータには、Datastax Java Driver 3.0以降が必要です。

関連する問題