has anybody an idea why the nativequery result is null?
$rsm = new ResultSetMapping;
$rsm->addEntityResult('AcmeTestBundle:event', 'e');
$rsm->addFieldResult('e', 'id', 'id');
$query = $this->getEntityManager()->createNativeQuery('SELECT id FROM event WHERE publickey COLLATE latin1_general_cs = ?', $rsm);
$query->setParameter(1, $eventkey);
return $query->getSingleResult();
When i run the query directly in mysql, i get the correct result.
This is the created query from the console:
[2012-06-24 18:08:08] doctrine.DEBUG: SELECT id FROM event WHERE publickey COLLATE latin1_general_cs = ? (["key"]) [] []
I’m using the same function on another entity and i get the correct result.
Has anybody an idea?
Thank you!
You probably have to add all entity fields in your ResultSetMapping.
Actually, with only the id, doctrine can’t hydrate your object.