I have the following Entity in Symfony 2 with an ID generated by an Oracle Sequence:
namespace PSBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="CONTRATO")
* @ORM\Entity
* @ORM\Entity(repositoryClass="PSBundle\Entity\ContratoRepository")
*/
class Contrato
{
/**
* @var integer
*
* @ORM\Column(name="ID_CONTRATO", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="SEQUENCE")
* @ORM\SequenceGenerator(sequenceName="SID_CONTRATO", allocationSize=1, initialValue=1)
*/
private $idContrato;
// Other fields...
}
But when I do:
$entityContrato = new Contrato();
// Set some fields
$em->persist($entityContrato);
I get:
Entity of type PSBundle\Entity\Contrato is missing an assigned ID for field 'idContrato'. The identifier generation strategy for this entity requires the ID field to be populated before EntityManager#persist() is called. If you want automatically generated identifiers instead you need to adjust the metadata mapping accordingly.
I know that SID_CONTRATO
is well defined as if I select the NEXTVAL it works:
What I'm missing? Any kind of light in the subject would be more than appreciated, my related dependencies are:
"php": "7.2",
"symfony/symfony": "2.3.42",
"doctrine/orm": "2.3.x-dev",
"doctrine/doctrine-bundle": "1.2.0",
Doctrine config (from config/config.yml
, I don't have a doctrine.yaml
file):
# Doctrine Configuration
doctrine:
dbal:
driver: oci8
port: 1521
dbname: ORCL
host: