0
Well, I’ve looking in some articles and changed the way I update the entity:
@PutMapping("/update")
public StructureElement update(@RequestBody StructureElement se){
StructureElement databaseElement;
logger.info("Call to StructureElementController.update with se = " + se);
this.connectToDatabase();
try{
databaseElement = this.repository.findOne(se.getId());
if(databaseElement == null){
logger.error("Could not find StructureElement to update. se = " + se);
return null;
}
// Update
databaseElement.setDescription(se.getDescription());
databaseElement.setTag(se.getTag());
databaseElement.setOptional(se.isOptional());
databaseElement.setRepetitive(se.isRepetitive());
databaseElement.getSignature().setModificationDate(new Date());
databaseElement = this.repository.save(databaseElement);
logger.info("Updated SE = " + databaseElement);
}catch (Exception e){
logger.error("Could not update structure element. se = " + se, e);
return null;
}
return databaseElement;
}
Now this works.
Seems that Spring data JPA doesnt want to update an entity like a simple JPA EntityManager
….
Source:stackexchange.com