我有這麼定義的ID字段的表:不能堅持到卡桑德拉與DataNucleus將UUID的
create table XXX (
id uuid primary key,
name varchar,
....
和我班的XXX是這樣註解:
public class XXX {
@PrimaryKey
@Persistent(customValueStrategy = "uuid")
public UUID id;
...
當試圖發出一個PersistenceManager我得到:
線程「main」中的異常javax.jdo.JDOFatalInternalException:字段XXX.id生成的ID無效,id: 54e5abde-732B-42FF-af92-06af89af46ff 在org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:673) 在org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:720) at Importer.main(StayImporter.java:84) at Importer.exec(StayImporter.java:102) at Importer.main(Importer的.java:110) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本機方法) 在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在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) NestedThrowablesStackTrace: 爲字段XXX生成的ID無效.id,id:54e5abde-732b-42ff-af92-06af89af46ff org.datanucleus.exceptions.NucleusException:爲字段XXX.id生成的ID無效,ID:54e5abde-732b-42ff-af92-06af89af46ff at org.datanucleus.store .AbstractStoreManager.getStrategyValue(AbstractStoreManager.java:1300) 在org.datanucleus.state.StateManagerImpl.populateStrategyFields(StateManagerImpl.java:2201) 在org.datanucleus.state.StateManagerImpl.initialiseForPersistentNew(StateManagerImpl.java:418) 在有機.datanucleus.state.StateManagerImpl.initialiseForPersistentNew(StateManage rImpl.java:120) 在org.datanucleus.state.ObjectProviderFactoryImpl.newForPersistentNew(ObjectProviderFactoryImpl.java:218) 在org.datanucleus.ExecutionContextImpl.persistObjectInternal(ExecutionContextImpl.java:2078) 在org.datanucleus.ExecutionContextImpl.persistObjectWork( ExecutionContextImpl.java:1922) 在org.datanucleus.ExecutionContextImpl.persistObject(ExecutionContextImpl.java:1777) 在org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:715) 在org.datanucleus.api。 jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:740)
UUID看起來不錯,爲什麼d它不起作用?
Maven是:
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-accessplatform-jdo-cassandra</artifactId>
<version>4.2.1</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>2.1.9</version>
</dependency>
卡桑德拉版本2.2.3
我以爲所有的發電機通常都是基於字符串或整數的。如果您將該字段設爲字符串會發生什麼?此外,這不是真正的例外...將嵌套 –
我已包括嵌套的異常 –
與字符串字段,我得到: org.datanucleus.exceptions.NucleusException:爲XXX.id生成無效Id,id:7aa194c8 -06d2-491f-9ccb-4e52db36dd0a –