16 Şubat 2021 Salı

SpringData Cassandra

Maven
Örnek
Şu satırı dahil ederiz
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-data-cassandra</artifactId>
</dependency>
Örnek - reactive
Şu satırı dahil ederiz
<dependency>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-starter-data-cassandra-reactive</artifactId>
 <version>2.0.0.M7</version>
</dependency>
application.yml
Örnek
Şöyle yaparız
cassandra:
 personalization:
 cluster-name: personalization
 contact-points: 172.X.X.X, 172.X.X.Y
 keyspace-name: personalization
Birden Fazla Cassandra Keyspace Kullanmak
Burada bir örnek var

ReactiveCassandraRepository Arayüzü
Örnek 
Şöyle yaparız
@Repository
public interface UserPreferencesRepository extends
 ReactiveCassandraRepository<UserPreferences, UserId> {

  @Query(value = “SELECT * FROM user_preferences where user_id = ?0 limit ?1”)
  Flux<UserPreferences> findByUserId(int userId, int limit);

}

Hiç yorum yok:

Yorum Gönder