Doctrine findOneBy method not working

Viewed 72673

I am creating small application with just two entities, Order and Shipment.

The Shipment entity is as follows: (methods removed to keep it short)

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

/**
 * @var string $username
 *
 * @ORM\Column(name="username", type="string", length=255)
 */
private $username;

/**
 * @var string $password
 *
 * @ORM\Column(name="password", type="string", length=255)
 */
private $password;

/**
 * @var integer $order_id
 *
 * @ORM\Column(name="order_id", type="integer")
 */
private $order_id;

/**
 * @var smallint $payment_type
 *
 * @ORM\Column(name="payment_type", type="smallint")
 */
private $payment_type;

In my controller I am trying to query using the order_id but my findOneByOrderId method is not working.

$orderExists = $this->getDoctrine()
                ->getRepository('ShipBundle:Shipment')
                ->findOneByOrderId($orderId);

var_dump($orderExists);     die();

The error I get is:

Entity 'ShipBundle\Entity\Shipment' has no field 'orderId'. You can therefore not call 'findOneByOrderId' on the entities' repository.

If I am not wrong, Doctrine find methods join the variables at underscores and capitalize them. What am I doing wrong?

4 Answers
Related