An error occurred while trying to write to the entity “claims” [id=d150a3cb-49c3

An error occurred while trying to write to the entity “claims” [id=d150a3cb-49c3-44e2-9f46-792e400dc0d8@3966, type=ClaimsClaim (id=2024)] (data store: ClaimsProcess). Details: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): ClaimsClaimDT1123 Data: TypedValue[it=2024,v={<null>,,<null>,,,,,,<null>,<null>,,<null>}] ...

OriginalPostID-80520

OriginalPostID-80520

  Discussion posts and replies are publicly visible

  • Hi,

    We are providing all the primary keys through the process. Still its giving this error.
  • Hi,
    I did face same issue while inserting the data in a table. Did you get remedy for this issue?
  • Hi rahulk,

    Could u please share your XSD if possible.


    Thanks,
    ravalik
  • Please check the primary key in the CDT and see if the auto-generate option is selected, else you will have to pass a value to the PK before writing records to a data store entity.
  • Hi,

    Please download your XSD and add JPA annotations appropriate to your requirement (add @GeneratedValue for your ID field), save it and then create a new version of the CDT from XSD. You will need to verify and publish your Data Store again in order to reflect these changes.

    Hope it helps!!
  • The comment from  helped me in my case. For some reason the "@GeneratedValue" wasn't added to the primary key field in the XSD by Appian, so I added this manually and the error was resolved. 

  • I got this same error. (Details: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save())

    I had wanted to create my first Appian WEB API.

    I created a Data Store Entity without an autogenerated ID field.  

    I created a Service Account and got an API key, put the Service account into the viewer group and gave it access to my DSE, per the docs (Creating Web APIs - Appian 21.3)

    My primary key(PK) field is unique, and called CNUMBER.

    I tried to use the first example example in the

    a!writeToDataStoreEntity(
      dataStoreEntity: cons!CES_POINTER_CHECKS_DATASTOREENTITY,
      valueToStore: type!Employee(
        CNUMBER: http!request.queryParameters.CNUMBER,
        CDATE: http!request.queryParameters.CDATE,
        CAMOUNT: http!request.queryParameters.CAMOUNT,
        CDESC: http!request.queryParameters.CDESC
      ),
      onSuccess: a!httpResponse(
        statusCode: 200,
        headers: {
          a!httpHeader(name: "Content-Type", value: "application/json")
        },
        body: a!toJson(
          fv!storedValues
        )
      ),
      onError: a!httpResponse(
        statusCode: 500,
        headers: {
          a!httpHeader(name: "Content-Type", value: "application/json")
        },
        body: a!toJson(
          {
            error: "There was an error writing to the data store"
          }
        )
      )
    )

    When I tested it in the WEB API node it worked perfectly and added or updated a record in my table.

    When I tried to access remotely, I got the error.

    I tried adding an auto generated id field, then the WEB API node failed and I still got the error. I would up fixing this by using the Web API Tutorial Level II example:  Web API Tutorial - Level II - Appian 21.3

    So the working code is:

    a!localVariables(
       local!value: cast(
       'type!{urn:com:appian:types}CES_CHECKS',
        a!fromJson(http!request.body)
        ),
        a!writeToDataStoreEntity(
            dataStoreEntity: cons!CES_POINTER_CHECKS_DATASTOREENTITY,
            valueToStore: local!value,
            onSuccess: a!httpResponse(
            statusCode: 200,
            headers: {
           a!httpHeader(
           name: "Content-Type",
          value: "application/json"
         )
        },
         body: a!toJson(fv!storedValues)
        ),
        onError: a!httpResponse(
        statusCode: 500,
        headers: {
        a!httpHeader(
        name: "Content-Type",
       value: "application/json"
       )
      },
      body: a!toJson(
      {
        error: "There was another error writing to the data store"    
       }
       )
      )
     )

    )

    Which works great when called from UBUNTU curl as follows:

    curl myenv.appian.community/.../myenv_cendpoint -H "Appian-API-Key:MySecretApiKeykjldsjfksjflsjdfsjldsjfkldjslfj" -H "Content-Type:application/json" --request POST --data '{"CNUMBER":12,"CDATE":"20210920","CAMOUNT":2123.44,"CDESC":"a desc"}'

    This was a pain to hack out.  Hope this helps someone!