Hmmm, i hope i'm not alone with this if other users come from the hibernate side.
I will store a new entity where the id is 'null' per default. Hibernate will handle this.
@id
private Long id;
private String loginname;
OxSecUser obj = new OxSecUser();
obj.setLoginname("test_loginname");
. . .
response = invocationBuilder.post(Entity.entity(obj, MediaType.APPLICATION_JSON));
This generates a Json:
{"id":null,"version":0,"loginname":"test_loginname","password": . . .
On the server side by the POST method it throws an error:
! Causing: com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: de.oxitec.zkboost.backend.model.OxSecUser["id"])
! at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:210) ~[jackson-databind-2.5.1.jar:2.5.1]
! at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:177) ~[jackson-databind-2.5.1.jar:2.5.1]
! at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.wrapAndThrow(BeanDeserializerBase.java:1446) ~[jackson-databind-2.5.1.jar:2.5.1]
! at com.fasterxml.jackson.module.afterburner.deser.SuperSonicBeanDeserializer.deserializeFromObject(SuperSonicBeanDeserializer.java:225) ~[jackson-module-afterburner-2.5.1.jar:2.5.1]
! at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeWithObjectId(BeanDeserializerBase.java:1045) ~[jackson-databind-2.5.1.jar:2.5.1]
!
So, my question is: must i modify the model classes so that a new entity has a default id value other than NULL i.e.
@Id
private Long id = Long.MIN_VALUE;
where i evaluate in the save method the value as a new entity?
Thanks all for informations about that
Stephan