Reputation: 323
I need to map an entity to a Postgres view which doesn't have primary id, no id defined.
Views in Postgresql can't have primary keys. On the same time Doctrine entities need a primary key defined.
Can I create a "virtual" property some like this?
class MyEntityClass
{
/**
* @var int
*
* @ORM\Id
* @ORM\Column(type="uuid")
*/
private $id;
public function getId(): string
{
return generate_unique_id_just_for_my_join()
}
}
This entity need to be used only for select data. Never for insert/update.
Upvotes: 1
Views: 513
Reputation: 323
Problem solved using Doctrine somposite primary keys
https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/tutorials/composite-primary-keys.html
Upvotes: 1