I have a table with an ID field so defined:
create table XXX (
id uuid primary key,
name varchar,
....
and my class XXX is so annotated:
public class XXX {
@PrimaryKey
@Persistent(customValueStrategy = "uuid")
public UUID id;
...
When trying to issue a PersistenceManager.makePersistent(), I get:
Exception in thread "main" javax.jdo.JDOFatalInternalException: Invalid Id generated for field XXX.id, id : 54e5abde-732b-42ff-af92-06af89af46ff at org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:673) at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:720) at org.datanucleus.api.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:740) at Importer.save(StayImporter.java:84) at Importer.exec(StayImporter.java:102) at Importer.main(Importer.java:110) 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) NestedThrowablesStackTrace: Invalid Id generated for field XXX.id, id : 54e5abde-732b-42ff-af92-06af89af46ff org.datanucleus.exceptions.NucleusException: Invalid Id generated for field XXX.id, id : 54e5abde-732b-42ff-af92-06af89af46ff at org.datanucleus.store.AbstractStoreManager.getStrategyValue(AbstractStoreManager.java:1300) at org.datanucleus.state.StateManagerImpl.populateStrategyFields(StateManagerImpl.java:2201) at org.datanucleus.state.StateManagerImpl.initialiseForPersistentNew(StateManagerImpl.java:418) at org.datanucleus.state.StateManagerImpl.initialiseForPersistentNew(StateManagerImpl.java:120) at org.datanucleus.state.ObjectProviderFactoryImpl.newForPersistentNew(ObjectProviderFactoryImpl.java:218) at org.datanucleus.ExecutionContextImpl.persistObjectInternal(ExecutionContextImpl.java:2078) at org.datanucleus.ExecutionContextImpl.persistObjectWork(ExecutionContextImpl.java:1922) at org.datanucleus.ExecutionContextImpl.persistObject(ExecutionContextImpl.java:1777) at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:715) at org.datanucleus.api.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:740)
The UUID looks good to me, why does it not work?
Maven is:
<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>
Cassandra version is 2.2.3