无法使用 Kundera 在 Cassandra 中插入 timeuuid
Cannot insert timeuuid in Cassandra with Kundera
我有这个 Cassandra table:
CREATE TABLE xxx ( id timeuuid PRIMARY KEY);
和这个 class:
@Entity
@Table(name = "xxx", schema = "yyy")
public class XXX {
@Id
@GeneratedValue
public UUID id;
}
坚持后,我得到:
Exception in thread "main" com.impetus.kundera.KunderaException: java.lang.IllegalArgumentException: GenerationType.AUTO Strategy not supported by this client :com.impetus.client.cassandra.pelops.PelopsClient
at com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:174)
at Importer.save(StayImporter.java:80)
at Importer.exec(StayImporter.java:92)
at Importer.main(StayImporter.java:100)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.lang.IllegalArgumentException: GenerationType.AUTO Strategy not supported by this client :com.impetus.client.cassandra.pelops.PelopsClient
at com.impetus.kundera.persistence.IdGenerator.onAutoGenerator(IdGenerator.java:116)
at com.impetus.kundera.persistence.IdGenerator.generateAndSetId(IdGenerator.java:71)
at com.impetus.kundera.graph.ObjectGraphBuilder.getNode(ObjectGraphBuilder.java:111)
at com.impetus.kundera.graph.ObjectGraphBuilder.getObjectGraph(ObjectGraphBuilder.java:75)
at com.impetus.kundera.persistence.PersistenceDelegator.persist(PersistenceDelegator.java:135)
at com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:168)
... 8 more
这是我的 pom.xml:
<repositories>
<repository>
<id>sonatype-nexus</id>
<name>Kundera Public Repository</name>
<url>https://oss.sonatype.org/content/repositories/releases</url>
</repository>
</repositories>
<dependency>
<groupId>com.impetus.client</groupId>
<artifactId>kundera-cassandra</artifactId>
<version>2.9</version>
</dependency>
来自日志:
GenerationType.AUTO Strategy not supported by this client com.impetus.client.cassandra.pelops.PelopsClient
我建议你使用 Thrift 客户端。您可以通过将 persistence.xml
中的 kundera.client.lookup.class
属性 更改为以下内容来执行此操作:
<property name="kundera.client.lookup.class" value="com.impetus.client.cassandra.thrift.ThriftClientFactory" />
此外,我建议您使用latest version of Kundera-Cassandra。
我有这个 Cassandra table:
CREATE TABLE xxx ( id timeuuid PRIMARY KEY);
和这个 class:
@Entity
@Table(name = "xxx", schema = "yyy")
public class XXX {
@Id
@GeneratedValue
public UUID id;
}
坚持后,我得到:
Exception in thread "main" com.impetus.kundera.KunderaException: java.lang.IllegalArgumentException: GenerationType.AUTO Strategy not supported by this client :com.impetus.client.cassandra.pelops.PelopsClient at com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:174) at Importer.save(StayImporter.java:80) at Importer.exec(StayImporter.java:92) at Importer.main(StayImporter.java:100) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) Caused by: java.lang.IllegalArgumentException: GenerationType.AUTO Strategy not supported by this client :com.impetus.client.cassandra.pelops.PelopsClient at com.impetus.kundera.persistence.IdGenerator.onAutoGenerator(IdGenerator.java:116) at com.impetus.kundera.persistence.IdGenerator.generateAndSetId(IdGenerator.java:71) at com.impetus.kundera.graph.ObjectGraphBuilder.getNode(ObjectGraphBuilder.java:111) at com.impetus.kundera.graph.ObjectGraphBuilder.getObjectGraph(ObjectGraphBuilder.java:75) at com.impetus.kundera.persistence.PersistenceDelegator.persist(PersistenceDelegator.java:135) at com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:168) ... 8 more
这是我的 pom.xml:
<repositories>
<repository>
<id>sonatype-nexus</id>
<name>Kundera Public Repository</name>
<url>https://oss.sonatype.org/content/repositories/releases</url>
</repository>
</repositories>
<dependency>
<groupId>com.impetus.client</groupId>
<artifactId>kundera-cassandra</artifactId>
<version>2.9</version>
</dependency>
来自日志:
GenerationType.AUTO Strategy not supported by this client com.impetus.client.cassandra.pelops.PelopsClient
我建议你使用 Thrift 客户端。您可以通过将 persistence.xml
中的 kundera.client.lookup.class
属性 更改为以下内容来执行此操作:
<property name="kundera.client.lookup.class" value="com.impetus.client.cassandra.thrift.ThriftClientFactory" />
此外,我建议您使用latest version of Kundera-Cassandra。