I'm using Goole App Engine to Build my REST API, I've already marked my class as PersistenceCapable and also i got defined my @PrimaryKey and also marked as @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY), also i've already EndPoints generated. but when i type in the terminal window a curl command to insert a new entity or registry it doesn't work. this is the code:
@PersistenceCapable(identityType = IdentityType.APPLICATION)
class Student{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long id;
private String studentName;
....
....
....
}
this is the curl command and response from my local server. when i try to insert a new entity
curl -H 'Content-Type: application/json' -d'{"studentName": "myname"}' htto://localhost:8889/_ah/api/utp/v1/student
and this is the response from the local server.
"error" : {
"message" : "javax.jdo.JDOFatalInternalException: El valor de llave dado para construir una identidad de SingleFieldIdentity de tipo \"class javax.jdo.identity.LongIdentity\" para la clase \"class com.alex.wserver.Student\" es nulo.\nNestedThrowables:\norg.datanucleus.exceptions.NucleusException: El valor de llave dado para construir una identidad de SingleFieldIdentity de tipo \"class javax.jdo.identity.LongIdentity\" para la clase \"class com.alex.wserver.Student\" es nulo."
i've been thinking that id was automatically generated an inserted. but that isn't happening here. Unlike of insert an id together
- are my class wrong?
- are my POST/json request Ok?
Thanks in advance.