Symfony, rather Doctrine, offers Optimistic Locking by adding the @Version Annotation to the property of an entity. In practice the version-property on the User-Entity will then look like this:
/**
* @Groups({
* "user:item:get"
* })
* @ORM\Version
* @ORM\Column(type="integer")
*/
private $version;
The user:item:get Group in the @Groups-Annotation will add the value of the version-property to the response of a GET-Request. There is no direct implementation of any Request, we use the CRUD-API of an Entity that leverages internal Provider/Persister system.
Let us assume the current version on the User-Resource we are about to change is 10.
Executing a PUT-Request on that Resource with a body like this:
{
"zip": 10000
"version": 5
}
will be completely valid. The zip-property will be changed to 10000, even though the version-numbers are mismatched.
What am I doing wrong? Is the internal Persister-system unable to validate the version number by itself or am I providing it incorrectly - is it not supposed to be in the request body?
Thanks!