I have two models called Person
and Tag
. One Person has many Tags, and the Tag primary key is a composite key of person_id
and tag
(Person $person
and $tag
in Doctrine2).
There is a data field (BLOB
) in the Tag
model with a lot of data. I am setting up a query that does not require the data from that field, so I want to set up a query that does not retrieve that field.
I tried with the following query:
SELECT c, PARTIAL t.{tag} FROM Contact c LEFT JOIN c.tags
Here, I get the somewhat expected error The partial field selection of class Tag must contain the identifier. No problem, I add the contact field:
SELECT c, PARTIAL t.{contact,tag} FROM Contact c LEFT JOIN c.tags
But now, I get There is no mapped field named 'contact' on class Tag.
Does Doctrine2 not support partial queries on composite keys?
Here is the Tag class:
/** @Entity @Table(name="tag") **/
class Tag
{
/** @Id @ManyToOne(targetEntity="Contact",inversedBy="tags") @var Contact **/
protected $contact;
/** @Id @Column(type="string",length=10,nullable=false) @var string **/
protected $tag;
/** @Column(type="blob") **/
protected $data;
}