I have a post entity which may represent the Post or Comment to another post.
/**
* @ORM\ManyToOne(targetEntity="Post", inversedBy="comments")
*/
private $post;
public function setPost($post) { $this->post = $post; return $this; }
public function getPost() { return $this->post; }
/**
* @ORM\OneToMany(targetEntity="Post", mappedBy="post", cascade={"remove"})
*/
private $comments;
public function getComments() { return $this->comments; }
....
So normally i can get parent Post by ->getPost();
.
Now i want to optimize request and using partial select like this one
$query = $this->getEntityManager()
->createQuery(
"SELECT partial post.{id, title, Post}
FROM XXXMyBundle:Post post
ORDER BY post.id ASC
")
But each time i see errors like
There is no mapped field named 'Post' on class
I tried to change field name in query to post_id, post or postId but it didn't help.
Is there any way to get the post_id (that's name of the field in database) ?