geekInThePink geekInThePink - 7 months ago 82
SQL Question

Uncaught PHP Exception Doctrine\ORM\Query\QueryException: "[Semantical Error] line?

I am trying to create a search field for the rejected transactions page in our web application project, I'm using symfony2 framework, I'm stuck coz there was an error saying,

'[Semantical Error] line 0, col 235 near 'b JOIN b.ediAk403ErrorCodes': Error: Class Matrix\MatrixEdiBundle\Entity\EdiTransaction has no association named edi997Details'

and also

'CRITICAL - Uncaught PHP Exception Doctrine\ORM\Query\QueryException: "[Semantical Error] line 0, col 235 near 'b JOIN b.ediAk403ErrorCodes': Error: Class Matrix\MatrixEdiBundle\Entity\EdiTransaction has no association named edi997Details" at /tmxpage/apache/htdocsEDI/Editracker/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php line 63 '

here is my code for that (in my repository) :

public function getDetails($gsNumber, $senderId, $receiverId, $page = 1, $limit = 5 ){

$em = $this->getEntityManager();

$query = $em->createQuery(

'SELECT partial a.{ediTransactionId, senderId, receiverId, gsNumber, isaNumber, fileName },

partial b.{errorCodeId, noOfTrans},

partial c.{errorCode, condition}

FROM MatrixEdiBundle:EdiTransaction a

JOIN a.edi997Details b

JOIN b.ediAk403ErrorCodes c

WHERE b.errorCodeId != 1

AND a.flag = 1

AND a.gsNumber LIKE :gsNumber

AND a.senderId LIKE :senderId

AND a.recieverId LIKE :receiverId')

->setParameter('gsNumber', "%gsNumber%")

->setParameter('senderId', "%senderId%")

->setParameter('receiverId'ssss, "%receiverId%")

->setFirstResult(($page-1)*$limit)

->setMaxResults($limit);



$paginator = new Paginator($query, $fetchJoinCollection = false );

$paginator->setUseOutputWalkers(false);


return $paginator;
}


and here is my entity code for the talble ediAk403ErrorCodes :

class EdiAk403ErrorCodes
{
/**
* @var string
*
* @ORM\Column(name="condition", type="string", length=50, nullable=false)
*/
private $condition;

/**
* @var integer
*
* @ORM\Column(name="error_code", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $errorCode;

/**
* Set condition
*
* @param string $condition
* @return EdiAk403ErrorCodes
*/

public function setCondition($condition)
{
$this->condition = $condition;

return $this;
}

/**
* Get condition
*
* @return string
*/
public function getCondition()
{
return $this->condition;
}

/**
* Get errorCode
*
* @return integer
*/
public function getErrorCode()
{
return $this->errorCode;
}

/**
* Get edi997Details
*
* @return \Matrix\MatrixEdiBundle\Entity\Edi997Details
*/
public function getEdi997Details()
{
return $this->edi997Details;
}

}

Answer

Seems your Entity Class EdiTransaction don't have an explicit doctrine relation with the table EdiAk403ErrorCodes. So try adding the field definition with the correct annotation in the EdiTransaction class as follow:

EdiTransaction

/**
 * @ORM\ManyToOne(targetEntity="Matrix\MatrixEdiBundle\Entity\Edi997Details", inversedBy="editTransactions")
 * @ORM\JoinColumn(name="edit_details_id", referencedColumnName="id")
 */
private $edi997Details;

Hope this help