DDC-1376: Foreign key not available to order when using findBy() #1995

Closed
doctrinebot opened this Issue Sep 14, 2011 · 3 comments

1 participant

@doctrinebot

Jira issue originally created by user presteus:

<?php
/****
 * Service
 *
 * @Entity(repositoryClass="App*Model_Repository_Si*Service")
 * @Table(name="service")
 */
class App*Model_Entities_Si*Service
{
   /****
    * @var int
    *
    * @Id
    * @GeneratedValue(strategy="SEQUENCE")
    * @Column(name="pk", type="integer")
    */
   public $pk;

    /****
     * Service parent
     * @var App*Model_Entities_Si*Service
     *
     * @ManyToOne(targetEntity="App*Model_Entities_Si*Service", cascade={"all"}, inversedBy="service")
     * @JoinColumn(name="pk_service", referencedColumnName="pk")
     */
    private $service;

   /****
    * Returns an App*Model_Entities_Si*Service that represents the service
    *
    * @return App*Model_Entities_Si*Service
    */
   public function getService(){
      return $this->service;
   }
   /****
    * Set an App*Model_Entities_Si*Service that represents a service
    *
    * @param App*Model_Entities_Si*Service $newService
    */
   public function setService($newService){
      $this->service = $newService;
   }
}

$service = $this->service('Service_Type', true);
$serviceType = $service->findOneBy(array('code' => 'service'));

$service = $this->service('Service', true);
$services = $service->findBy(
    array('serviceType' => $serviceType->getPk()),
    array('service' => 'ASC')
);

Using orderBy parameter of EntityRepository::findBy() with Foreign Key do not work.
An Unrecognized field error occured.

Of course, i can use DQL but i think this function should work with mapping.

Thank you in advance

@doctrinebot

Comment created by @beberlei:

Not a bug

@doctrinebot

Comment created by @FabioBatSilva:

Fixed : b30b068

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added this to the 2.4 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment