I am following this question here Explicitly set Id with Doctrine when using "AUTO" strategy
But I can't seem to make it work on my application.
My entity SuppliersOrdersDeliveries:
class SuppliersOrdersDeliveries
{
/**
* @var integer
*
* @ORM\Column(name="supplier_order_id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="NONE")
*/
private $supplierOrderId;
{...}
}
The main key is
supplier_order_id
YAML file:
id:
supplierOrderId:
type: integer
nullable: false
unsigned: true
comment: 'Supplier order ID'
id: true
column: supplier_order_id
generator:
strategy: NONE
And this is how I persist the data into DB:
$dateTimeDeliveryTerm = new DateTime($generalDeliveryTerm);
$delivery = new \Doctrine\Entities\SuppliersOrdersDeliveries();
$delivery->setGeneralDeliveryTerm($dateTimeDeliveryTerm);
$delivery->setSupplierOrderId($supplier_order['supplier_order_id']);
$delivery->setCmsUserId($this->cmsusers->get('id'));
$this->eMgr->getClassMetaData(get_class($delivery))->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator());
$this->eMgr->getClassMetaData(get_class($delivery))->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
$this->eMgr->persist($delivery);
$this->eMgr->flush();
Problem is that I still get the null on insert at supplier_order_id variable.
Also I tried to set the strategy to NONE on YAML and entity files, but the error stays the same as I would change the type later using setIdGeneratorType function.
I don't want the supplier_order_id to be auto incremented or anything else, I need to set it by myself.
Any ideas?