I am having a problem with doctrine optimistic locking.
I have mapped my entity like the documentation says (I guess I think so), and my optimistic locking version doesn't increment. It always stays as null inside the database.
Part of my entity and it's mapping:
Entity:
/** @var AccountID */
private $accountID;
/** @var ClientID */
private $clientID;
/** @var Money */
private $money;
/** @var array|Transfer[] */
private $transfers;
/** @var bool Account status - active not active */
private $active;
/** @var int */
private $version = 1;
Mapping:
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
https://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd">
<entity name="Madkom\ES\Banking\Domain\Account\Account" table="account">
<indexes>
<index name="client_id_idx" columns="client_id"/>
</indexes>
<embedded name="accountID" class="Madkom\ES\Banking\Domain\Account\AccountID" />
<embedded name="clientID" class="Madkom\ES\Banking\Domain\Account\ClientID" />
<embedded name="money" class="Madkom\ES\Banking\Domain\Money" />
<field name="transfers" column="transfers" type="jsonb"/>
<field name="active" column="active" type="boolean" length="32" unique="true" />
<field name="version" type="integer" version="true"/>
</entity>
Whenever I added new record, version is always the same, null. I am using Postgresql 9.4 and Doctrine 2.5.1. The jsonb
type comes from outside library.