问题标签 [spring-data-cassandra]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
337 浏览

spring-data-cassandra - 为什么 CqlTemplate 的 ExceptionTranslator 为空(CqlOperations 的 impl 类)?

我有一个带有注释的类@Repository,我将其用作 cassandra 的 dao。它是自动装配的CassandraOperations

当我使用该字段进行查询时,有时我会收到一个 Datastax ReadTimeOutException,它是一个 RuntimeException。当 CqlTemplate.java(用于的 spring impl 类CassandraOperations)尝试调用translateExceptionIfPossible它时,会使用一个名为 的字段exceptionTranslator,该字段不是由 spring 注入器设置的。这会导致抛出空指针异常,而不是 ReadTimeOutException。为什么这个字段没有正确设置?

它不能是我需要设置的东西,因为 set 方法仅在 impl 类上,而不在层次结构中的任何接口上。

0 投票
1 回答
840 浏览

java - spring cassandra connect 和 session 创建会抛出异常吗?

我正在寻找除 nullPointerException 和 noHostAvailableException 以外的异常?

0 投票
5 回答
9806 浏览

java - 如何使用 Spring Data cassandara 创建表?

我已经像这样创建了自己的存储库:

那么问题是如何为此自动创建 cassandra 表?目前 Spring 注入MyRepository尝试将实体插入到不存在的表中。

那么有没有办法在 spring 容器启动期间创建 cassandra 表(如果它们不存在)?

PS如果只有配置布尔属性而不添加xml行并创建像BeanFactory等这样的东西,那就太好了。:-)

0 投票
2 回答
7601 浏览

cassandra - Spring data Cassandra 2.0 Select BLOB column返回不正确的ByteBuffer数据

上下文:Spring data cassandra official 1.0.2.RELEASE from Maven Central repo, CQL3, cassandra 2.0, datastax driver 2.0.4

背景:cassandra blob 数据类型映射到 Java ByteBuffer。

下面的示例代码演示了在等效插入旁边使用 select 不会检索正确的字节。实际检索到的数据以大量垃圾字节为前缀,实际上看起来像是整行的序列化。这篇与 Cassandra 1.2 相关的较早帖子建议我们可能必须从长度为 ByteBuffer.remaining() 的 ByteBuffer.arrayOffset() 开始,但 arrayOffset 的值实际上是 0。

我发现了一个 spring-data-cassandra 2.0.0。SNAPSHOT 但 CassandraOperations API 有很大不同,它的包名也是:org.springdata... 与 org.springframework...

帮助解决这个问题将非常受欢迎。

同时,看起来我必须将 Base64 二进制数据编码/解码到文本数据类型列。

--- 这是我使用的简单表 CQL 元数据 -------------

--- 遵循映射到 CQL 表的简单数据对象 ---

--- 以及简单地插入和检索人员对象的普通 java 应用程序代码 --

--- 假设您已经为 cassandra 配置了一个简单的 Spring 项目,如http://projects.spring.io/spring-data-cassandra/中所述

实际执行产生:

[main] INFO org.spring.cassandra.example.CassandraApp - 我们尝试 id=1234567890, name=mickey, age=50, pict= 0001020304051122334455AACCFF

[main] INFO org.spring.cassandra.example.CassandraApp - We got id=1234567890, name=mickey, age=50, pict=8200000800000073000000020000000100000004000A6D796B657973706163650006706572736F6E00026964000D00046E616D65000D000361676500090004706963740003000000010000000A31323334353637383930000000066D69636B657900000004000000320000000E 0001020304051122334455AACCFF

尽管插入在数据库本身中看起来是正确的,但从 cqlsh 命令行可以看出:

0 投票
1 回答
733 浏览

java - 如何将异步版本 SimpleCassandraRepository 添加到 spring data cassanbdra?

Spring data cassandra项目具有用于解析 cassandra 存储库的 org.springframework.data.cassandra.repository.support.SimpleCassandraRepository 类。

我想要的是:

  1. 为示例创建“通用”接口,但使用异步方法AsyncCassandraRepositoryorg.springframework.data.cassandra.repository.TypedIdCassandraRepository
  2. 为该接口创建实现——如 org.springframework.data.cassandra.repository.support.SimpleCassandraRepository,但使用异步方法。
  3. 然后为其他域实体创建新的异步存储库,只是从异步接口扩展,例如CustomerRepository extends AsyncCassandraRepository。所以不需要新的实现。

所以这个想法是创建新的异步接口和实现并在任何地方使用它。SimpleCassandraRepository iteft 非常简单,所以创建新的异步版本没有问题。

真正的问题是将新的异步接口和实现“注册”到 Spring Data cassandra 深度中。我怎样才能做到这一点?

0 投票
1 回答
811 浏览

cassandra - Spring Cassandra 与 Astyanax 的性能对比

我正在尝试评估 Astyanax 和 Spring Cassandra 的性能。但是我确实编写了一个程序来测量插入和读取时间。事实证明,对于大数据,Astyanax 的插入速度比 Spring Cassandra 快 600 倍。我相信 Spring Cassandra 使用 datastax 驱动程序与 Cassandra 通信,尽管 Astyanax 使用节俭。任何对 Cassandra 客户端 API 有很多了解的人都可以给我更多关于他们的性能分析的信息吗?我的分析中有什么问题吗?

0 投票
1 回答
1786 浏览

spring-data - Spring Data Cassandra - 环境不能为空错误

我正在关注 Spring Data Cassandra 参考http://docs.spring.io/spring-data/cassandra/docs/1.1.0.RC1/reference/html/上的基本教程,我遇到了以下异常

我已经完成了文件中提到的步骤,

1) 使用 Cassandra 属性

2)创建Java配置

3) 创建域和存储库类

我在测试类中有自动装配的环境变量。我检查了几个示例项目,不确定还需要做什么。

0 投票
6 回答
7467 浏览

java - Multiple keyspace support for spring-data-cassandra repositories?

Does Spring Data Cassandra support multiple keyspace repositories in the same application context? I am setting up the cassandra spring data configuration using the following JavaConfig class

I tried creating a second configuration class after moving the repository classes to a different package.

However in that case the first set if repositories fail as the configured column family for the entities is not found in the keyspace. I think it is probably looking for the column family in the second keyspace.

Does spring-data-cassandra support multiple keyspace repositories? The only place where I found a reference for multiple keyspaces was here. But it does not explain if this can be done with repositories?

0 投票
1 回答
224 浏览

spring-data - 为什么有两个spring-data-cassandra github项目?

我正在考虑在项目中使用 Spring Data Cassandra。

我在 Github 上看到了 spring-data-cassandra 的两个项目。

为什么?哪个是正式版?

https://github.com/spring-projects/spring-data-cassandra
这是从http://projects.spring.io/spring-data-cassandra/链接到的那个

https://github.com/SpringData/spring-data-cassandra
这只是官方版本的某人的fork吗?

0 投票
5 回答
45242 浏览

java - 如何关闭 Spring Boot 命令行应用程序

我正在使用 Spring Boot 构建一个命令行 java 应用程序以使其快速运行。

该应用程序加载不同类型的文件(例如 CSV)并将它们加载到 Cassandra 数据库中。它不使用任何 Web 组件,它不是 Web 应用程序。

我遇到的问题是在工作完成后停止应用程序。我正在使用带有 a 的 Spring CommandLineRunner 接口@Component来运行任务,如下所示,但是当工作完成时,应用程序并没有停止,它出于某种原因继续运行,我找不到停止它的方法。

更新:问题似乎是spring-cassandra,因为项目中没有其他内容。有谁知道为什么它让线程在后台运行以防止应用程序停止?

更新:通过更新到最新的 Spring Boot 版本,问题消失了。