DDC-1165: [ Proposal] entityMethod#find() for Entity with ForeignKey as PrimaryKey, pass entity object instead of id #1462

Closed
opened 2026-01-22 13:15:17 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (May 21, 2011).

Originally assigned to: @guilhermeblanco on GitHub.

Jira issue originally created by user benoit:

Hi all, i am currently using Doctrine 2.1Beta because i have an entity with foreignKey as primaryKey:

class IndividualsStatus
{
/****
* @var Individuals
*
* @Id
* @ManyToOne(targetEntity="Individuals", inversedBy="diagnosers", cascade={"persist","refresh"})
* @JoinColumns({
* @JoinColumn(name="individuals_id", referencedColumnName="id")
* })
*/
private $individuals;

/****
 * @var Diagnosers
 *
 * @Id
 * @ManyToOne(targetEntity="Diagnosers", inversedBy="individuals", cascade={"persist","refresh"})
 * @JoinColumns({
 *   @JoinColumn(name="diagnosers_id", referencedColumnName="id")
 * })
 */
private $diagnosers;

/****
* @var smallint $status
*
* @Column(name="status_individuals", type="smallint")
*/
private $statusIndividuals;

}

i use the em find method to get an IndividualsStatus entity, i am expecting to do:

$individuals = $em->find('Individuals', 10);
$diagnosers = $em->find('Diagnosers', 15);

$individualsStatus = $em->find('IndividualsStatus', array('individiduals' => $individuals, 'diagnosers' => $diagnosers));

But i have to do:
$individualsStatus = $em->find('IndividualsStatus', array('individiduals' => $individuals->getId(), 'diagnosers' => $diagnosers->getId()));

It's very trivial but maybe another people was expecting that too.

Cheers

Originally created by @doctrinebot on GitHub (May 21, 2011). Originally assigned to: @guilhermeblanco on GitHub. Jira issue originally created by user benoit: Hi all, i am currently using Doctrine 2.1Beta because i have an entity with foreignKey as primaryKey: class IndividualsStatus { /**** \* @var Individuals * \* @Id \* @ManyToOne(targetEntity="Individuals", inversedBy="diagnosers", cascade={"persist","refresh"}) \* @JoinColumns({ \* @JoinColumn(name="individuals_id", referencedColumnName="id") \* }) */ private $individuals; ``` /**** * @var Diagnosers * * @Id * @ManyToOne(targetEntity="Diagnosers", inversedBy="individuals", cascade={"persist","refresh"}) * @JoinColumns({ * @JoinColumn(name="diagnosers_id", referencedColumnName="id") * }) */ private $diagnosers; /**** * @var smallint $status * * @Column(name="status_individuals", type="smallint") */ private $statusIndividuals; ``` } i use the em find method to get an IndividualsStatus entity, i am expecting to do: $individuals = $em->find('Individuals', 10); $diagnosers = $em->find('Diagnosers', 15); $individualsStatus = $em->find('IndividualsStatus', array('individiduals' => $individuals, 'diagnosers' => $diagnosers)); But i have to do: $individualsStatus = $em->find('IndividualsStatus', array('individiduals' => $individuals->getId(), 'diagnosers' => $diagnosers->getId())); It's very trivial but maybe another people was expecting that too. Cheers
admin added the Improvement label 2026-01-22 13:15:17 +01:00
admin closed this issue 2026-01-22 13:15:18 +01:00
Author
Owner

@doctrinebot commented on GitHub (Aug 14, 2011):

Comment created by @guilhermeblanco:

This issue is fixed in latest 2.2-DEV by this commit: 63a2f02f4d

Cheers,

@doctrinebot commented on GitHub (Aug 14, 2011): Comment created by @guilhermeblanco: This issue is fixed in latest 2.2-DEV by this commit: https://github.com/doctrine/doctrine2/commit/63a2f02f4ddea1ab9191b0e4acfd1d790d2247c7 Cheers,
Author
Owner

@doctrinebot commented on GitHub (Aug 14, 2011):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Aug 14, 2011): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1462